aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLulu13022002 <[email protected]>2023-06-27 06:22:49 +0200
committerGitHub <[email protected]>2023-06-26 21:22:49 -0700
commitcf0f013f53ef6c51528dca6d8873b61dc9546b1e (patch)
tree13ee64cb7e66844161fc6bb103ed8eb1d4918a20
parent7103f813bc58d335392fe822080a673e6d26293f (diff)
downloadPaper-cf0f013f53ef6c51528dca6d8873b61dc9546b1e.tar.gz
Paper-cf0f013f53ef6c51528dca6d8873b61dc9546b1e.zip
Avoid duplicate death event call for armorstands (#9223)
* Avoid duplicate death event call for armorstands * restore vanilla behavior (emit the game event etc...)
-rw-r--r--patches/server/0253-Improve-death-events.patch51
-rw-r--r--patches/server/0384-Fix-numerous-item-duplication-issues-and-teleport-is.patch6
2 files changed, 46 insertions, 11 deletions
diff --git a/patches/server/0253-Improve-death-events.patch b/patches/server/0253-Improve-death-events.patch
index 35e2933348..a2b22fc36f 100644
--- a/patches/server/0253-Improve-death-events.patch
+++ b/patches/server/0253-Improve-death-events.patch
@@ -301,21 +301,48 @@ index ebe207e2c4d8b7e125fec8a5182fe4882c9339e3..8ac82d3efc0f6d8ff40226e4f8084435
public void addAdditionalSaveData(CompoundTag nbt) {
super.addAdditionalSaveData(nbt);
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
-index 719f68f96e58ddcdd3592131c691d21263c81915..4413b609f1250cf9477fcb3fecd7b67afee0b896 100644
+index 719f68f96e58ddcdd3592131c691d21263c81915..a35a0952ce8e1fc42e92734786d531c7e10b34d7 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
-@@ -536,8 +536,9 @@ public class ArmorStand extends LivingEntity {
+@@ -491,8 +491,10 @@ public class ArmorStand extends LivingEntity {
+ }
+ // CraftBukkit end
+ if (source.is(DamageTypeTags.IS_EXPLOSION)) {
+- this.brokenByAnything(source);
+- this.kill();
++ // Paper start - avoid duplicate event call
++ org.bukkit.event.entity.EntityDeathEvent event = this.brokenByAnything(source);
++ if (!event.isCancelled()) this.kill(false);
++ // Paper end
+ return false;
+ } else if (source.is(DamageTypeTags.IGNITES_ARMOR_STANDS)) {
+ if (this.isOnFire()) {
+@@ -536,9 +538,9 @@ public class ArmorStand extends LivingEntity {
this.gameEvent(GameEvent.ENTITY_DAMAGE, source.getEntity());
this.lastHit = i;
} else {
- this.brokenByPlayer(source);
+ org.bukkit.event.entity.EntityDeathEvent event = this.brokenByPlayer(source); // Paper
this.showBreakingParticles();
-+ if (!event.isCancelled()) // Paper
- this.discard(); // CraftBukkit - SPIGOT-4890: remain as this.discard() since above damagesource method will call death event
+- this.discard(); // CraftBukkit - SPIGOT-4890: remain as this.discard() since above damagesource method will call death event
++ if (!event.isCancelled()) this.kill(false); // Paper - we still need to kill to follow vanilla logic (emit the game event etc...)
}
-@@ -599,7 +600,7 @@ public class ArmorStand extends LivingEntity {
+ return true;
+@@ -590,8 +592,10 @@ public class ArmorStand extends LivingEntity {
+
+ f1 -= amount;
+ if (f1 <= 0.5F) {
+- this.brokenByAnything(damageSource);
+- this.kill();
++ // Paper start - avoid duplicate event call
++ org.bukkit.event.entity.EntityDeathEvent event = this.brokenByAnything(damageSource);
++ if (!event.isCancelled()) this.kill(false);
++ // Paper end
+ } else {
+ this.setHealth(f1);
+ this.gameEvent(GameEvent.ENTITY_DAMAGE, damageSource.getEntity());
+@@ -599,7 +603,7 @@ public class ArmorStand extends LivingEntity {
}
@@ -324,7 +351,7 @@ index 719f68f96e58ddcdd3592131c691d21263c81915..4413b609f1250cf9477fcb3fecd7b67a
ItemStack itemstack = new ItemStack(Items.ARMOR_STAND);
if (this.hasCustomName()) {
-@@ -607,10 +608,10 @@ public class ArmorStand extends LivingEntity {
+@@ -607,10 +611,10 @@ public class ArmorStand extends LivingEntity {
}
drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops
@@ -337,7 +364,7 @@ index 719f68f96e58ddcdd3592131c691d21263c81915..4413b609f1250cf9477fcb3fecd7b67a
this.playBrokenSound();
// this.dropAllDeathLoot(damagesource); // CraftBukkit - moved down
-@@ -632,7 +633,7 @@ public class ArmorStand extends LivingEntity {
+@@ -632,7 +636,7 @@ public class ArmorStand extends LivingEntity {
this.armorItems.set(i, ItemStack.EMPTY);
}
}
@@ -346,13 +373,21 @@ index 719f68f96e58ddcdd3592131c691d21263c81915..4413b609f1250cf9477fcb3fecd7b67a
}
-@@ -764,7 +765,8 @@ public class ArmorStand extends LivingEntity {
+@@ -764,7 +768,16 @@ public class ArmorStand extends LivingEntity {
@Override
public void kill() {
- org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, drops); // CraftBukkit - call event
++ // Paper start
++ kill(true);
++ }
++
++ public void kill(boolean callEvent) {
++ if (callEvent) {
++ // Paper end
+ org.bukkit.event.entity.EntityDeathEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, drops); // CraftBukkit - call event // Paper - make cancellable
+ if (event.isCancelled()) return; // Paper - make cancellable
++ } // Paper
this.remove(Entity.RemovalReason.KILLED);
this.gameEvent(GameEvent.ENTITY_DIE);
}
diff --git a/patches/server/0384-Fix-numerous-item-duplication-issues-and-teleport-is.patch b/patches/server/0384-Fix-numerous-item-duplication-issues-and-teleport-is.patch
index bc698eb6fb..de1606e60e 100644
--- a/patches/server/0384-Fix-numerous-item-duplication-issues-and-teleport-is.patch
+++ b/patches/server/0384-Fix-numerous-item-duplication-issues-and-teleport-is.patch
@@ -113,10 +113,10 @@ index 02f5992f859163ea3fa77b3607bc9a0a29c17723..f8c2ff77f8db6f3e31eb2ef4d8638a73
this.drops = new ArrayList<>();
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
-index 4413b609f1250cf9477fcb3fecd7b67afee0b896..101e3a1f0f52b67b55c99c2619cc43298d92a3f2 100644
+index a35a0952ce8e1fc42e92734786d531c7e10b34d7..498c6664fcfb028111031691348bfa2eb21d605b 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
-@@ -621,7 +621,7 @@ public class ArmorStand extends LivingEntity {
+@@ -624,7 +624,7 @@ public class ArmorStand extends LivingEntity {
for (i = 0; i < this.handItems.size(); ++i) {
itemstack = (ItemStack) this.handItems.get(i);
if (!itemstack.isEmpty()) {
@@ -125,7 +125,7 @@ index 4413b609f1250cf9477fcb3fecd7b67afee0b896..101e3a1f0f52b67b55c99c2619cc4329
this.handItems.set(i, ItemStack.EMPTY);
}
}
-@@ -629,7 +629,7 @@ public class ArmorStand extends LivingEntity {
+@@ -632,7 +632,7 @@ public class ArmorStand extends LivingEntity {
for (i = 0; i < this.armorItems.size(); ++i) {
itemstack = (ItemStack) this.armorItems.get(i);
if (!itemstack.isEmpty()) {