aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0544-Add-dropLeash-variable-to-EntityUnleashEvent.patch
diff options
context:
space:
mode:
authorTomTom <[email protected]>2023-11-03 15:05:57 +0100
committerGitHub <[email protected]>2023-11-03 14:05:57 +0000
commit487109fddc74813b81bf17dfe8ec7be443963d9d (patch)
tree8fbfe1ec07553dc9149882389257d948b0486e02 /patches/server/0544-Add-dropLeash-variable-to-EntityUnleashEvent.patch
parent8493340be4fa69fa9369719272e5dff1b7a2f455 (diff)
downloadPaper-487109fddc74813b81bf17dfe8ec7be443963d9d.tar.gz
Paper-487109fddc74813b81bf17dfe8ec7be443963d9d.zip
Readd 0414 use distance map to optimise entity tracker (#9868)
Diffstat (limited to 'patches/server/0544-Add-dropLeash-variable-to-EntityUnleashEvent.patch')
-rw-r--r--patches/server/0544-Add-dropLeash-variable-to-EntityUnleashEvent.patch140
1 files changed, 140 insertions, 0 deletions
diff --git a/patches/server/0544-Add-dropLeash-variable-to-EntityUnleashEvent.patch b/patches/server/0544-Add-dropLeash-variable-to-EntityUnleashEvent.patch
new file mode 100644
index 0000000000..cbc3cf3058
--- /dev/null
+++ b/patches/server/0544-Add-dropLeash-variable-to-EntityUnleashEvent.patch
@@ -0,0 +1,140 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Nassim Jahnke <[email protected]>
+Date: Fri, 29 Jan 2021 15:13:11 +0100
+Subject: [PATCH] Add dropLeash variable to EntityUnleashEvent
+
+
+diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
+index 7bbb68bf06e04b58b6c4fa546fe919e387e00b27..c17ea8bdbbd5581b4a2728564fad72f6bb518f66 100644
+--- a/src/main/java/net/minecraft/world/entity/Mob.java
++++ b/src/main/java/net/minecraft/world/entity/Mob.java
+@@ -1306,12 +1306,15 @@ public abstract class Mob extends LivingEntity implements Targeting {
+ return InteractionResult.PASS;
+ } else if (this.getLeashHolder() == player) {
+ // CraftBukkit start - fire PlayerUnleashEntityEvent
+- if (CraftEventFactory.callPlayerUnleashEntityEvent(this, player, hand).isCancelled()) {
++ // Paper start - drop leash variable
++ org.bukkit.event.player.PlayerUnleashEntityEvent event = CraftEventFactory.callPlayerUnleashEntityEvent(this, player, hand, !player.getAbilities().instabuild);
++ if (event.isCancelled()) {
++ // Paper end
+ ((ServerPlayer) player).connection.send(new ClientboundSetEntityLinkPacket(this, this.getLeashHolder()));
+ return InteractionResult.PASS;
+ }
+ // CraftBukkit end
+- this.dropLeash(true, !player.getAbilities().instabuild);
++ this.dropLeash(true, event.isDropLeash()); // Paper - drop leash variable
+ this.gameEvent(GameEvent.ENTITY_INTERACT, player);
+ return InteractionResult.sidedSuccess(this.level().isClientSide);
+ } else {
+@@ -1479,8 +1482,11 @@ public abstract class Mob extends LivingEntity implements Targeting {
+
+ if (this.leashHolder != null) {
+ if (!this.isAlive() || !this.leashHolder.isAlive()) {
+- this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), (!this.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit
+- this.dropLeash(true, true);
++ // Paper start - drop leash variable
++ EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), (!this.isAlive()) ? EntityUnleashEvent.UnleashReason.PLAYER_UNLEASH : EntityUnleashEvent.UnleashReason.HOLDER_GONE, true);
++ this.level().getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
++ this.dropLeash(true, event.isDropLeash());
++ // Paper end
+ }
+
+ }
+@@ -1543,8 +1549,11 @@ public abstract class Mob extends LivingEntity implements Targeting {
+ boolean flag1 = super.startRiding(entity, force);
+
+ if (flag1 && this.isLeashed()) {
+- this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
+- this.dropLeash(true, true);
++ // Paper start - drop leash variable
++ EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.UNKNOWN, true);
++ this.level().getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
++ this.dropLeash(true, event.isDropLeash());
++ // Paper end
+ }
+
+ return flag1;
+@@ -1733,8 +1742,11 @@ public abstract class Mob extends LivingEntity implements Targeting {
+ @Override
+ protected void removeAfterChangingDimensions() {
+ super.removeAfterChangingDimensions();
+- this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
+- this.dropLeash(true, false);
++ // Paper start - drop leash variable
++ EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.UNKNOWN, false);
++ this.level().getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
++ this.dropLeash(true, event.isDropLeash());
++ // Paper end
+ this.getAllSlots().forEach((itemstack) -> {
+ if (!itemstack.isEmpty()) {
+ itemstack.setCount(0);
+diff --git a/src/main/java/net/minecraft/world/entity/PathfinderMob.java b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
+index 452f219fde958fb4dc775cd2c56c0576c45a8045..8e362ad31208d87f4a69a1747485610e0588be51 100644
+--- a/src/main/java/net/minecraft/world/entity/PathfinderMob.java
++++ b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
+@@ -57,8 +57,11 @@ public abstract class PathfinderMob extends Mob {
+
+ if (this instanceof TamableAnimal && ((TamableAnimal) this).isInSittingPose()) {
+ if (f > entity.level().paperConfig().misc.maxLeashDistance) { // Paper
+- this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
+- this.dropLeash(true, true);
++ // Paper start - drop leash variable
++ EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE, true);
++ this.level().getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
++ this.dropLeash(true, event.isDropLeash());
++ // Paper end
+ }
+
+ return;
+@@ -66,8 +69,11 @@ public abstract class PathfinderMob extends Mob {
+
+ this.onLeashDistance(f);
+ if (f > entity.level().paperConfig().misc.maxLeashDistance) { // Paper
+- this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
+- this.dropLeash(true, true);
++ // Paper start - drop leash variable
++ EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE, true);
++ this.level().getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
++ this.dropLeash(true, event.isDropLeash());
++ // Paper end
+ this.goalSelector.disableControlFlag(Goal.Flag.MOVE);
+ } else if (f > 6.0F) {
+ double d0 = (entity.getX() - this.getX()) / (double) f;
+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 16784fcc853e23689a854e7dc6c03ed8182a164e..4eb97572a97a8d98af37c4223f42fc63659bc0ca 100644
+--- a/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java
++++ b/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java
+@@ -126,11 +126,14 @@ public class LeashFenceKnotEntity extends HangingEntity {
+
+ if (entityinsentient1.isLeashed() && entityinsentient1.getLeashHolder() == this) {
+ // CraftBukkit start
+- if (CraftEventFactory.callPlayerUnleashEntityEvent(entityinsentient1, player, hand).isCancelled()) {
++ // Paper start - drop leash variable
++ org.bukkit.event.player.PlayerUnleashEntityEvent event = CraftEventFactory.callPlayerUnleashEntityEvent(entityinsentient1, player, hand, !player.getAbilities().instabuild);
++ if (event.isCancelled()) {
++ // Paper end
+ die = false;
+ continue;
+ }
+- entityinsentient1.dropLeash(true, !player.getAbilities().instabuild); // false -> survival mode boolean
++ entityinsentient1.dropLeash(true, event.isDropLeash()); // false -> survival mode boolean // Paper - drop leash variable
+ // CraftBukkit end
+ flag1 = true;
+ }
+diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+index 46ab61bf75bf15bb6156dc9204e4071779e812e6..5bc937175a00c836a3a855780e2b8fd9a0005c07 100644
+--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
++++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+@@ -1634,8 +1634,10 @@ public class CraftEventFactory {
+ return itemInHand;
+ }
+
+- public static PlayerUnleashEntityEvent callPlayerUnleashEntityEvent(Mob entity, net.minecraft.world.entity.player.Player player, InteractionHand enumhand) {
+- PlayerUnleashEntityEvent event = new PlayerUnleashEntityEvent(entity.getBukkitEntity(), (Player) player.getBukkitEntity(), CraftEquipmentSlot.getHand(enumhand));
++ // Paper start - drop leash variable
++ public static PlayerUnleashEntityEvent callPlayerUnleashEntityEvent(Mob entity, net.minecraft.world.entity.player.Player player, InteractionHand enumhand, boolean dropLeash) {
++ PlayerUnleashEntityEvent event = new PlayerUnleashEntityEvent(entity.getBukkitEntity(), (Player) player.getBukkitEntity(), CraftEquipmentSlot.getHand(enumhand), dropLeash);
++ // Paper end
+ entity.level().getCraftServer().getPluginManager().callEvent(event);
+ return event;
+ }