PaperMC/nms-patches/EntityWolf.patch

90 lines
3.7 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntityWolf.java
+++ b/net/minecraft/server/EntityWolf.java
2016-02-29 22:32:46 +01:00
@@ -3,6 +3,11 @@
2015-02-26 23:41:06 +01:00
import com.google.common.base.Predicate;
2016-02-29 22:32:46 +01:00
import java.util.UUID;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
+// CraftBukkit end
+
public class EntityWolf extends EntityTameableAnimal {
2016-02-29 22:32:46 +01:00
private static final DataWatcherObject<Float> DATA_HEALTH = DataWatcher.a(EntityWolf.class, DataWatcherRegistry.c);
@@ -59,6 +64,18 @@
this.getAttributeMap().b(GenericAttributes.ATTACK_DAMAGE).setValue(2.0D);
2015-02-26 23:41:06 +01:00
}
+ // CraftBukkit - add overriden version
+ @Override
+ public void setGoalTarget(EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fire) {
+ super.setGoalTarget(entityliving, reason, fire);
+ if (entityliving == null) {
+ this.setAngry(false);
+ } else if (!this.isTamed()) {
+ this.setAngry(true);
+ }
2015-02-26 23:41:06 +01:00
+ }
+ // CraftBukkit end
2015-02-26 23:41:06 +01:00
+
2016-02-29 22:32:46 +01:00
public void setGoalTarget(EntityLiving entityliving) {
super.setGoalTarget(entityliving);
if (entityliving == null) {
@@ -192,9 +209,10 @@
Entity entity = damagesource.getEntity();
2016-02-29 22:32:46 +01:00
if (this.goalSit != null) {
- this.goalSit.setSitting(false);
+ // CraftBukkit - moved into EntityLiving.d(DamageSource, float)
+ // PAIL : checkme
+ // this.goalSit.setSitting(false);
}
-
if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) {
f = (f + 1.0F) / 2.0F;
}
2016-02-29 22:32:46 +01:00
@@ -235,7 +253,7 @@
--itemstack.count;
}
- this.heal((float) itemfood.getNutrition(itemstack));
+ this.heal((float) itemfood.getNutrition(itemstack), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit
2016-02-29 22:32:46 +01:00
return true;
}
} else if (itemstack.getItem() == Items.DYE) {
@@ -256,7 +274,7 @@
this.goalSit.setSitting(!this.isSitting());
this.bc = false;
this.navigation.o();
- this.setGoalTarget((EntityLiving) null);
+ this.setGoalTarget((EntityLiving) null, TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason
}
} else if (itemstack != null && itemstack.getItem() == Items.BONE && !this.isAngry()) {
if (!entityhuman.abilities.canInstantlyBuild) {
2016-02-29 22:32:46 +01:00
@@ -264,12 +282,14 @@
}
2015-02-26 23:41:06 +01:00
if (!this.world.isClientSide) {
- 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.setTamed(true);
2016-02-29 22:32:46 +01:00
this.navigation.o();
this.setGoalTarget((EntityLiving) null);
this.goalSit.setSitting(true);
this.setHealth(20.0F);
+ this.setHealth(this.getMaxHealth()); // CraftBukkit - 20.0 -> getMaxHealth()
2016-02-29 22:32:46 +01:00
this.setOwnerUUID(entityhuman.getUniqueID());
this.o(true);
this.world.broadcastEntityEffect(this, (byte) 7);
2016-02-29 22:32:46 +01:00
@@ -351,7 +371,7 @@
}
protected boolean isTypeNotPersistent() {
- return !this.isTamed() && this.ticksLived > 2400;
+ return !this.isTamed() /*&& this.ticksLived > 2400*/; // CraftBukkit
}
public boolean a(EntityLiving entityliving, EntityLiving entityliving1) {