mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 03:43:40 +01:00
Handle null targets in target event. Fixes BUKKIT-5635
This commit is contained in:
parent
3fbf4d3b5f
commit
38fbe60d46
2 changed files with 10 additions and 3 deletions
|
@ -64,7 +64,11 @@ public class EntityIronGolem extends EntityGolem {
|
|||
// 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());
|
||||
if (event.getTarget() == null) {
|
||||
this.setGoalTarget(null);
|
||||
} else {
|
||||
this.setGoalTarget(((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle());
|
||||
}
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
|
|
@ -191,9 +191,12 @@ public class EntityZombie extends EntityMonster {
|
|||
this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit
|
||||
// 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);
|
||||
if (event.getTarget() == null) {
|
||||
entityzombie.setGoalTarget(null);
|
||||
} else {
|
||||
entityzombie.setGoalTarget(((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle());
|
||||
}
|
||||
}
|
||||
// CraftBukkit end
|
||||
entityzombie.a((GroupDataEntity) null);
|
||||
|
|
Loading…
Reference in a new issue