From 8e7e07352327667040137e027d3e88fa80276ac0 Mon Sep 17 00:00:00 2001 From: EvilSeph Date: Wed, 8 Feb 2012 10:55:15 -0500 Subject: [PATCH] Made Ender Dragons fire EntityRegainHealth events when getting healed by Ender Crystals. --- .../net/minecraft/server/EntityEnderDragon.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/minecraft/server/EntityEnderDragon.java b/src/main/java/net/minecraft/server/EntityEnderDragon.java index 77416b8e19..36e73f300c 100644 --- a/src/main/java/net/minecraft/server/EntityEnderDragon.java +++ b/src/main/java/net/minecraft/server/EntityEnderDragon.java @@ -9,8 +9,8 @@ import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.Location; import org.bukkit.event.entity.EntityCreatePortalEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent; import java.util.ArrayList; import org.bukkit.PortalType; @@ -346,7 +346,14 @@ public class EntityEnderDragon extends EntityComplex { this.s = null; } else if (this.ticksLived % 10 == 0 && this.health < this.t) { - ++this.health; + // CraftBukkit start + EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), 1, EntityRegainHealthEvent.RegainReason.ENDER_CRYSTAL); + this.world.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + this.health += event.getAmount(); + } + // CraftBukkit end } } @@ -589,7 +596,7 @@ public class EntityEnderDragon extends EntityComplex { BlockEnderPortal.a = true; byte b0 = 4; - + // CraftBukkit start - Replace any "this.world" in the following with just "world"! EntityCreatePortalEvent event = new EntityCreatePortalEvent(this.getBukkitEntity(), new ArrayList(), PortalType.ENDER); BlockStateListPopulator world = new BlockStateListPopulator(this.world.getWorld(), event.getBlocks());