2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/EntityWolf.java
|
|
|
|
+++ b/net/minecraft/server/EntityWolf.java
|
2018-12-25 22:00:00 +01:00
|
|
|
@@ -3,6 +3,11 @@
|
|
|
|
import java.util.UUID;
|
2016-05-10 13:47:39 +02:00
|
|
|
import javax.annotation.Nullable;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+// 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);
|
2018-12-25 22:00:00 +01:00
|
|
|
@@ -56,6 +61,22 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
this.getAttributeMap().b(GenericAttributes.ATTACK_DAMAGE).setValue(2.0D);
|
2015-02-26 23:41:06 +01:00
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+ // CraftBukkit - add overriden version
|
|
|
|
+ @Override
|
2016-04-20 12:40:16 +02:00
|
|
|
+ public boolean setGoalTarget(EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fire) {
|
|
|
|
+ if (!super.setGoalTarget(entityliving, reason, fire)) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ entityliving = getGoalTarget();
|
2014-11-25 22:32:16 +01:00
|
|
|
+ if (entityliving == null) {
|
|
|
|
+ this.setAngry(false);
|
|
|
|
+ } else if (!this.isTamed()) {
|
|
|
|
+ this.setAngry(true);
|
|
|
|
+ }
|
2016-04-20 12:40:16 +02:00
|
|
|
+ return true;
|
2015-02-26 23:41:06 +01:00
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2016-05-10 13:47:39 +02:00
|
|
|
public void setGoalTarget(@Nullable EntityLiving entityliving) {
|
2016-02-29 22:32:46 +01:00
|
|
|
super.setGoalTarget(entityliving);
|
|
|
|
if (entityliving == null) {
|
2018-12-25 22:00:00 +01:00
|
|
|
@@ -190,7 +211,8 @@
|
2014-12-09 15:40:38 +01:00
|
|
|
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)
|
|
|
|
+ // this.goalSit.setSitting(false);
|
|
|
|
}
|
2018-07-15 02:00:00 +02:00
|
|
|
|
2014-12-09 15:40:38 +01:00
|
|
|
if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) {
|
2018-12-25 22:00:00 +01:00
|
|
|
@@ -236,7 +258,7 @@
|
2016-11-17 02:41:03 +01:00
|
|
|
itemstack.subtract(1);
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- 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;
|
|
|
|
}
|
2018-07-15 02:00:00 +02:00
|
|
|
} else if (item instanceof ItemDye) {
|
2018-12-25 22:00:00 +01:00
|
|
|
@@ -257,7 +279,7 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
this.goalSit.setSitting(!this.isSitting());
|
2018-07-15 02:00:00 +02:00
|
|
|
this.bg = false;
|
2018-07-22 04:00:00 +02:00
|
|
|
this.navigation.q();
|
2014-11-25 22:32:16 +01:00
|
|
|
- this.setGoalTarget((EntityLiving) null);
|
|
|
|
+ this.setGoalTarget((EntityLiving) null, TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason
|
|
|
|
}
|
2018-07-15 02:00:00 +02:00
|
|
|
} else if (item == Items.BONE && !this.isAngry()) {
|
2014-11-25 22:32:16 +01:00
|
|
|
if (!entityhuman.abilities.canInstantlyBuild) {
|
2018-12-25 22:00:00 +01:00
|
|
|
@@ -265,12 +287,13 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2015-02-26 23:41:06 +01:00
|
|
|
if (!this.world.isClientSide) {
|
2014-11-25 22:32:16 +01:00
|
|
|
- if (this.random.nextInt(3) == 0) {
|
|
|
|
+ // CraftBukkit - added event call and isCancelled check.
|
|
|
|
+ if (this.random.nextInt(3) == 0 && !CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) {
|
2017-05-14 04:00:00 +02:00
|
|
|
this.c(entityhuman);
|
2018-07-22 04:00:00 +02:00
|
|
|
this.navigation.q();
|
2016-02-29 22:32:46 +01:00
|
|
|
this.setGoalTarget((EntityLiving) null);
|
|
|
|
this.goalSit.setSitting(true);
|
2017-05-14 04:00:00 +02:00
|
|
|
- this.setHealth(20.0F);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.setHealth(this.getMaxHealth()); // CraftBukkit - 20.0 -> getMaxHealth()
|
2018-07-15 02:00:00 +02:00
|
|
|
this.s(true);
|
2014-11-25 22:32:16 +01:00
|
|
|
this.world.broadcastEntityEffect(this, (byte) 7);
|
2017-05-14 04:00:00 +02:00
|
|
|
} else {
|