diff options
author | GJ <gjmcferrin@gmail.com> | 2014-02-05 11:56:37 -0500 |
---|---|---|
committer | Travis Watkins <amaranth@ubuntu.com> | 2014-04-18 10:43:06 -0500 |
commit | 890a4af12fce9c28dcc69aebf14078420293dc00 (patch) | |
tree | 05a1f7938e78c3040aac869a25678c07750c7b13 /src/main | |
parent | 3abba823151c87050fb7680c3a7194eb1fe5d64d (diff) | |
download | craftbukkit-890a4af12fce9c28dcc69aebf14078420293dc00.tar craftbukkit-890a4af12fce9c28dcc69aebf14078420293dc00.tar.gz craftbukkit-890a4af12fce9c28dcc69aebf14078420293dc00.tar.lz craftbukkit-890a4af12fce9c28dcc69aebf14078420293dc00.tar.xz craftbukkit-890a4af12fce9c28dcc69aebf14078420293dc00.zip |
[Bleeding] Call EntityTargetEvent in many new places.
Adds BUKKIT-5388, BUKKIT-5387, BUKKIT-5386, BUKKIT-5483, BUKKIT-5484.
Fixes BUKKIT-5389.
Diffstat (limited to 'src/main')
6 files changed, 48 insertions, 11 deletions
diff --git a/src/main/java/net/minecraft/server/EntityIronGolem.java b/src/main/java/net/minecraft/server/EntityIronGolem.java index afc7e0ee..dec42cdd 100644 --- a/src/main/java/net/minecraft/server/EntityIronGolem.java +++ b/src/main/java/net/minecraft/server/EntityIronGolem.java @@ -63,7 +63,12 @@ public class EntityIronGolem extends EntityGolem { protected void o(Entity entity) { if (entity instanceof IMonster && this.aH().nextInt(20) == 0) { - this.setGoalTarget((EntityLiving) entity); + // CraftBukkit start + org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(this, (EntityLiving) entity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.COLLISION); + if (!event.isCancelled()) { + this.setGoalTarget(((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle()); + } + // CraftBukkit end } super.o(entity); diff --git a/src/main/java/net/minecraft/server/EntityPigZombie.java b/src/main/java/net/minecraft/server/EntityPigZombie.java index 38d14422..ec268506 100644 --- a/src/main/java/net/minecraft/server/EntityPigZombie.java +++ b/src/main/java/net/minecraft/server/EntityPigZombie.java @@ -83,22 +83,20 @@ public class EntityPigZombie extends EntityZombie { if (entity1 instanceof EntityPigZombie) { EntityPigZombie entitypigzombie = (EntityPigZombie) entity1; - entitypigzombie.c(entity); + entitypigzombie.c(entity, EntityTargetEvent.TargetReason.PIG_ZOMBIE_TARGET); } } - this.c(entity); + this.c(entity, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY); } return super.damageEntity(damagesource, f); } } - private void c(Entity entity) { - // CraftBukkit start - org.bukkit.entity.Entity bukkitTarget = entity == null ? null : entity.getBukkitEntity(); - - EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, EntityTargetEvent.TargetReason.PIG_ZOMBIE_TARGET); + // CraftBukkit start + private void c(Entity entity, EntityTargetEvent.TargetReason reason) { // add TargetReason + EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), entity.getBukkitEntity(), reason); this.world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { diff --git a/src/main/java/net/minecraft/server/EntityWolf.java b/src/main/java/net/minecraft/server/EntityWolf.java index 9a4e0c4c..b992d084 100644 --- a/src/main/java/net/minecraft/server/EntityWolf.java +++ b/src/main/java/net/minecraft/server/EntityWolf.java @@ -1,5 +1,10 @@ package net.minecraft.server; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.entity.EntityTargetEvent.TargetReason; +// CraftBukkit end + public class EntityWolf extends EntityTameableAnimal { private float bq; @@ -236,6 +241,11 @@ public class EntityWolf extends EntityTameableAnimal { this.bc = false; this.setPathEntity((PathEntity) null); this.setTarget((Entity) null); + // CraftBukkit start + if (this.getGoalTarget() != null) { + CraftEventFactory.callEntityTargetEvent(this, null, TargetReason.FORGOT_TARGET); + } + // CraftBukkit end this.setGoalTarget((EntityLiving) null); } } else if (itemstack != null && itemstack.getItem() == Items.BONE && !this.isAngry()) { @@ -249,9 +259,14 @@ public class EntityWolf extends EntityTameableAnimal { if (!this.world.isStatic) { // CraftBukkit - added event call and isCancelled check. - if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { + if (this.random.nextInt(3) == 0 && !CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { this.setTamed(true); this.setPathEntity((PathEntity) null); + // CraftBukkit start + if (this.getGoalTarget() != null) { + CraftEventFactory.callEntityTargetEvent(this, null, TargetReason.FORGOT_TARGET); + } + // CraftBukkit end this.setGoalTarget((EntityLiving) null); this.bp.setSitting(true); this.setHealth(this.getMaxHealth()); // CraftBukkit - 20.0 -> getMaxHealth() diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java index 66c4c9c4..ecb4abe1 100644 --- a/src/main/java/net/minecraft/server/EntityZombie.java +++ b/src/main/java/net/minecraft/server/EntityZombie.java @@ -10,6 +10,7 @@ import org.bukkit.craftbukkit.entity.CraftLivingEntity; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.EntityCombustByEntityEvent; import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityTargetEvent; //CraftBukkit end public class EntityZombie extends EntityMonster { @@ -188,7 +189,13 @@ public class EntityZombie extends EntityMonster { entityzombie.setPosition((double) i1, (double) j1, (double) k1); if (this.world.b(entityzombie.boundingBox) && this.world.getCubes(entityzombie, entityzombie.boundingBox).isEmpty() && !this.world.containsLiquid(entityzombie.boundingBox)) { this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit - entityzombie.setGoalTarget(entityliving); + // CraftBukkit start - call EntityTargetEvent + org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(entityzombie, entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET); + entityliving = ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle(); + if (!event.isCancelled()) { + entityzombie.setGoalTarget(entityliving); + } + // CraftBukkit end entityzombie.a((GroupDataEntity) null); this.getAttributeInstance(bp).a(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0)); entityzombie.getAttributeInstance(bp).a(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0)); diff --git a/src/main/java/net/minecraft/server/PathfinderGoalHurtByTarget.java b/src/main/java/net/minecraft/server/PathfinderGoalHurtByTarget.java index 6686f059..2a0404ee 100644 --- a/src/main/java/net/minecraft/server/PathfinderGoalHurtByTarget.java +++ b/src/main/java/net/minecraft/server/PathfinderGoalHurtByTarget.java @@ -32,7 +32,13 @@ public class PathfinderGoalHurtByTarget extends PathfinderGoalTarget { EntityCreature entitycreature = (EntityCreature) iterator.next(); if (this.c != entitycreature && entitycreature.getGoalTarget() == null && !entitycreature.c(this.c.getLastDamager())) { - entitycreature.setGoalTarget(this.c.getLastDamager()); + // CraftBukkit start - call EntityTargetEvent + org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(entitycreature, this.c.getLastDamager(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY); + if (event.isCancelled()) { + continue; + } + entitycreature.setGoalTarget(event.getTarget() == null ? null : ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle()); + // CraftBukkit end } } } diff --git a/src/main/java/net/minecraft/server/PathfinderGoalOcelotAttack.java b/src/main/java/net/minecraft/server/PathfinderGoalOcelotAttack.java index 8baf68d3..0c08df38 100644 --- a/src/main/java/net/minecraft/server/PathfinderGoalOcelotAttack.java +++ b/src/main/java/net/minecraft/server/PathfinderGoalOcelotAttack.java @@ -1,5 +1,7 @@ package net.minecraft.server; +import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit + public class PathfinderGoalOcelotAttack extends PathfinderGoal { World a; @@ -29,6 +31,10 @@ public class PathfinderGoalOcelotAttack extends PathfinderGoal { } public void d() { + // CraftBukkit start + EntityTargetEvent.TargetReason reason = this.c.isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED; + org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetEvent(this.c, null, reason); + // CraftBukkit end this.c = null; this.b.getNavigation().h(); } |