2020-05-06 09:48:49 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2019-12-19 19:03:16 +00:00
|
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
|
|
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
|
2020-10-16 21:08:33 +00:00
|
|
|
index e654d215722e795027dbc504ef3c45ae94341bd3..b79cd5945504a13f64f91e617099dea6f6893966 100644
|
2019-12-19 19:03:16 +00:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2020-10-16 21:08:33 +00:00
|
|
|
@@ -568,4 +568,9 @@ public class PaperWorldConfig {
|
2019-12-19 19:03:16 +00:00
|
|
|
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/server/PathfinderGoalNearestAttackableTarget.java b/src/main/java/net/minecraft/server/PathfinderGoalNearestAttackableTarget.java
|
2020-06-25 23:38:24 +00:00
|
|
|
index 25a67f91e487d80d3996cc8b2544fece55059590..c0721c7fe479c8f753b8f48197a70dcd1ecfef5f 100644
|
2019-12-19 19:03:16 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/PathfinderGoalNearestAttackableTarget.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PathfinderGoalNearestAttackableTarget.java
|
|
|
|
@@ -25,6 +25,7 @@ public class PathfinderGoalNearestAttackableTarget<T extends EntityLiving> 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/server/PathfinderTargetCondition.java b/src/main/java/net/minecraft/server/PathfinderTargetCondition.java
|
2020-08-25 02:22:08 +00:00
|
|
|
index 174464273d1069ea07f12aaea116206366bad89f..253377c6238594de1f76cafcbf8223592e4d3f6b 100644
|
2019-12-19 19:03:16 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/PathfinderTargetCondition.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PathfinderTargetCondition.java
|
|
|
|
@@ -80,7 +80,7 @@ public class PathfinderTargetCondition {
|
|
|
|
|
|
|
|
if (this.b > 0.0D) {
|
|
|
|
double d0 = this.g ? entityliving1.A(entityliving) : 1.0D;
|
2020-08-25 02:22:08 +00:00
|
|
|
- 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());
|
2019-12-19 19:03:16 +00:00
|
|
|
|
|
|
|
if (d2 > d1 * d1) {
|
|
|
|
@@ -96,4 +96,18 @@ public class PathfinderTargetCondition {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Paper start
|
|
|
|
+ private boolean useFollowRange = false;
|
|
|
|
+
|
|
|
|
+ public PathfinderTargetCondition useFollowRange() {
|
|
|
|
+ this.useFollowRange = true;
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private double getFollowRange(EntityLiving entityliving) {
|
2020-06-26 12:04:38 +00:00
|
|
|
+ AttributeModifiable attributeinstance = entityliving.getAttributeInstance(GenericAttributes.FOLLOW_RANGE);
|
2019-12-19 19:03:16 +00:00
|
|
|
+ return attributeinstance == null ? 16.0D : attributeinstance.getValue();
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|