kettle

Kotlin utilities for Quilt mod development


Project maintained by Cypher121 Hosted on GitHub Pages — Theme by mattgraham

//kettle/coffee.cypher.kettle.scheduler/Task

Task

[jvm]
interface Task<T : Any>

A task that can be run on a TickingScheduler. Entirely self-contained and can be moved between schedulers at will. Can be paused, stopped, and restarted from outside the task. Attempting to do so from inside the task will throw IllegalStateException. Use TaskContext.sleepFor and TaskContext.waitUntil instead.

A task can be created using Task.create or using the task DSL.

Types

Name Summary
Companion [jvm]
object Companion
State [jvm]
sealed class State
Represents possible lifecycle states of a task.

Properties

Name Summary
isExecuting [jvm]
abstract val isExecuting: Boolean
true if task is running and not waiting for a condition or sleeping, or false otherwise
isSleeping [jvm]
abstract val isSleeping: Boolean
true if the task is sleeping for a certain amount of ticks, or false otherwise
isWaiting [jvm]
abstract val isWaiting: Boolean
true if the task is waiting for a condition, or false otherwise
name [jvm]
abstract val name: String
name of the task
state [jvm]
abstract val state: Task.State
current external state of the task

Functions

Name Summary
copy [jvm]
abstract fun copy(): Task<T>
Creates a copy of this task with identical configuration and executed code.
forceResume [jvm]
abstract fun forceResume()
Resumes the task if it was previously paused with pause. Additionally, cancels any suspension caused by TaskContext.sleepFor or TaskContext.waitUntil.
pause [jvm]
abstract fun pause()
Pauses the task, so it can be resumed later using resume.
reset [jvm]
abstract fun reset()
Resets the task’s execution, so it can be started from the beginning using start.
restart [jvm]
open fun restart()
Resets the task and starts it from the beginning.
resume [jvm]
abstract fun resume()
Resumes the task if it was previously paused with pause.
start [jvm]
abstract fun start()
Starts the task if it is newly created or has been reset.
stop [jvm]
abstract fun stop()
Ends the execution of the task. The task can no longer be resumed, but can be reset and started again.