9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-28 19:39:17 +00:00

don't submit running goal

This commit is contained in:
hayanesuru
2025-05-04 00:22:02 +08:00
parent 1ffa315c13
commit cc2781e7fa

View File

@@ -190,7 +190,7 @@ index 0903508d2cd3c78602e62dbcff4aa70285bc4c4f..e99fd55a90c68cc96701e5291219d1d0
// Paper start - Folia schedulers
diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java
index 05d5cde42b7011091ef4ee874c0d9d5586ae3f10..7b4330c15a2bdf63882c4ed025f2b426592a9bba 100644
index 05d5cde42b7011091ef4ee874c0d9d5586ae3f10..99362471bee4f8404f7cecd860ff339241705d63 100644
--- a/net/minecraft/world/entity/Mob.java
+++ b/net/minecraft/world/entity/Mob.java
@@ -144,6 +144,12 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
@@ -206,21 +206,22 @@ index 05d5cde42b7011091ef4ee874c0d9d5586ae3f10..7b4330c15a2bdf63882c4ed025f2b426
protected Mob(EntityType<? extends Mob> entityType, Level level) {
super(entityType, level);
@@ -225,12 +231,21 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
@@ -225,12 +231,22 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
}
// Paper end - Skip AI during inactive ticks for non-aware mobs
boolean isThrottled = org.dreeam.leaf.config.modules.opt.ThrottleInactiveGoalSelectorTick.enabled && _pufferfish_inactiveTickDisableCounter++ % 20 != 0; // Pufferfish - throttle inactive goal selector ticking
+ this.tickingTarget = false; // Leaf - Async target finding
+ // Leaf start - Async target finding
+ boolean running = this.targetSelector.ctxGoals != null || this.goalSelector.ctxGoals != null;
+ this.tickingTarget = false;
if (this.goalSelector.inactiveTick(this.activatedPriority, true) && !isThrottled) { // Pufferfish - pass activated priroity // Pufferfish - throttle inactive goal selector ticking
this.goalSelector.tick();
}
+ this.tickingTarget = true; // Leaf - Async target finding
+ this.tickingTarget = true;
if (this.targetSelector.inactiveTick(this.activatedPriority, true)) { // Pufferfish - pass activated priority
this.targetSelector.tick();
}
+ // Leaf start - Async target finding
+ if (org.dreeam.leaf.config.modules.async.AsyncTargetFinding.enabled) {
+ if (this.targetSelector.ctxGoals != null || this.goalSelector.ctxGoals != null) {
+ if (!running && (this.targetSelector.ctxGoals != null || this.goalSelector.ctxGoals != null)) {
+ ((ServerLevel) this.level()).asyncGoalExecutor.submit(this.getId());
+ }
+ }
@@ -228,11 +229,12 @@ index 05d5cde42b7011091ef4ee874c0d9d5586ae3f10..7b4330c15a2bdf63882c4ed025f2b426
}
// Paper end
@@ -914,17 +929,28 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
@@ -914,17 +930,29 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
// Paper end - Allow nerfed mobs to jump and float
this.sensing.tick();
int i = this.tickCount + this.getId();
+ // Leaf start - Async target finding
+ boolean running = this.targetSelector.ctxGoals != null || this.goalSelector.ctxGoals != null;
if (i % 2 != 0 && this.tickCount > 1) {
+ this.tickingTarget = true;
if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
@@ -249,7 +251,7 @@ index 05d5cde42b7011091ef4ee874c0d9d5586ae3f10..7b4330c15a2bdf63882c4ed025f2b426
this.goalSelector.tick();
}
+ if (org.dreeam.leaf.config.modules.async.AsyncTargetFinding.enabled) {
+ if (this.targetSelector.ctxGoals != null || this.goalSelector.ctxGoals != null) {
+ if (!running && (this.targetSelector.ctxGoals != null || this.goalSelector.ctxGoals != null)) {
+ ((ServerLevel) this.level()).asyncGoalExecutor.submit(this.getId());
+ }
+ }