From cc2781e7faf875964c6c6c336ff85323bde30665 Mon Sep 17 00:00:00 2001 From: hayanesuru Date: Sun, 4 May 2025 00:22:02 +0800 Subject: [PATCH] don't submit running goal --- .../features/0154-Async-target-finding.patch | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/leaf-server/minecraft-patches/features/0154-Async-target-finding.patch b/leaf-server/minecraft-patches/features/0154-Async-target-finding.patch index 822fb0ef..d41c09d8 100644 --- a/leaf-server/minecraft-patches/features/0154-Async-target-finding.patch +++ b/leaf-server/minecraft-patches/features/0154-Async-target-finding.patch @@ -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 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()); + } + }