mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 18:05:10 +00:00
Fixed updateEveryXTicks being inconsistent due to using entity's ticksExisted. IAction instances now track their own tick
This commit is contained in:
1 parent
7e1374d96a
commit
e0c9bfffa5
8 files changed
+31
-34
No files matched your search
@@ -92,6 +92,10 @@ public class ActionThread {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isTaskRunning(String taskKey) {
|
||||
return runningTasks.contains(taskKey);
|
||||
}
|
||||
|
||||
public boolean inActionThread() {
|
||||
return Thread.currentThread() == thread;
|
||||
}
|
||||
@@ -108,13 +112,12 @@ public class ActionThread {
|
||||
if (threadPaused && pauseUntil != null && pauseUntil.apply(action))
|
||||
resume();
|
||||
|
||||
if (runningKeys.contains(taskKey))
|
||||
if (!runningKeys.add(taskKey))
|
||||
return;
|
||||
|
||||
final AtomicReference<Future<?>> taskRef = new AtomicReference<>();
|
||||
taskRef.set(executor.submit(() -> {
|
||||
runningTasks.add(taskRef.get());
|
||||
runningKeys.add(taskKey);
|
||||
try {
|
||||
task.run();
|
||||
} finally {
|
||||
|
||||
Reference in new issue
Block a user