aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-26 13:49:05 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-26 13:49:05 +0200
commita575ac91e1efb6f398e5bfd43fd2428c3251f928 (patch)
tree1fc990bd94c9d6ed67053f0b296e94c250cf64a0 /src/main/java/at/hannibal2/skyhanni/utils
parent7944f8f88ec20b8caea0c41757366734682e059d (diff)
downloadskyhanni-a575ac91e1efb6f398e5bfd43fd2428c3251f928.tar.gz
skyhanni-a575ac91e1efb6f398e5bfd43fd2428c3251f928.tar.bz2
skyhanni-a575ac91e1efb6f398e5bfd43fd2428c3251f928.zip
Auto-detecting tool in hand when joining garden
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/MinecraftDispatcher.kt17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/MinecraftDispatcher.kt b/src/main/java/at/hannibal2/skyhanni/utils/MinecraftDispatcher.kt
new file mode 100644
index 000000000..2ccbf30de
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/utils/MinecraftDispatcher.kt
@@ -0,0 +1,17 @@
+package at.hannibal2.skyhanni.utils
+
+import kotlinx.coroutines.MainCoroutineDispatcher
+import net.minecraft.client.Minecraft
+import kotlin.coroutines.CoroutineContext
+
+object MinecraftDispatcher : MainCoroutineDispatcher() {
+ override val immediate: MainCoroutineDispatcher
+ get() = this
+
+ override fun isDispatchNeeded(context: CoroutineContext): Boolean {
+ return !Minecraft.getMinecraft().isCallingFromMinecraftThread
+ }
+ override fun dispatch(context: CoroutineContext, block: Runnable) {
+ Minecraft.getMinecraft().addScheduledTask(block)
+ }
+} \ No newline at end of file