diff options
author | EvilSeph <evilseph@unaligned.org> | 2011-06-18 22:37:52 -0400 |
---|---|---|
committer | EvilSeph <evilseph@unaligned.org> | 2011-06-18 22:37:52 -0400 |
commit | b292a9dfbc9725de05d81c0702ad5817394c5f36 (patch) | |
tree | 182ac0f2729250ddb52b15d237ee815d88ae863f /src/main | |
parent | 155874eec9cc307814dd658acba4e27a121ca9a5 (diff) | |
download | craftbukkit-b292a9dfbc9725de05d81c0702ad5817394c5f36.tar craftbukkit-b292a9dfbc9725de05d81c0702ad5817394c5f36.tar.gz craftbukkit-b292a9dfbc9725de05d81c0702ad5817394c5f36.tar.lz craftbukkit-b292a9dfbc9725de05d81c0702ad5817394c5f36.tar.xz craftbukkit-b292a9dfbc9725de05d81c0702ad5817394c5f36.zip |
Added more events for Wolves. Thanks Deaygo!
Added events for when wolf owner attacks an entity, or is attacked. Also added event for when a non-tame wolf targets a sheep.
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/net/minecraft/server/EntityHuman.java | 23 | ||||
-rw-r--r-- | src/main/java/net/minecraft/server/EntityWolf.java | 17 |
2 files changed, 37 insertions, 3 deletions
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java index 5b01faae..5feff7a7 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -10,7 +10,9 @@ import org.bukkit.craftbukkit.TrigMath; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityTargetEvent.TargetReason; import org.bukkit.event.player.PlayerBedEnterEvent; import org.bukkit.event.player.PlayerBedLeaveEvent; import org.bukkit.event.player.PlayerDropItemEvent; @@ -463,8 +465,25 @@ public abstract class EntityHuman extends EntityLiving { EntityWolf entitywolf1 = (EntityWolf) entity; if (entitywolf1.A() && entitywolf1.E() == null && this.name.equals(entitywolf1.x()) && (!flag || !entitywolf1.isSitting())) { - entitywolf1.setSitting(false); - entitywolf1.c(entityliving); + // CraftBukkit start + CraftServer server = this.world.getServer(); + org.bukkit.entity.Entity bukkitTarget = null; + if (entity != null) { + bukkitTarget = entityliving.getBukkitEntity(); + } + EntityTargetEvent event; + if (flag) { + event = new EntityTargetEvent(entitywolf1.getBukkitEntity(), bukkitTarget, TargetReason.OWNER_ATTACKED_TARGET); + } else { + event = new EntityTargetEvent(entitywolf1.getBukkitEntity(), bukkitTarget, TargetReason.TARGET_ATTACKED_OWNER); + } + server.getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + entitywolf1.setSitting(false); + entitywolf1.c(entityliving); + } + // CraftBukkit end } } } diff --git a/src/main/java/net/minecraft/server/EntityWolf.java b/src/main/java/net/minecraft/server/EntityWolf.java index cfc1228d..8ef074f0 100644 --- a/src/main/java/net/minecraft/server/EntityWolf.java +++ b/src/main/java/net/minecraft/server/EntityWolf.java @@ -109,7 +109,22 @@ public class EntityWolf extends EntityAnimal { List list = this.world.a(EntitySheep.class, AxisAlignedBB.b(this.locX, this.locY, this.locZ, this.locX + 1.0D, this.locY + 1.0D, this.locZ + 1.0D).b(16.0D, 4.0D, 16.0D)); if (!list.isEmpty()) { - this.c((Entity) list.get(this.world.random.nextInt(list.size()))); + // CraftBukkit start + Entity entity = (Entity) list.get(this.world.random.nextInt(list.size())); + + CraftServer server = this.world.getServer(); + org.bukkit.entity.Entity bukkitTarget = null; + if (entity != null) { + bukkitTarget = entity.getBukkitEntity(); + } + + EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, TargetReason.RANDOM_TARGET); + server.getPluginManager().callEvent(event); + + if (!event.isCancelled() || event.getTarget() != null ) { + this.c(entity); + } + // CraftBukkit end } } |