2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 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/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java
|
2024-01-21 12:53:04 +01:00
|
|
|
index 0dad5be671f990d0edf0a155e2534b3812438902..175ba1184fc997f562f0834b172e17dc1b5b3027 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java
|
2021-11-24 23:26:32 +01:00
|
|
|
@@ -38,6 +38,7 @@ public class NearestAttackableTargetGoal<T extends LivingEntity> extends TargetG
|
2021-11-24 06:44:21 +01:00
|
|
|
this.randomInterval = reducedTickDelay(reciprocalChance);
|
2021-06-11 14:02:28 +02:00
|
|
|
this.setFlags(EnumSet.of(Goal.Flag.TARGET));
|
2021-06-13 21:29:58 +02:00
|
|
|
this.targetConditions = TargetingConditions.forCombat().range(this.getFollowDistance()).selector(targetPredicate);
|
2024-01-21 12:53:04 +01:00
|
|
|
+ if (mob.level().paperConfig().entities.entitiesTargetWithFollowRange) this.targetConditions.useFollowRange(); // Paper - Fix MC-145656
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
|
2024-01-21 12:53:04 +01:00
|
|
|
index f29823f2e8a54bd4e81e2940b5c505b152f23e88..fae0dbfb6ac09a0c152c0f74a72583f44316def7 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
|
2021-11-24 06:44:21 +01:00
|
|
|
@@ -76,7 +76,7 @@ public class TargetingConditions {
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
if (this.range > 0.0D) {
|
2021-06-13 21:29:58 +02:00
|
|
|
double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0D;
|
|
|
|
- double e = Math.max(this.range * d, 2.0D);
|
2024-01-21 12:53:04 +01:00
|
|
|
+ double e = Math.max((this.useFollowRange ? this.getFollowRange(baseEntity) : this.range) * d, 2.0D); // Paper - Fix MC-145656
|
2021-06-13 21:29:58 +02:00
|
|
|
double f = baseEntity.distanceToSqr(targetEntity.getX(), targetEntity.getY(), targetEntity.getZ());
|
|
|
|
if (f > e * e) {
|
|
|
|
return false;
|
2021-11-24 06:44:21 +01:00
|
|
|
@@ -94,4 +94,18 @@ public class TargetingConditions {
|
2021-06-11 14:02:28 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+
|
2024-01-21 12:53:04 +01:00
|
|
|
+ // Paper start - Fix MC-145656
|
2021-06-11 14:02:28 +02:00
|
|
|
+ private boolean useFollowRange = false;
|
|
|
|
+
|
|
|
|
+ public TargetingConditions useFollowRange() {
|
|
|
|
+ this.useFollowRange = true;
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private double getFollowRange(LivingEntity entityliving) {
|
2021-06-13 21:29:58 +02:00
|
|
|
+ net.minecraft.world.entity.ai.attributes.AttributeInstance attributeinstance = entityliving.getAttribute(net.minecraft.world.entity.ai.attributes.Attributes.FOLLOW_RANGE);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ return attributeinstance == null ? 16.0D : attributeinstance.getValue();
|
|
|
|
+ }
|
2024-01-21 12:53:04 +01:00
|
|
|
+ // Paper end - Fix MC-145656
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|