blob: 7cbfffe37900b9d527c389a4eff1e03927c75d69 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
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)
}
}
|