diff --git a/patches/server/0005-Paper-config-files.patch b/patches/server/0005-Paper-config-files.patch index 8115fc2d48..c9839c6460 100644 --- a/patches/server/0005-Paper-config-files.patch +++ b/patches/server/0005-Paper-config-files.patch @@ -861,10 +861,10 @@ index 0000000000000000000000000000000000000000..69add4a7f1147015806bc9b63a8340d1 +} diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java new file mode 100644 -index 0000000000000000000000000000000000000000..1029b6de6f36b08bf634b4056ef5701383f6f258 +index 0000000000000000000000000000000000000000..1c562f384a66258b1a33c4ab33370b0a1cdeeeb1 --- /dev/null +++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -@@ -0,0 +1,467 @@ +@@ -0,0 +1,470 @@ +package io.papermc.paper.configuration; + +import com.google.common.base.Suppliers; @@ -903,6 +903,8 @@ index 0000000000000000000000000000000000000000..1029b6de6f36b08bf634b4056ef57013 +import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap; +import it.unimi.dsi.fastutil.objects.Reference2LongMap; +import it.unimi.dsi.fastutil.objects.Reference2LongOpenHashMap; ++import it.unimi.dsi.fastutil.objects.Reference2ObjectMap; ++import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Type; @@ -1108,6 +1110,7 @@ index 0000000000000000000000000000000000000000..1029b6de6f36b08bf634b4056ef57013 + .serializers(serializers -> serializers + .register(new TypeToken>() {}, new FastutilMapSerializer.SomethingToPrimitive>(Reference2IntOpenHashMap::new, Integer.TYPE)) + .register(new TypeToken>() {}, new FastutilMapSerializer.SomethingToPrimitive>(Reference2LongOpenHashMap::new, Long.TYPE)) ++ .register(new TypeToken>() {}, new FastutilMapSerializer.SomethingToSomething>(Reference2ObjectOpenHashMap::new)) + .register(new TypeToken>() {}, new TableSerializer()) + .register(DespawnRange.class, DespawnRange.SERIALIZER) + .register(StringRepresentableSerializer::isValidFor, new StringRepresentableSerializer()) @@ -1426,7 +1429,7 @@ new file mode 100644 index 0000000000000000000000000000000000000000..dad3fcc689ec806f985122a7cbd501a7d0fd0d36 --- /dev/null +++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java -@@ -0,0 +1,581 @@ +@@ -0,0 +1,588 @@ +package io.papermc.paper.configuration; + +import com.google.common.collect.HashBasedTable; @@ -1451,6 +1454,8 @@ index 0000000000000000000000000000000000000000..dad3fcc689ec806f985122a7cbd501a7 +import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap; +import it.unimi.dsi.fastutil.objects.Reference2LongMap; +import it.unimi.dsi.fastutil.objects.Reference2LongOpenHashMap; ++import it.unimi.dsi.fastutil.objects.Reference2ObjectMap; ++import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap; +import java.util.Arrays; +import java.util.IdentityHashMap; +import java.util.List; @@ -1628,6 +1633,11 @@ index 0000000000000000000000000000000000000000..dad3fcc689ec806f985122a7cbd501a7 + } + } + ++ public Reference2ObjectMap, IntOr.Disabled> despawnTime = Util.make(new Reference2ObjectOpenHashMap<>(), map -> { ++ map.put(EntityType.SNOWBALL, IntOr.Disabled.DISABLED); ++ map.put(EntityType.LLAMA_SPIT, IntOr.Disabled.DISABLED); ++ }); ++ + @PostProcess + public void precomputeDespawnDistances() throws SerializationException { + for (Map.Entry entry : this.despawnRanges.entrySet()) { @@ -2802,41 +2812,43 @@ index 0000000000000000000000000000000000000000..7fc0905fc6b8f5df762b4cea573f935d +} diff --git a/src/main/java/io/papermc/paper/configuration/serializer/collections/FastutilMapSerializer.java b/src/main/java/io/papermc/paper/configuration/serializer/collections/FastutilMapSerializer.java new file mode 100644 -index 0000000000000000000000000000000000000000..4af710e144b70933d750c22edfe484c18e4a3540 +index 0000000000000000000000000000000000000000..5a0ecd5423be7fd84e02808a3de4cf3d75d96ecd --- /dev/null +++ b/src/main/java/io/papermc/paper/configuration/serializer/collections/FastutilMapSerializer.java -@@ -0,0 +1,69 @@ +@@ -0,0 +1,85 @@ +package io.papermc.paper.configuration.serializer.collections; + +import io.leangen.geantyref.GenericTypeReflector; +import io.leangen.geantyref.TypeFactory; -+import org.checkerframework.checker.nullness.qual.Nullable; -+import org.spongepowered.configurate.ConfigurationNode; -+import org.spongepowered.configurate.serialize.SerializationException; -+import org.spongepowered.configurate.serialize.TypeSerializer; -+ +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.Collections; +import java.util.Map; +import java.util.function.Function; ++import org.jspecify.annotations.NullMarked; ++import org.jspecify.annotations.Nullable; ++import org.spongepowered.configurate.ConfigurationNode; ++import org.spongepowered.configurate.serialize.SerializationException; ++import org.spongepowered.configurate.serialize.TypeSerializer; + +@SuppressWarnings("rawtypes") ++@NullMarked +public abstract class FastutilMapSerializer> implements TypeSerializer { -+ private final Function factory; + -+ protected FastutilMapSerializer(final Function factory) { ++ private final Function factory; ++ ++ protected FastutilMapSerializer(final Function factory) { + this.factory = factory; + } + + @Override + public M deserialize(final Type type, final ConfigurationNode node) throws SerializationException { -+ @Nullable final Map map = (Map) node.get(this.createBaseMapType((ParameterizedType) type)); ++ final Map map = (Map) node.get(this.createBaseMapType((ParameterizedType) type)); + return this.factory.apply(map == null ? Collections.emptyMap() : map); + } + + @Override -+ public void serialize(final Type type, @Nullable final M obj, final ConfigurationNode node) throws SerializationException { ++ public void serialize(final Type type, final @Nullable M obj, final ConfigurationNode node) throws SerializationException { + if (obj == null || obj.isEmpty()) { + node.raw(null); + } else { @@ -2848,6 +2860,7 @@ index 0000000000000000000000000000000000000000..4af710e144b70933d750c22edfe484c1 + protected abstract Type createBaseMapType(final ParameterizedType type); + + public static final class SomethingToPrimitive> extends FastutilMapSerializer { ++ + private final Type primitiveType; + + public SomethingToPrimitive(final Function factory, final Type primitiveType) { @@ -2862,6 +2875,7 @@ index 0000000000000000000000000000000000000000..4af710e144b70933d750c22edfe484c1 + } + + public static final class PrimitiveToSomething> extends FastutilMapSerializer { ++ + private final Type primitiveType; + + public PrimitiveToSomething(final Function factory, final Type primitiveType) { @@ -2874,6 +2888,18 @@ index 0000000000000000000000000000000000000000..4af710e144b70933d750c22edfe484c1 + return TypeFactory.parameterizedClass(Map.class, GenericTypeReflector.box(this.primitiveType), type.getActualTypeArguments()[0]); + } + } ++ ++ public static final class SomethingToSomething> extends FastutilMapSerializer { ++ ++ public SomethingToSomething(final Function factory) { ++ super(factory); ++ } ++ ++ @Override ++ protected Type createBaseMapType(final ParameterizedType type) { ++ return TypeFactory.parameterizedClass(Map.class, type.getActualTypeArguments()[0], type.getActualTypeArguments()[1]); ++ } ++ } +} diff --git a/src/main/java/io/papermc/paper/configuration/serializer/collections/MapSerializer.java b/src/main/java/io/papermc/paper/configuration/serializer/collections/MapSerializer.java new file mode 100644 diff --git a/patches/server/1065-Configurable-Entity-Despawn-Time.patch b/patches/server/1065-Configurable-Entity-Despawn-Time.patch new file mode 100644 index 0000000000..e703796c72 --- /dev/null +++ b/patches/server/1065-Configurable-Entity-Despawn-Time.patch @@ -0,0 +1,39 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kevin Raneri +Date: Mon, 30 Sep 2024 09:50:55 -0700 +Subject: [PATCH] Configurable Entity Despawn Time + + +diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java +index 4b54d0ea31062972e68ee8fafe3cfaf68f65a5cd..7a74e06f98dd17b055fa4697635395a8a9fc77ae 100644 +--- a/src/main/java/net/minecraft/world/entity/Entity.java ++++ b/src/main/java/net/minecraft/world/entity/Entity.java +@@ -429,6 +429,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + private UUID originWorld; + public boolean freezeLocked = false; // Paper - Freeze Tick Lock API + public boolean fixedPose = false; // Paper - Expand Pose API ++ private final int despawnTime; // Paper - entity despawn time limit + + public void setOrigin(@javax.annotation.Nonnull Location location) { + this.origin = location.toVector(); +@@ -552,6 +553,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + + public Entity(EntityType type, Level world) { + this.id = Entity.ENTITY_COUNTER.incrementAndGet(); ++ this.despawnTime = type == EntityType.PLAYER ? -1 : world.paperConfig().entities.spawning.despawnTime.getOrDefault(type, io.papermc.paper.configuration.type.number.IntOr.Disabled.DISABLED).or(-1); // Paper - entity despawn time limit + this.passengers = ImmutableList.of(); + this.deltaMovement = Vec3.ZERO; + this.bb = Entity.INITIAL_AABB; +@@ -845,6 +847,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + } + + public void tick() { ++ // Paper start - entity despawn time limit ++ if (this.despawnTime >= 0 && this.tickCount >= this.despawnTime) { ++ this.discard(); ++ return; ++ } ++ // Paper end - entity despawn time limit + this.baseTick(); + } +