Archiviert
13
0

Avoid duplicate death event call for armorstands (#9223)

* Avoid duplicate death event call for armorstands

* restore vanilla behavior (emit the game event etc...)
Dieser Commit ist enthalten in:
Lulu13022002 2023-06-27 06:22:49 +02:00 committet von GitHub
Ursprung 7103f813bc
Commit cf0f013f53
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
2 geänderte Dateien mit 46 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -301,21 +301,48 @@ index ebe207e2c4d8b7e125fec8a5182fe4882c9339e3..8ac82d3efc0f6d8ff40226e4f8084435
public void addAdditionalSaveData(CompoundTag nbt) { public void addAdditionalSaveData(CompoundTag nbt) {
super.addAdditionalSaveData(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 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 --- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
+++ b/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.gameEvent(GameEvent.ENTITY_DAMAGE, source.getEntity());
this.lastHit = i; this.lastHit = i;
} else { } else {
- this.brokenByPlayer(source); - this.brokenByPlayer(source);
+ org.bukkit.event.entity.EntityDeathEvent event = this.brokenByPlayer(source); // Paper + org.bukkit.event.entity.EntityDeathEvent event = this.brokenByPlayer(source); // Paper
this.showBreakingParticles(); 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); ItemStack itemstack = new ItemStack(Items.ARMOR_STAND);
if (this.hasCustomName()) { 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 drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops
@ -337,7 +364,7 @@ index 719f68f96e58ddcdd3592131c691d21263c81915..4413b609f1250cf9477fcb3fecd7b67a
this.playBrokenSound(); this.playBrokenSound();
// this.dropAllDeathLoot(damagesource); // CraftBukkit - moved down // 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); 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 @Override
public void kill() { public void kill() {
- org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, drops); // CraftBukkit - call event - 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 + 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 + if (event.isCancelled()) return; // Paper - make cancellable
+ } // Paper
this.remove(Entity.RemovalReason.KILLED); this.remove(Entity.RemovalReason.KILLED);
this.gameEvent(GameEvent.ENTITY_DIE); this.gameEvent(GameEvent.ENTITY_DIE);
} }

Datei anzeigen

@ -113,10 +113,10 @@ index 02f5992f859163ea3fa77b3607bc9a0a29c17723..f8c2ff77f8db6f3e31eb2ef4d8638a73
this.drops = new ArrayList<>(); this.drops = new ArrayList<>();
// CraftBukkit end // 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 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 --- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
+++ b/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) { for (i = 0; i < this.handItems.size(); ++i) {
itemstack = (ItemStack) this.handItems.get(i); itemstack = (ItemStack) this.handItems.get(i);
if (!itemstack.isEmpty()) { if (!itemstack.isEmpty()) {
@ -125,7 +125,7 @@ index 4413b609f1250cf9477fcb3fecd7b67afee0b896..101e3a1f0f52b67b55c99c2619cc4329
this.handItems.set(i, ItemStack.EMPTY); 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) { for (i = 0; i < this.armorItems.size(); ++i) {
itemstack = (ItemStack) this.armorItems.get(i); itemstack = (ItemStack) this.armorItems.get(i);
if (!itemstack.isEmpty()) { if (!itemstack.isEmpty()) {