diff --git a/patches/server/Improve-death-events.patch b/patches/server/Improve-death-events.patch index d7af0791d2..7c6f119de4 100644 --- a/patches/server/Improve-death-events.patch +++ b/patches/server/Improve-death-events.patch @@ -304,6 +304,19 @@ diff --git a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java +@@ -0,0 +0,0 @@ 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()) { @@ -0,0 +0,0 @@ public class ArmorStand extends LivingEntity { this.gameEvent(GameEvent.ENTITY_DAMAGE, source.getEntity()); this.lastHit = i; @@ -311,10 +324,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - 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...) } + return true; +@@ -0,0 +0,0 @@ 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()); @@ -0,0 +0,0 @@ public class ArmorStand extends LivingEntity { } @@ -351,8 +378,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @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); }