13
0
geforkt von Mirrors/Paper

[Bleeding] Call EntityTargetEvent in many new places.

Adds BUKKIT-5388, BUKKIT-5387, BUKKIT-5386, BUKKIT-5483, BUKKIT-5484.
Fixes BUKKIT-5389.
Dieser Commit ist enthalten in:
GJ 2014-02-05 11:56:37 -05:00 committet von Travis Watkins
Ursprung 3abba82315
Commit 890a4af12f
6 geänderte Dateien mit 48 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -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);

Datei anzeigen

@ -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()) {

Datei anzeigen

@ -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()

Datei anzeigen

@ -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));

Datei anzeigen

@ -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
}
}
}

Datei anzeigen

@ -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();
}