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

remove capture world in async target finding

This commit is contained in:
hayanesuru
2025-07-04 15:37:22 +09:00
parent 7b8c74e584
commit b904e81e27
4 changed files with 85 additions and 92 deletions

View File

@@ -52,8 +52,8 @@ public class AsyncGoalExecutor {
if (entity == null || entity.isRemoved() || !(entity instanceof Mob mob)) {
return;
}
mob.goalSelector.ctx.wake();
mob.targetSelector.ctx.wake();
mob.goalSelector.ctx.wake(this.world);
mob.targetSelector.ctx.wake(this.world);
}
private boolean poll(Mob mob) {

View File

@@ -1,8 +1,9 @@
package org.dreeam.leaf.async.ai;
import net.minecraft.server.level.ServerLevel;
import org.jetbrains.annotations.Nullable;
@FunctionalInterface
public interface VWaker {
@Nullable Object wake();
@Nullable Object wake(ServerLevel world);
}

View File

@@ -1,5 +1,6 @@
package org.dreeam.leaf.async.ai;
import net.minecraft.server.level.ServerLevel;
import org.jetbrains.annotations.Nullable;
public class Waker {
@@ -16,11 +17,16 @@ public class Waker {
return result;
}
final void wake() {
final var wake = this.wake;
public final void cancel() {
this.wake = null;
this.result = null;
}
final void wake(ServerLevel world) {
final VWaker wake = this.wake;
if (wake != null) {
try {
this.result = wake.wake();
this.result = wake.wake(world);
} catch (Exception e) {
AsyncGoalExecutor.LOGGER.error("Exception while wake", e);
}