diff options
author | nea <nea@nea.moe> | 2023-05-16 01:23:43 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-05-16 01:23:43 +0200 |
commit | ead6762eb1c005914b05f9d3c29f334989c67513 (patch) | |
tree | cd1409756be2bc4a93195c31d432fef053afe002 /src/main/kotlin/moe/nea/firmament/util/MinecraftDispatcher.kt | |
parent | 96c546cc73880a7c502c17aadda6ca84c847692d (diff) | |
download | firmament-ead6762eb1c005914b05f9d3c29f334989c67513.tar.gz firmament-ead6762eb1c005914b05f9d3c29f334989c67513.tar.bz2 firmament-ead6762eb1c005914b05f9d3c29f334989c67513.zip |
Replace references to NEU with Firmament
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/util/MinecraftDispatcher.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/util/MinecraftDispatcher.kt | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/util/MinecraftDispatcher.kt b/src/main/kotlin/moe/nea/firmament/util/MinecraftDispatcher.kt new file mode 100644 index 0000000..1e7fba2 --- /dev/null +++ b/src/main/kotlin/moe/nea/firmament/util/MinecraftDispatcher.kt @@ -0,0 +1,22 @@ +package moe.nea.firmament.util + +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.Runnable +import kotlin.coroutines.CoroutineContext +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) + } +} |