diff --git a/patches/server/Configurable-max-leash-distance.patch b/patches/server/Configurable-max-leash-distance.patch index 9109d4354b..14fe9099ac 100644 --- a/patches/server/Configurable-max-leash-distance.patch +++ b/patches/server/Configurable-max-leash-distance.patch @@ -13,7 +13,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } - if ((double) f > 10.0D) { -+ if ((double) f > entity.level().paperConfig().misc.maxLeashDistance) { // Paper - Configurable max leash distance ++ if ((double) f > entity.level().paperConfig().misc.maxLeashDistance.or(LEASH_TOO_FAR_DIST)) { // Paper - Configurable max leash distance ((Leashable) entity).leashTooFarBehaviour(); } else if ((double) f > 6.0D) { ((Leashable) entity).elasticRangeLeashBehaviour(entity1, f); +diff --git a/src/main/java/net/minecraft/world/entity/TamableAnimal.java b/src/main/java/net/minecraft/world/entity/TamableAnimal.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/TamableAnimal.java ++++ b/src/main/java/net/minecraft/world/entity/TamableAnimal.java +@@ -0,0 +0,0 @@ public abstract class TamableAnimal extends Animal implements OwnableEntity { + @Override + public boolean handleLeashAtDistance(Entity leashHolder, float distance) { + if (this.isInSittingPose()) { +- if (distance > 10.0F) { ++ if (distance > (float) this.level().paperConfig().misc.maxLeashDistance.or(Leashable.LEASH_TOO_FAR_DIST)) { // Paper - Configurable max leash distance + this.dropLeash(true, true); + } + diff --git a/patches/server/Expand-EntityUnleashEvent.patch b/patches/server/Expand-EntityUnleashEvent.patch index d25ae9f802..f5bd7efda3 100644 --- a/patches/server/Expand-EntityUnleashEvent.patch +++ b/patches/server/Expand-EntityUnleashEvent.patch @@ -27,11 +27,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } @@ -0,0 +0,0 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + protected void removeAfterChangingDimensions() { this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION, null); // CraftBukkit - add Bukkit remove cause - if (this instanceof Leashable leashable) { +- if (this instanceof Leashable leashable) { - this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit - leashable.dropLeash(true, false); ++ if (this instanceof Leashable leashable && leashable.isLeashed()) { // Paper - only call if it is leashed + // Paper start - Expand EntityUnleashEvent + final EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN, false); // CraftBukkit + event.callEvent(); @@ -95,6 +97,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } return flag1; +diff --git a/src/main/java/net/minecraft/world/entity/TamableAnimal.java b/src/main/java/net/minecraft/world/entity/TamableAnimal.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/TamableAnimal.java ++++ b/src/main/java/net/minecraft/world/entity/TamableAnimal.java +@@ -0,0 +0,0 @@ public abstract class TamableAnimal extends Animal implements OwnableEntity { + public boolean handleLeashAtDistance(Entity leashHolder, float distance) { + if (this.isInSittingPose()) { + if (distance > (float) this.level().paperConfig().misc.maxLeashDistance.or(Leashable.LEASH_TOO_FAR_DIST)) { // Paper - Configurable max leash distance +- this.dropLeash(true, true); ++ // Paper start - Expand EntityUnleashEvent ++ org.bukkit.event.entity.EntityUnleashEvent event = new org.bukkit.event.entity.EntityUnleashEvent(this.getBukkitEntity(), org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.DISTANCE, true); ++ if (!event.callEvent()) return false; ++ this.dropLeash(true, event.isDropLeash()); ++ // Paper end - Expand EntityUnleashEvent + } + + return false; diff --git a/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java b/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java diff --git a/patches/server/Fix-item-duplication-and-teleport-issues.patch b/patches/server/Fix-item-duplication-and-teleport-issues.patch index 88c5b7a0da..6d7e349aa4 100644 --- a/patches/server/Fix-item-duplication-and-teleport-issues.patch +++ b/patches/server/Fix-item-duplication-and-teleport-issues.patch @@ -52,8 +52,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (entity2 != null) { if (this != entity2) { + // Paper start - Fix item duplication and teleport issues -+ if (this instanceof Mob) { -+ ((Mob) this).dropLeash(true, true); // Paper drop lead ++ if (this instanceof Leashable leashable) { ++ leashable.dropLeash(true, true); // Paper drop lead + } + // Paper end - Fix item duplication and teleport issues entity2.restoreFrom(this); diff --git a/patches/server/Paper-config-files.patch b/patches/server/Paper-config-files.patch index 90a92bdcd2..9a44c83528 100644 --- a/patches/server/Paper-config-files.patch +++ b/patches/server/Paper-config-files.patch @@ -1031,6 +1031,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + .register(MapSerializer.TYPE, new MapSerializer(false)) + .register(new EnumValueSerializer()) + .register(new ComponentSerializer()) ++ .register(IntOr.Default.SERIALIZER) ++ .register(IntOr.Disabled.SERIALIZER) ++ .register(DoubleOr.Default.SERIALIZER) ++ .register(DoubleOr.Disabled.SERIALIZER) ++ .register(BooleanOrDefault.SERIALIZER) ++ .register(Duration.SERIALIZER) ++ .register(DurationOrDisabled.SERIALIZER) ++ .register(NbtPathSerializer.SERIALIZER) + ); + } + @@ -1054,9 +1062,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + .header(GLOBAL_HEADER) + .serializers(builder -> builder + .register(new PacketClassSerializer()) -+ .register(IntOr.Disabled.SERIALIZER) -+ .register(IntOr.Default.SERIALIZER) -+ .register(DoubleOr.Default.SERIALIZER) + ); + } + @@ -1100,14 +1105,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + .register(new TypeToken>() {}, new TableSerializer()) + .register(DespawnRange.class, DespawnRange.SERIALIZER) + .register(StringRepresentableSerializer::isValidFor, new StringRepresentableSerializer()) -+ .register(IntOr.Default.SERIALIZER) -+ .register(IntOr.Disabled.SERIALIZER) -+ .register(DoubleOr.Default.SERIALIZER) -+ .register(BooleanOrDefault.SERIALIZER) -+ .register(Duration.SERIALIZER) -+ .register(DurationOrDisabled.SERIALIZER) + .register(EngineMode.SERIALIZER) -+ .register(NbtPathSerializer.SERIALIZER) + .register(FallbackValueSerializer.create(contextMap.require(SPIGOT_WORLD_CONFIG_CONTEXT_KEY).get(), MinecraftServer::getServer)) + .register(new RegistryValueSerializer<>(new TypeToken>() {}, access, Registries.ENTITY_TYPE, true)) + .register(new RegistryValueSerializer<>(Item.class, access, Registries.ITEM, true)) @@ -1985,7 +1983,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public boolean showSignClickCommandFailureMsgsToPlayer = false; + public RedstoneImplementation redstoneImplementation = RedstoneImplementation.VANILLA; + public boolean disableEndCredits = false; -+ public double maxLeashDistance = Leashable.LEASH_TOO_FAR_DIST; ++ public DoubleOr.Default maxLeashDistance = DoubleOr.Default.USE_DEFAULT; + public boolean disableSprintInterruptionOnAttack = false; + public int shieldBlockingDelay = 5; + public boolean disableRelativeProjectileVelocity = false; @@ -4835,6 +4833,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import com.google.common.base.Preconditions; +import java.util.OptionalDouble; ++import java.util.function.DoublePredicate; +import java.util.function.Function; +import java.util.function.Predicate; +import org.spongepowered.configurate.serialize.ScalarSerializer; @@ -4857,6 +4856,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public static final ScalarSerializer SERIALIZER = new Serializer<>(Default.class, Default::new, DEFAULT_VALUE, USE_DEFAULT); + } + ++ record Disabled(OptionalDouble value) implements DoubleOr { ++ private static final String DISABLED_VALUE = "disabled"; ++ public static final Disabled DISABLED = new Disabled(OptionalDouble.empty()); ++ public static final ScalarSerializer SERIALIZER = new Serializer<>(Disabled.class, Disabled::new, DISABLED_VALUE, DISABLED); ++ ++ public boolean test(DoublePredicate predicate) { ++ return this.value.isPresent() && predicate.test(this.value.getAsDouble()); ++ } ++ ++ public boolean enabled() { ++ return this.value.isPresent(); ++ } ++ } ++ + final class Serializer extends OptionalNumSerializer { + Serializer(final Class classOfT, final Function factory, String emptySerializedValue, T emptyValue) { + super(classOfT, emptySerializedValue, emptyValue, OptionalDouble::empty, OptionalDouble::isEmpty, factory, double.class);