--- a/net/minecraft/world/entity/animal/EntityWolf.java +++ b/net/minecraft/world/entity/animal/EntityWolf.java @@ -68,6 +68,11 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.Vec3D; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.entity.EntityTargetEvent.TargetReason; +// CraftBukkit end + public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable { private static final DataWatcherObject DATA_INTERESTED_ID = DataWatcher.defineId(EntityWolf.class, DataWatcherRegistry.BOOLEAN); @@ -122,6 +127,24 @@ return EntityInsentient.createMobAttributes().add(GenericAttributes.MOVEMENT_SPEED, 0.30000001192092896D).add(GenericAttributes.MAX_HEALTH, 8.0D).add(GenericAttributes.ATTACK_DAMAGE, 2.0D); } + // CraftBukkit - add overriden version + @Override + public boolean setTarget(EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fire) { + if (!super.setTarget(entityliving, reason, fire)) { + return false; + } + entityliving = getTarget(); + /* // PAIL + if (entityliving == null) { + this.setAngry(false); + } else if (!this.isTamed()) { + this.setAngry(true); + } + */ + return true; + } + // CraftBukkit end + @Override protected void defineSynchedData() { super.defineSynchedData(); @@ -293,7 +316,7 @@ } else { Entity entity = damagesource.getEntity(); - this.setOrderedToSit(false); + // this.setWillSit(false); // CraftBukkit - moved into EntityLiving.damageEntity(DamageSource, float) if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) { f = (f + 1.0F) / 2.0F; } @@ -318,7 +341,7 @@ super.setTame(flag); if (flag) { this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(20.0D); - this.setHealth(20.0F); + this.setHealth(this.getMaxHealth()); // CraftBukkit - 20.0 -> getMaxHealth() } else { this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(8.0D); } @@ -342,7 +365,7 @@ itemstack.shrink(1); } - this.heal((float) item.getFoodProperties().getNutrition()); + this.heal((float) item.getFoodProperties().getNutrition(), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit this.gameEvent(GameEvent.MOB_INTERACT, this.eyeBlockPosition()); return EnumInteractionResult.SUCCESS; } @@ -354,7 +377,7 @@ this.setOrderedToSit(!this.isOrderedToSit()); this.jumping = false; this.navigation.stop(); - this.setTarget((EntityLiving) null); + this.setTarget((EntityLiving) null, TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason return EnumInteractionResult.SUCCESS; } @@ -376,7 +399,8 @@ itemstack.shrink(1); } - if (this.random.nextInt(3) == 0) { + // CraftBukkit - added event call and isCancelled check. + if (this.random.nextInt(3) == 0 && !CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { this.tame(entityhuman); this.navigation.stop(); this.setTarget((EntityLiving) null);