mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-25 09:59:15 +00:00
improve Async target finding (#294)
* fix NearestHealableRaiderTargetGoal not async and fix data race in Async target finding * remove unnecessary requiresUpdateEveryTick * add AsyncGoal * use cow list on ServerLevel#players * move warning * run tasks after entity tick
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
package org.dreeam.leaf.async.ai;
|
||||
|
||||
public interface AsyncGoal {
|
||||
boolean poll();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.dreeam.leaf.async.ai;
|
||||
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class AsyncGoalExecutor {
|
||||
public static final java.util.concurrent.ExecutorService EXECUTOR = new ThreadPoolExecutor(
|
||||
1,
|
||||
1,
|
||||
0L,
|
||||
TimeUnit.MILLISECONDS,
|
||||
new ArrayBlockingQueue<>(128),
|
||||
new com.google.common.util.concurrent.ThreadFactoryBuilder()
|
||||
.setNameFormat("Leaf Async Target Finding Thread")
|
||||
.setDaemon(true)
|
||||
.setPriority(Thread.NORM_PRIORITY - 2)
|
||||
.build(), new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
}
|
||||
Reference in New Issue
Block a user