From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: William Blake Galbreath Date: Wed, 18 Dec 2019 22:21:35 -0600 Subject: [PATCH] MC-145656 Fix Follow Range Initial Target diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { private void pillagerSettings() { disablePillagerPatrols = getBoolean("game-mechanics.disable-pillager-patrols", disablePillagerPatrols); } + + public boolean entitiesTargetWithFollowRange = false; + private void entitiesTargetWithFollowRange() { + entitiesTargetWithFollowRange = getBoolean("entities-target-with-follow-range", entitiesTargetWithFollowRange); + } } diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.java b/src/main/java/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.java +++ b/src/main/java/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.java @@ -0,0 +0,0 @@ public class PathfinderGoalNearestAttackableTarget exten this.b = i; this.a(EnumSet.of(PathfinderGoal.Type.TARGET)); this.d = (new PathfinderTargetCondition()).a(this.k()).a(predicate); + if (entityinsentient.world.paperConfig.entitiesTargetWithFollowRange) this.d.useFollowRange(); // Paper } @Override diff --git a/src/main/java/net/minecraft/world/entity/ai/targeting/PathfinderTargetCondition.java b/src/main/java/net/minecraft/world/entity/ai/targeting/PathfinderTargetCondition.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/ai/targeting/PathfinderTargetCondition.java +++ b/src/main/java/net/minecraft/world/entity/ai/targeting/PathfinderTargetCondition.java @@ -0,0 +0,0 @@ import java.util.function.Predicate; import javax.annotation.Nullable; import net.minecraft.world.entity.EntityInsentient; import net.minecraft.world.entity.EntityLiving; +import net.minecraft.world.entity.ai.attributes.AttributeModifiable; +import net.minecraft.world.entity.ai.attributes.GenericAttributes; public class PathfinderTargetCondition { @@ -0,0 +0,0 @@ public class PathfinderTargetCondition { if (this.b > 0.0D) { double d0 = this.g ? entityliving1.A(entityliving) : 1.0D; - double d1 = Math.max(this.b * d0, 2.0D); + double d1 = Math.max((useFollowRange ? getFollowRange(entityliving) : this.b) * d0, 2.0D); // Paper double d2 = entityliving.h(entityliving1.locX(), entityliving1.locY(), entityliving1.locZ()); if (d2 > d1 * d1) { @@ -0,0 +0,0 @@ public class PathfinderTargetCondition { return true; } } + + // Paper start + private boolean useFollowRange = false; + + public PathfinderTargetCondition useFollowRange() { + this.useFollowRange = true; + return this; + } + + private double getFollowRange(EntityLiving entityliving) { + AttributeModifiable attributeinstance = entityliving.getAttributeInstance(GenericAttributes.FOLLOW_RANGE); + return attributeinstance == null ? 16.0D : attributeinstance.getValue(); + } + // Paper end }