Package-level declarations

Coroutine utilities (for example a Minecraft main thread dispatcher) and coroutine task functions

Types

Link copied to clipboard
class CoroutineTask(howOften: Long)

Properties

Link copied to clipboard
val fabrikCoroutineScope: CoroutineScope
Link copied to clipboard
lateinit var mcClientCoroutineDispatcher: CoroutineDispatcher

A CoroutineDispatcher which executes code synchronously to the net.minecraft.client.MinecraftClient main game thread.

Link copied to clipboard
lateinit var mcClientCoroutineScope: CoroutineScope

A CoroutineScope using the current net.minecraft.client.MinecraftClient as the CoroutineDispatcher.

Link copied to clipboard
lateinit var mcCoroutineDispatcher: CoroutineDispatcher

A CoroutineDispatcher which executes code synchronously to the net.minecraft.server.MinecraftServer main server thread.

Link copied to clipboard
lateinit var mcCoroutineScope: CoroutineScope

A CoroutineScope using the current net.minecraft.server.MinecraftServer as the CoroutineDispatcher.

Link copied to clipboard
val silkCoroutineScope: CoroutineScope

A CoroutineScope using the "Default" dispatcher of kotlinx.coroutines.

Functions

Link copied to clipboard
inline fun coroutineTask(sync: Boolean = true, howOften: Long = 1, period: Long = 0, delay: Long = 0, crossinline task: suspend CoroutineScope.(task: CoroutineTask) -> Unit): Job
Link copied to clipboard
inline fun infiniteMcCoroutineTask(sync: Boolean = true, client: Boolean = false, scope: CoroutineScope = if (sync) { if (client) mcClientCoroutineScope else mcCoroutineScope } else silkCoroutineScope, period: Duration = 1.ticks, delay: Duration = Duration.ZERO, crossinline task: suspend CoroutineScope.() -> Unit): Job

Allows you to use coroutines for infinitely repeating tasks.

Link copied to clipboard
inline fun <T> initWithServerAsync(crossinline block: suspend CoroutineScope.(MinecraftServer) -> T): Deferred<T>

Returns a Deferred<T> which will be completed as soon as the server is starting.

Link copied to clipboard
inline fun <T> initWithServerSync(crossinline block: suspend CoroutineScope.(MinecraftServer) -> T): Deferred<Job>

Returns a Deferred<T> which will be completed as soon as the server is starting.

Link copied to clipboard
fun CoroutineScope.mcClientSyncLaunch(block: suspend CoroutineScope.() -> Unit): Job

Does the same as launch, but the dispatcher defaults to mcClientCoroutineDispatcher.

Link copied to clipboard
inline fun mcCoroutineTask(sync: Boolean = true, client: Boolean = false, scope: CoroutineScope = if (sync) { if (client) mcClientCoroutineScope else mcCoroutineScope } else silkCoroutineScope, howOften: Long = 1, period: Duration = 1.ticks, delay: Duration = Duration.ZERO, crossinline task: suspend CoroutineScope.(task: CoroutineTask) -> Unit): Job

Allows you to use coroutines for tasks, both repeating and non-repeating.

Link copied to clipboard
fun CoroutineScope.mcSyncLaunch(block: suspend CoroutineScope.() -> Unit): Job

Does the same as launch, but the dispatcher defaults to mcCoroutineDispatcher.