2020-05-06 11:22:03 +02:00
|
|
|
From 294494a32012632470ca8fc99e7ff36a9c9f3027 Mon Sep 17 00:00:00 2001
|
2019-12-19 20:03:16 +01: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-05-06 10:35:20 +02:00
|
|
|
index 1c703e48e99..e89ad807ed9 100644
|
2019-12-19 20:03:16 +01:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2020-05-06 10:35:20 +02:00
|
|
|
@@ -621,4 +621,9 @@ public class PaperWorldConfig {
|
2019-12-19 20:03:16 +01: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-05-06 10:35:20 +02:00
|
|
|
index cd17bf2be53..b85e67a85d1 100644
|
2019-12-19 20:03:16 +01: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-05-06 10:35:20 +02:00
|
|
|
index c76a43837b4..e35ec2db078 100644
|
2019-12-19 20:03:16 +01: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;
|
|
|
|
- double d1 = this.b * d0;
|
|
|
|
+ double d1 = (useFollowRange ? getFollowRange(entityliving) : this.b) * d0; // Paper
|
|
|
|
double d2 = entityliving.g(entityliving1.locX(), entityliving1.locY(), entityliving1.locZ());
|
|
|
|
|
|
|
|
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) {
|
|
|
|
+ AttributeInstance attributeinstance = entityliving.getAttributeInstance(GenericAttributes.FOLLOW_RANGE);
|
|
|
|
+ return attributeinstance == null ? 16.0D : attributeinstance.getValue();
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
--
|
2020-05-02 00:03:47 +02:00
|
|
|
2.26.2
|
2019-12-19 20:03:16 +01:00
|
|
|
|