diff options
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/util')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/util/MinecraftDispatcher.kt | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/util/MinecraftDispatcher.kt b/src/main/kotlin/moe/nea/firmament/util/MinecraftDispatcher.kt index 29ca6c2..5f94f41 100644 --- a/src/main/kotlin/moe/nea/firmament/util/MinecraftDispatcher.kt +++ b/src/main/kotlin/moe/nea/firmament/util/MinecraftDispatcher.kt @@ -6,23 +6,7 @@ package moe.nea.firmament.util -import kotlinx.coroutines.CoroutineDispatcher -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.Runnable -import kotlin.coroutines.CoroutineContext +import kotlinx.coroutines.asCoroutineDispatcher import net.minecraft.client.MinecraftClient -object MinecraftDispatcher : CoroutineDispatcher() { - @ExperimentalCoroutinesApi - override fun limitedParallelism(parallelism: Int): CoroutineDispatcher { - throw UnsupportedOperationException("limitedParallelism is not supported for MinecraftDispatcher") - } - - override fun isDispatchNeeded(context: CoroutineContext): Boolean = - !MinecraftClient.getInstance().isOnThread - - - override fun dispatch(context: CoroutineContext, block: Runnable) { - MinecraftClient.getInstance().execute(block) - } -} +val MinecraftDispatcher by lazy { MinecraftClient.getInstance().asCoroutineDispatcher() } |