Paper/Spigot-Server-Patches/0415-MC-145656-Fix-Follow-Range-Initial-Target.patch
Aikar e4d10a6d67
Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
122289ff Add FaceAttachable interface to handle Grindstone facing in common with Switches
a6db750e SPIGOT-5647: ZombieVillager entity should have getVillagerType()

CraftBukkit Changes:
bbe3d58e SPIGOT-5650: Lectern.setPage(int) causes a NullPointerException
3075579f Add FaceAttachable interface to handle Grindstone facing in common with Switches
95bd4238 SPIGOT-5647: ZombieVillager entity should have getVillagerType()
4d975ac3 SPIGOT-5617: setBlockData does not work when NotPlayEvent is called by redstone current
2020-04-02 17:09:17 -04:00

68 lines
3.1 KiB
Diff

From 50c525844c440587c3d5db2156496ff5e735769c Mon Sep 17 00:00:00 2001
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
index 3bbf77a8ec..f8d8cb8655 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -633,4 +633,9 @@ 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/server/PathfinderGoalNearestAttackableTarget.java b/src/main/java/net/minecraft/server/PathfinderGoalNearestAttackableTarget.java
index cd17bf2be5..b85e67a85d 100644
--- 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
index c76a43837b..e35ec2db07 100644
--- 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
}
--
2.25.1