mcCoroutineTask

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(source)

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

Return

the Job for this task, which is cancellable

Parameters

sync

if true, the coroutine will be executed by the Minecraft main thread

client

if true, a dispatcher for syncing with the client main thread will be used

howOften

specifies how often the task should be executed, for infinite execution use infiniteMcCoroutineTask

period

the duration between each "round" of execution

delay

the delay before the first execution begins

task

the task which should be executed