Paper/nms-patches/EntityWolf.patch

98 lines
4.3 KiB
Diff
Raw Normal View History

2015-02-26 23:41:06 +01:00
--- /home/matt/mc-dev-private//net/minecraft/server/EntityWolf.java 2015-02-26 22:40:22.735608138 +0000
+++ src/main/java/net/minecraft/server/EntityWolf.java 2015-02-26 22:40:22.735608138 +0000
@@ -2,6 +2,11 @@
import com.google.common.base.Predicate;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
+// CraftBukkit end
+
public class EntityWolf extends EntityTameableAnimal {
2015-02-26 23:41:06 +01:00
private float bo;
@@ -64,6 +69,18 @@
}
+ // 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
+
protected void E() {
this.datawatcher.watch(18, Float.valueOf(this.getHealth()));
2015-02-26 23:41:06 +01:00
}
@@ -95,7 +112,8 @@
}
protected String z() {
- return this.isAngry() ? "mob.wolf.growl" : (this.random.nextInt(3) == 0 ? (this.isTamed() && this.datawatcher.getFloat(18) < 10.0F ? "mob.wolf.whine" : "mob.wolf.panting") : "mob.wolf.bark");
+ // CraftBukkit - (getFloat(18) < 10) -> (getFloat(18) < this.getMaxHealth() / 2)
+ return this.isAngry() ? "mob.wolf.growl" : (this.random.nextInt(3) == 0 ? (this.isTamed() && this.datawatcher.getFloat(18) < this.getMaxHealth() / 2 ? "mob.wolf.whine" : "mob.wolf.panting") : "mob.wolf.bark");
}
2015-02-26 23:41:06 +01:00
protected String bo() {
@@ -186,7 +204,8 @@
} else {
Entity entity = damagesource.getEntity();
2015-02-26 23:41:06 +01:00
- this.bm.setSitting(false);
+ // CraftBukkit - moved into EntityLiving.d(DamageSource, float)
2015-02-26 23:41:06 +01:00
+ // this.bm.setSitting(false);
if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) {
f = (f + 1.0F) / 2.0F;
}
2015-02-26 23:41:06 +01:00
@@ -229,7 +248,7 @@
--itemstack.count;
}
- this.heal((float) itemfood.getNutrition(itemstack));
+ this.heal((float) itemfood.getNutrition(itemstack), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit
if (itemstack.count <= 0) {
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null);
}
2015-02-26 23:41:06 +01:00
@@ -254,7 +273,7 @@
this.bm.setSitting(!this.isSitting());
this.aY = false;
this.navigation.n();
- 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) {
2015-02-26 23:41:06 +01:00
@@ -266,12 +285,13 @@
}
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);
this.navigation.n();
- this.setGoalTarget((EntityLiving) null);
+ this.setGoalTarget((EntityLiving) null, TargetReason.FORGOT_TARGET, true);
2015-02-26 23:41:06 +01:00
this.bm.setSitting(true);
- this.setHealth(20.0F);
+ this.setHealth(this.getMaxHealth()); // CraftBukkit - 20.0 -> getMaxHealth()
this.setOwnerUUID(entityhuman.getUniqueID().toString());
this.l(true);
this.world.broadcastEntityEffect(this, (byte) 7);
2015-02-26 23:41:06 +01:00
@@ -358,7 +378,7 @@
}
protected boolean isTypeNotPersistent() {
- return !this.isTamed() && this.ticksLived > 2400;
+ return !this.isTamed() /*&& this.ticksLived > 2400*/; // CraftBukkit
}
public boolean a(EntityLiving entityliving, EntityLiving entityliving1) {