--- a/net/minecraft/world/entity/animal/EntityWolf.java +++ b/net/minecraft/world/entity/animal/EntityWolf.java @@ -90,6 +90,12 @@ import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.phys.Vec3D; +// CraftBukkit start +import org.bukkit.event.entity.EntityRegainHealthEvent; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.craftbukkit.event.CraftEventFactory; +// CraftBukkit end + public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable, VariantHolder> { private static final DataWatcherObject DATA_INTERESTED_ID = DataWatcher.defineId(EntityWolf.class, DataWatcherRegistry.BOOLEAN); @@ -360,11 +366,14 @@ if (this.isInvulnerableTo(damagesource)) { return false; } else { - if (!this.level().isClientSide) { + // CraftBukkit start + boolean result = super.hurt(damagesource, f); + if (!this.level().isClientSide && result) { + // CraftBukkit end this.setOrderedToSit(false); } - return super.hurt(damagesource, f); + return result; // CraftBukkit } } @@ -374,9 +383,9 @@ } @Override - protected void actuallyHurt(DamageSource damagesource, float f) { + public boolean actuallyHurt(DamageSource damagesource, float f) { // CraftBukkit - void -> boolean if (!this.canArmorAbsorb(damagesource)) { - super.actuallyHurt(damagesource, f); + return super.actuallyHurt(damagesource, f); // CraftBukkit } else { ItemStack itemstack = this.getBodyArmorItem(); int i = itemstack.getDamageValue(); @@ -395,6 +404,7 @@ } } + return false; // CraftBukkit } private boolean canArmorAbsorb(DamageSource damagesource) { @@ -405,7 +415,7 @@ protected void applyTamingSideEffects() { if (this.isTame()) { this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(40.0D); - this.setHealth(40.0F); + this.setHealth(this.getMaxHealth()); // CraftBukkit - 40.0 -> getMaxHealth() } else { this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(8.0D); } @@ -432,7 +442,7 @@ FoodInfo foodinfo = (FoodInfo) itemstack.get(DataComponents.FOOD); float f = foodinfo != null ? (float) foodinfo.nutrition() : 1.0F; - this.heal(2.0F * f); + this.heal(2.0F * f, EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit return EnumInteractionResult.sidedSuccess(this.level().isClientSide()); } else { if (item instanceof ItemDye) { @@ -480,7 +490,7 @@ this.setOrderedToSit(!this.isOrderedToSit()); this.jumping = false; this.navigation.stop(); - this.setTarget((EntityLiving) null); + this.setTarget((EntityLiving) null, EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason return EnumInteractionResult.SUCCESS_NO_ITEM_USED; } else { return enuminteractionresult; @@ -498,7 +508,8 @@ } private void tryToTame(EntityHuman entityhuman) { - 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);