2021-06-11 12:02:28 +00: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/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2022-06-06 00:17:27 +00:00
|
|
|
index 68448d9ae6650beabcc62128772c6a18754788c4..297adb65c486abccd42cdb3b042e651a767c69cf 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2022-06-06 00:17:27 +00:00
|
|
|
@@ -488,5 +488,10 @@ public class PaperWorldConfig {
|
2021-12-01 01:31:13 +00:00
|
|
|
private void generatorSettings() {
|
|
|
|
generateFlatBedrock = getBoolean("generator-settings.flat-bedrock", this.generateFlatBedrock);
|
2021-06-11 12:02:28 +00:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ public boolean entitiesTargetWithFollowRange = false;
|
|
|
|
+ private void entitiesTargetWithFollowRange() {
|
|
|
|
+ entitiesTargetWithFollowRange = getBoolean("entities-target-with-follow-range", entitiesTargetWithFollowRange);
|
|
|
|
+ }
|
|
|
|
}
|
2021-06-13 19:29:58 +00:00
|
|
|
|
2021-06-11 12:02:28 +00:00
|
|
|
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
|
2021-11-24 22:26:32 +00:00
|
|
|
index 638942d54c6ea2d305350a330ac9fb8b82294f53..c6fc08d13b4cf3141ff31bed99294bdbace1c5e2 100644
|
2021-06-11 12:02:28 +00: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 22:26:32 +00:00
|
|
|
@@ -38,6 +38,7 @@ public class NearestAttackableTargetGoal<T extends LivingEntity> extends TargetG
|
2021-11-24 05:44:21 +00:00
|
|
|
this.randomInterval = reducedTickDelay(reciprocalChance);
|
2021-06-11 12:02:28 +00:00
|
|
|
this.setFlags(EnumSet.of(Goal.Flag.TARGET));
|
2021-06-13 19:29:58 +00:00
|
|
|
this.targetConditions = TargetingConditions.forCombat().range(this.getFollowDistance()).selector(targetPredicate);
|
2021-06-11 12:02:28 +00:00
|
|
|
+ if (mob.level.paperConfig.entitiesTargetWithFollowRange) this.targetConditions.useFollowRange(); // Paper
|
|
|
|
}
|
|
|
|
|
|
|
|
@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
|
2021-11-24 05:44:21 +00:00
|
|
|
index 9f65f6cdbcc054bde03c42d7d3b16f65b93e5deb..a7575b5ef56af6f53448d391abb4956e130148ca 100644
|
2021-06-11 12:02:28 +00: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 05:44:21 +00:00
|
|
|
@@ -76,7 +76,7 @@ public class TargetingConditions {
|
2021-06-11 12:02:28 +00:00
|
|
|
|
|
|
|
if (this.range > 0.0D) {
|
2021-06-13 19:29:58 +00:00
|
|
|
double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0D;
|
|
|
|
- double e = Math.max(this.range * d, 2.0D);
|
|
|
|
+ double e = Math.max((this.useFollowRange ? this.getFollowRange(baseEntity) : this.range) * d, 2.0D); // Paper
|
|
|
|
double f = baseEntity.distanceToSqr(targetEntity.getX(), targetEntity.getY(), targetEntity.getZ());
|
|
|
|
if (f > e * e) {
|
|
|
|
return false;
|
2021-11-24 05:44:21 +00:00
|
|
|
@@ -94,4 +94,18 @@ public class TargetingConditions {
|
2021-06-11 12:02:28 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Paper start
|
|
|
|
+ private boolean useFollowRange = false;
|
|
|
|
+
|
|
|
|
+ public TargetingConditions useFollowRange() {
|
|
|
|
+ this.useFollowRange = true;
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private double getFollowRange(LivingEntity entityliving) {
|
2021-06-13 19:29:58 +00:00
|
|
|
+ net.minecraft.world.entity.ai.attributes.AttributeInstance attributeinstance = entityliving.getAttribute(net.minecraft.world.entity.ai.attributes.Attributes.FOLLOW_RANGE);
|
2021-06-11 12:02:28 +00:00
|
|
|
+ return attributeinstance == null ? 16.0D : attributeinstance.getValue();
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|