Another ActionThread overhaul

This commit is contained in:
bigguy345 committed 2025-06-29 21:06:15 +03:00
1 parent 772fc5ef6d
commit bdbf30d328
2 files changed
+36 -33

No files matched your search

@@ -67,23 +67,27 @@ public class Action implements IAction {
startAfterTicks--;
return;
}
if (maxDuration != -1 && duration >= maxDuration) {
if (maxDuration > -1 && duration >= maxDuration) {
markDone();
return;
}
if (ticksExisted % updateEveryXTick == 0 && task != null) {
if (isThreaded)
actionThread.run();
else {
try {
task.accept(this);
count++;
} catch (Throwable t) {
System.err.println("Scripted action '" + name + "' threw an exception:");
t.printStackTrace();
markDone();
}
}
actionThread.execute(this::executeTask);
else
executeTask();
}
duration++;
}
protected void executeTask() {
try {
task.accept(this);
count++;
} catch (Throwable t) {
System.err.println("IAction '" + name + "' threw an exception:");
t.printStackTrace();
markDone();
}
duration++;
}