2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/EntityWolf.java
|
|
|
|
+++ b/net/minecraft/server/EntityWolf.java
|
2019-04-23 04:00:00 +02:00
|
|
|
@@ -4,6 +4,11 @@
|
|
|
|
import java.util.function.Predicate;
|
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
|
|
|
|
+
|
2020-06-25 02:00:00 +02:00
|
|
|
public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable {
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
private static final DataWatcherObject<Boolean> by = DataWatcher.a(EntityWolf.class, DataWatcherRegistry.i);
|
|
|
|
@@ -43,7 +48,7 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
this.goalSelector.a(10, new PathfinderGoalRandomLookaround(this));
|
|
|
|
this.targetSelector.a(1, new PathfinderGoalOwnerHurtByTarget(this));
|
|
|
|
this.targetSelector.a(2, new PathfinderGoalOwnerHurtTarget(this));
|
|
|
|
- this.targetSelector.a(3, (new PathfinderGoalHurtByTarget(this, new Class[0])).a());
|
|
|
|
+ this.targetSelector.a(3, (new PathfinderGoalHurtByTarget(this, new Class[0])).a(new Class[0])); // CraftBukkit - decompile error
|
2020-06-25 02:00:00 +02:00
|
|
|
this.targetSelector.a(4, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, 10, true, false, this::b));
|
|
|
|
this.targetSelector.a(5, new PathfinderGoalRandomTargetNonTamed<>(this, EntityAnimal.class, false, EntityWolf.bx));
|
|
|
|
this.targetSelector.a(6, new PathfinderGoalRandomTargetNonTamed<>(this, EntityTurtle.class, false, EntityTurtle.bv));
|
|
|
|
@@ -55,6 +60,24 @@
|
|
|
|
return EntityInsentient.p().a(GenericAttributes.MOVEMENT_SPEED, 0.30000001192092896D).a(GenericAttributes.MAX_HEALTH, 8.0D).a(GenericAttributes.ATTACK_DAMAGE, 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();
|
2020-06-25 02:00:00 +02:00
|
|
|
+ /* // PAIL
|
2014-11-25 22:32:16 +01:00
|
|
|
+ if (entityliving == null) {
|
|
|
|
+ this.setAngry(false);
|
|
|
|
+ } else if (!this.isTamed()) {
|
|
|
|
+ this.setAngry(true);
|
|
|
|
+ }
|
2020-06-25 02:00:00 +02:00
|
|
|
+ */
|
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
|
|
|
+
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2020-06-25 02:00:00 +02:00
|
|
|
protected void initDatawatcher() {
|
|
|
|
super.initDatawatcher();
|
|
|
|
@@ -194,7 +217,7 @@
|
|
|
|
} else {
|
2014-12-09 15:40:38 +01:00
|
|
|
Entity entity = damagesource.getEntity();
|
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
- this.setWillSit(false);
|
|
|
|
+ // this.setWillSit(false); // CraftBukkit - moved into EntityLiving.damageEntity(DamageSource, float)
|
2014-12-09 15:40:38 +01:00
|
|
|
if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) {
|
2020-06-25 02:00:00 +02:00
|
|
|
f = (f + 1.0F) / 2.0F;
|
|
|
|
}
|
|
|
|
@@ -219,7 +242,7 @@
|
2019-12-10 23:00:00 +01:00
|
|
|
super.setTamed(flag);
|
|
|
|
if (flag) {
|
|
|
|
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(20.0D);
|
|
|
|
- this.setHealth(20.0F);
|
|
|
|
+ this.setHealth(this.getMaxHealth()); // CraftBukkit - 20.0 -> getMaxHealth()
|
|
|
|
} else {
|
|
|
|
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(8.0D);
|
|
|
|
}
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -243,7 +266,7 @@
|
2019-12-10 23:00:00 +01:00
|
|
|
itemstack.subtract(1);
|
2016-02-29 22:32:46 +01:00
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2019-12-10 23:00:00 +01:00
|
|
|
- this.heal((float) item.getFoodInfo().getNutrition());
|
|
|
|
+ this.heal((float) item.getFoodInfo().getNutrition(), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit
|
2020-06-25 02:00:00 +02:00
|
|
|
return EnumInteractionResult.SUCCESS;
|
2019-12-10 23:00:00 +01:00
|
|
|
}
|
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -254,7 +277,7 @@
|
|
|
|
this.setWillSit(!this.isWillSit());
|
|
|
|
this.jumping = false;
|
|
|
|
this.navigation.o();
|
|
|
|
- this.setGoalTarget((EntityLiving) null);
|
|
|
|
+ this.setGoalTarget((EntityLiving) null, TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason
|
|
|
|
return EnumInteractionResult.SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -276,7 +299,8 @@
|
2019-12-10 23:00:00 +01:00
|
|
|
itemstack.subtract(1);
|
|
|
|
}
|
|
|
|
|
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()) {
|
2019-04-23 04:00:00 +02:00
|
|
|
this.tame(entityhuman);
|
|
|
|
this.navigation.o();
|
2016-02-29 22:32:46 +01:00
|
|
|
this.setGoalTarget((EntityLiving) null);
|