diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2024-09-08 07:03:51 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-07 23:03:51 +0200 |
commit | d09480c3d272f270fb1b45c51bc3540b5416c09a (patch) | |
tree | 0a30b107c3cddb2bcfa80cb5318ef621fe3f8d5c /src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt | |
parent | 88416edd2f5a50e1ba88e9adb574e3c60c49abca (diff) | |
download | skyhanni-d09480c3d272f270fb1b45c51bc3540b5416c09a.tar.gz skyhanni-d09480c3d272f270fb1b45c51bc3540b5416c09a.tar.bz2 skyhanni-d09480c3d272f270fb1b45c51bc3540b5416c09a.zip |
Backend: Use on DelayedRun to add scheduled tasks (#2462)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt b/src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt index eb83bce3a..4642124b7 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt @@ -2,7 +2,9 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.CollectionUtils.drainTo +import net.minecraft.client.Minecraft import java.util.concurrent.ConcurrentLinkedQueue +import java.util.concurrent.Executor import kotlin.time.Duration object DelayedRun { @@ -35,4 +37,14 @@ object DelayedRun { } futureTasks.drainTo(tasks) } + + @JvmField + val onThread = Executor { + val mc = Minecraft.getMinecraft() + if (mc.isCallingFromMinecraftThread) { + it.run() + } else { + Minecraft.getMinecraft().addScheduledTask(it) + } + } } |