From c2a0396af25caf14a3e499e6fb3e0077b60149a4 Mon Sep 17 00:00:00 2001 From: t00thpick1 Date: Mon, 9 Dec 2013 23:03:57 -0500 Subject: [PATCH] Throw event when EnderCrystals harm EnderDragon. Fixes BUKKIT-4052 The EntityLiving dealDamage method will not call an event for the entity damage caused by an explosion without an associated entity cause, therefore, the explosion caused by EnderCrystals needs to be explicitely handled within the EnderDragon class. --- .../java/net/minecraft/server/EntityEnderDragon.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/EntityEnderDragon.java b/src/main/java/net/minecraft/server/EntityEnderDragon.java index 7067a64a8a..6cb09c43f0 100644 --- a/src/main/java/net/minecraft/server/EntityEnderDragon.java +++ b/src/main/java/net/minecraft/server/EntityEnderDragon.java @@ -7,6 +7,7 @@ import java.util.List; import org.bukkit.block.BlockState; import org.bukkit.craftbukkit.util.BlockStateListPopulator; import org.bukkit.event.entity.EntityCreatePortalEvent; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.Bukkit; @@ -300,7 +301,15 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo if (this.bC != null) { if (this.bC.dead) { if (!this.world.isStatic) { - this.a(this.bq, DamageSource.explosion((Explosion) null), 10.0F); + // CraftBukkit start + EntityDamageEvent event = new EntityDamageEvent(this.getBukkitEntity(), org.bukkit.event.entity.EntityDamageEvent.DamageCause.ENTITY_EXPLOSION, 10.0F); + Bukkit.getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + getBukkitEntity().setLastDamageCause(event); + this.a(this.bq, DamageSource.explosion((Explosion) null), (float) event.getDamage()); + } + // CraftBukkit end } this.bC = null;