mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-26 10:29:13 +00:00
cancel async target finding when entity removal
This commit is contained in:
@@ -177,6 +177,23 @@ index a9f33e705b3c0abfa3dcc01647a57c06bb614e1c..02c2b9c1978959e1ee0be5c72a5f7b98
|
||||
}
|
||||
|
||||
// Leaf start - SparklyPaper - parallel world ticking - Shutdown handling for async reads
|
||||
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
||||
index 1d78cacbf2c63f35fdf0552d50834385ab51aaf0..aadba595ca9ad6ba403b16b3c741421005f0414a 100644
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -750,6 +750,12 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
||||
|
||||
super.remove(reason, eventCause); // CraftBukkit
|
||||
this.brain.clearMemories();
|
||||
+ // Leaf start - Async target finding
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncTargetFinding.enabled && this instanceof Mob mob) {
|
||||
+ mob.targetSelector.ctx.cancel();
|
||||
+ mob.goalSelector.ctx.cancel();
|
||||
+ }
|
||||
+ // Leaf end - Async target finding
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java
|
||||
index 173ec6919cef2aa90c40d3bf33d927a2db7b4922..e99fd3cd5ca6863facd189bf9cd4a3d5c102424a 100644
|
||||
--- a/net/minecraft/world/entity/Mob.java
|
||||
@@ -219,10 +236,10 @@ index 173ec6919cef2aa90c40d3bf33d927a2db7b4922..e99fd3cd5ca6863facd189bf9cd4a3d5
|
||||
this.navigation.tick();
|
||||
this.customServerAiStep((ServerLevel)this.level());
|
||||
diff --git a/net/minecraft/world/entity/ai/goal/AvoidEntityGoal.java b/net/minecraft/world/entity/ai/goal/AvoidEntityGoal.java
|
||||
index 7651676e72fcec52d7c1f9f7d7b6f9e585015c4d..df1fcc24878ce6623f605140ac4b5850bc79bf28 100644
|
||||
index 7651676e72fcec52d7c1f9f7d7b6f9e585015c4d..7b1f8e58f6b1fc34204b77cf3c902759aceb3350 100644
|
||||
--- a/net/minecraft/world/entity/ai/goal/AvoidEntityGoal.java
|
||||
+++ b/net/minecraft/world/entity/ai/goal/AvoidEntityGoal.java
|
||||
@@ -67,15 +67,24 @@ public class AvoidEntityGoal<T extends LivingEntity> extends Goal {
|
||||
@@ -67,6 +67,13 @@ public class AvoidEntityGoal<T extends LivingEntity> extends Goal {
|
||||
|
||||
@Override
|
||||
public boolean canUse() {
|
||||
@@ -236,11 +253,8 @@ index 7651676e72fcec52d7c1f9f7d7b6f9e585015c4d..df1fcc24878ce6623f605140ac4b5850
|
||||
this.toAvoid = getServerLevel(this.mob)
|
||||
.getNearestEntity(
|
||||
this.mob.level().getEntitiesOfClass(this.avoidClass, this.mob.getBoundingBox().inflate(this.maxDist, 3.0, this.maxDist), livingEntity -> true),
|
||||
this.avoidEntityTargeting,
|
||||
this.mob,
|
||||
this.mob.getX(),
|
||||
- this.mob.getY(),
|
||||
+ this.mob.getEyeY(), // Leaf - Async target finding
|
||||
@@ -76,6 +83,8 @@ public class AvoidEntityGoal<T extends LivingEntity> extends Goal {
|
||||
this.mob.getY(),
|
||||
this.mob.getZ()
|
||||
);
|
||||
+ }
|
||||
@@ -266,7 +280,7 @@ index 7651676e72fcec52d7c1f9f7d7b6f9e585015c4d..df1fcc24878ce6623f605140ac4b5850
|
||||
+ final var ctx = mob.getGoalCtx();
|
||||
+ if (!ctx.state) return;
|
||||
+ final double x = mob.getX();
|
||||
+ final double y = mob.getEyeY();
|
||||
+ final double y = mob.getY();
|
||||
+ final double z = mob.getZ();
|
||||
+ final var avoidClass = this.avoidClass;
|
||||
+ final var bound = mob.getBoundingBox().inflate(this.maxDist, 3.0, this.maxDist);
|
||||
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Add configurable death item drop knockback settings
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index 905a532f22b1155641c5a7c66f8cd18ab6447e99..89751b2651f85eefeca7c782460297fbb2ddbcff 100644
|
||||
index 4a39b4ee1ea860a8a47bdad67ac79c74157b6d07..9ec5f1ebc013b427e92f92d6df722b42aa7f73d7 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1065,7 +1065,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -18,10 +18,10 @@ index 905a532f22b1155641c5a7c66f8cd18ab6447e99..89751b2651f85eefeca7c782460297fb
|
||||
}
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
||||
index 1d78cacbf2c63f35fdf0552d50834385ab51aaf0..f1975e5ab19da6dd1d8b94503924471e3efab921 100644
|
||||
index aadba595ca9ad6ba403b16b3c741421005f0414a..93c1e8f39f8db3cd69959f1528ef80481f74e8b0 100644
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -4154,9 +4154,9 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
||||
@@ -4160,9 +4160,9 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
||||
}
|
||||
|
||||
if (randomizeMotion) {
|
||||
|
||||
@@ -9,6 +9,7 @@ public class Waker {
|
||||
public volatile VWaker wake = null;
|
||||
@Nullable
|
||||
public volatile Object result = null;
|
||||
private volatile boolean cancel = false;
|
||||
public boolean state = true;
|
||||
|
||||
public final @Nullable Object result() {
|
||||
@@ -18,6 +19,7 @@ public class Waker {
|
||||
}
|
||||
|
||||
public final void cancel() {
|
||||
this.cancel = true;
|
||||
this.wake = null;
|
||||
this.result = null;
|
||||
}
|
||||
@@ -31,6 +33,9 @@ public class Waker {
|
||||
AsyncGoalExecutor.LOGGER.error("Exception while wake", e);
|
||||
}
|
||||
this.wake = null;
|
||||
if (this.cancel) {
|
||||
this.result = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user