diff options
author | GJ <gjmcferrin@gmail.com> | 2013-03-28 21:43:19 -0400 |
---|---|---|
committer | riking <rikingcoding@gmail.com> | 2013-04-15 20:03:22 -0700 |
commit | 0ab14dbaadaef02e6fbc01d6505fe56be2da58ea (patch) | |
tree | 21c74240a9cd1645e9983ac96e132d2c86c7df77 /src/main | |
parent | e62614a71e5fbe3f6765cd33bddb4c0ae187c10a (diff) | |
download | craftbukkit-0ab14dbaadaef02e6fbc01d6505fe56be2da58ea.tar craftbukkit-0ab14dbaadaef02e6fbc01d6505fe56be2da58ea.tar.gz craftbukkit-0ab14dbaadaef02e6fbc01d6505fe56be2da58ea.tar.lz craftbukkit-0ab14dbaadaef02e6fbc01d6505fe56be2da58ea.tar.xz craftbukkit-0ab14dbaadaef02e6fbc01d6505fe56be2da58ea.zip |
Make Slimes fire EntityTarget events. Fixes BUKKIT-1408
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/net/minecraft/server/EntitySlime.java | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/main/java/net/minecraft/server/EntitySlime.java b/src/main/java/net/minecraft/server/EntitySlime.java index 011c5ee8..5f12aaca 100644 --- a/src/main/java/net/minecraft/server/EntitySlime.java +++ b/src/main/java/net/minecraft/server/EntitySlime.java @@ -1,6 +1,11 @@ package net.minecraft.server; -import org.bukkit.event.entity.SlimeSplitEvent; // CraftBukkit +// CraftBukkit start +import org.bukkit.craftbukkit.entity.CraftEntity; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.entity.SlimeSplitEvent; +// CraftBukkit end public class EntitySlime extends EntityLiving implements IMonster { @@ -9,6 +14,7 @@ public class EntitySlime extends EntityLiving implements IMonster { public float c; public float d; private int jumpDelay = 0; + private Entity lastTarget; // CraftBukkit public EntitySlime(World world) { super(world); @@ -110,7 +116,22 @@ public class EntitySlime extends EntityLiving implements IMonster { protected void bq() { this.bn(); - EntityHuman entityhuman = this.world.findNearbyVulnerablePlayer(this, 16.0D); // CraftBukkit TODO: EntityTargetEvent + // CraftBukkit start + Entity entityhuman = this.world.findNearbyVulnerablePlayer(this, 16.0D); // EntityHuman -> Entity + EntityTargetEvent event = null; + + if (entityhuman != null && !entityhuman.equals(lastTarget)) { + event = CraftEventFactory.callEntityTargetEvent(this, entityhuman, EntityTargetEvent.TargetReason.CLOSEST_PLAYER); + } else if (lastTarget != null && entityhuman == null) { + event = CraftEventFactory.callEntityTargetEvent(this, entityhuman, EntityTargetEvent.TargetReason.FORGOT_TARGET); + } + + if (event != null && !event.isCancelled()) { + entityhuman = event.getTarget() == null ? null : ((CraftEntity) event.getTarget()).getHandle(); + } + + this.lastTarget = entityhuman; + // CraftBukkit end if (entityhuman != null) { this.a(entityhuman, 10.0F, 20.0F); |