mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 13:57:35 +01:00
Avoid duplicate death event call for armorstands (#9223)
* Avoid duplicate death event call for armorstands * restore vanilla behavior (emit the game event etc...)
This commit is contained in:
parent
609047b836
commit
94fbc95d13
@ -304,6 +304,19 @@ diff --git a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
|
|||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 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
|
||||||
|
@@ -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 {
|
@@ -0,0 +0,0 @@ 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;
|
||||||
@ -311,10 +324,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
- 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...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
@@ -0,0 +0,0 @@ public class ArmorStand extends LivingEntity {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -351,8 +378,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
@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);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user