2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/entity/animal/EntityWolf.java
|
|
|
|
+++ b/net/minecraft/world/entity/animal/EntityWolf.java
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -88,6 +88,12 @@
|
|
|
|
import net.minecraft.world.level.pathfinder.PathType;
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.phys.Vec3D;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
2023-06-24 09:15:05 +02:00
|
|
|
+import org.bukkit.event.entity.EntityRegainHealthEvent;
|
|
|
|
+import org.bukkit.event.entity.EntityTargetEvent;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
2024-04-23 17:15:00 +02:00
|
|
|
public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable, VariantHolder<Holder<WolfVariant>> {
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
private static final DataWatcherObject<Boolean> DATA_INTERESTED_ID = DataWatcher.defineId(EntityWolf.class, DataWatcherRegistry.BOOLEAN);
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -350,18 +356,21 @@
|
|
|
|
if (this.isInvulnerableTo(damagesource)) {
|
|
|
|
return false;
|
2023-06-24 09:15:05 +02:00
|
|
|
} else {
|
|
|
|
- if (!this.level().isClientSide) {
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ boolean result = super.hurt(damagesource, f);
|
|
|
|
+ if (!this.level().isClientSide && result) {
|
2024-04-23 17:15:00 +02:00
|
|
|
+ // CraftBukkit end
|
|
|
|
this.setOrderedToSit(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
- return super.hurt(damagesource, f);
|
|
|
|
+ return result; // CraftBukkit
|
2023-06-24 09:15:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-23 17:15:00 +02:00
|
|
|
@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();
|
|
|
|
@@ -380,6 +389,7 @@
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
+ return false; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean canArmorAbsorb(DamageSource damagesource) {
|
|
|
|
@@ -401,7 +411,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()
|
2019-12-10 23:00:00 +01:00
|
|
|
} else {
|
2021-11-21 23:00:00 +01:00
|
|
|
this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(8.0D);
|
2019-12-10 23:00:00 +01:00
|
|
|
}
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -428,7 +438,7 @@
|
|
|
|
FoodInfo foodinfo = (FoodInfo) itemstack.get(DataComponents.FOOD);
|
|
|
|
float f = foodinfo != null ? (float) foodinfo.nutrition() : 1.0F;
|
2019-12-10 23:00:00 +01:00
|
|
|
|
2024-04-23 17:15:00 +02:00
|
|
|
- this.heal(2.0F * f);
|
|
|
|
+ this.heal(2.0F * f, EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit
|
|
|
|
return EnumInteractionResult.sidedSuccess(this.level().isClientSide());
|
2023-06-07 17:30:00 +02:00
|
|
|
} else {
|
|
|
|
if (item instanceof ItemDye) {
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -476,7 +486,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;
|
|
|
|
@@ -494,7 +504,8 @@
|
|
|
|
}
|
2023-06-07 17:30:00 +02:00
|
|
|
|
2024-04-23 17:15:00 +02:00
|
|
|
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);
|