mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 18:59:49 +00:00
Fixed IConditional's task firing with latency after code that must come after it due to thread delegation
This commit is contained in:
1 parent
8b4892cb35
commit
0e8db79605
1 file changed
+17
-21
@@ -57,31 +57,27 @@ public class ConditionalAction extends Action implements IConditionalAction {
|
||||
}
|
||||
|
||||
if (ticksExisted % updateEveryXTick == 0) {
|
||||
if (condition != null && condition.apply(this)) {
|
||||
if (isThreaded)
|
||||
actionThread.execute("task", this::executeTask);
|
||||
else
|
||||
executeTask();
|
||||
}
|
||||
|
||||
if (isTerminated()) {
|
||||
if (onTermination != null) {
|
||||
if (isThreaded)
|
||||
actionThread.execute("onTermination", this::executeOnTermination);
|
||||
else
|
||||
executeOnTermination();
|
||||
}
|
||||
markDone();
|
||||
return;
|
||||
}
|
||||
|
||||
checkCount++;
|
||||
|
||||
Runnable execute = () -> {
|
||||
if (condition != null && condition.apply(this))
|
||||
executeTask();
|
||||
|
||||
if (isTerminated()) {
|
||||
if (onTermination != null)
|
||||
executeOnTermination();
|
||||
markDone();
|
||||
}
|
||||
};
|
||||
|
||||
if (isThreaded)
|
||||
actionThread.execute("task", execute);
|
||||
else
|
||||
execute.run();
|
||||
}
|
||||
|
||||
if (maxCount > -1 && count >= maxCount) {
|
||||
if (maxCount > -1 && count >= maxCount)
|
||||
markDone();
|
||||
return;
|
||||
}
|
||||
|
||||
duration++;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user