Package-level declarations

Types

Link copied to clipboard
abstract class CancellableEvent : Event

A cancellable event

Link copied to clipboard
Link copied to clipboard
abstract class Event

A callable event

Link copied to clipboard
class EventHook<T : Event>(val handlerClass: EventListener, val priority: Short = 0, val handler: Consumer<T>)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Occurs when the running Job is canceled because EventListener.running is false

Link copied to clipboard

A modern and fast event handler using lambda handlers

Link copied to clipboard

MixinEntityRenderState of event. Might be PRE or POST.

Link copied to clipboard
typealias SuspendableEventHandler<T> = suspend CoroutineScope.(T) -> Unit
Link copied to clipboard
sealed interface SuspendHandlerBehavior
Link copied to clipboard
interface Ticker

A queue of callbacks advanced once per tick.

Link copied to clipboard

Schedules tasks that must run inside net.minecraft.client.Minecraft.tick.

Properties

Link copied to clipboard
val EventListener.eventListenerScope: CoroutineScope

Get the related CoroutineScope of receiver EventListener.

Link copied to clipboard

The event's name on the interop protocol, or the simple class name for an untagged add-on event.

Functions

Link copied to clipboard
inline fun <E : Event, V> EventListener.computedOn(initialValue: V, priority: Short = 0, crossinline accumulator: (event: E, prev: V) -> V): ReadWriteProperty<EventListener, V>

Returns computed ReadWriteProperty based on the accumulator of specific event.

Link copied to clipboard
inline fun <E : Event> eventFlow(): SharedFlow<E>
Link copied to clipboard
inline fun <T : Event> EventListener.handler(priority: Short = 0, handler: Consumer<T>): EventHook<T>
fun <T : Event> EventListener.handler(eventClass: Class<T>, priority: Short = 0, handler: Consumer<T>): EventHook<T>
Link copied to clipboard
inline fun <E : Event> EventListener.newEventHook(priority: Short = 0, handler: Consumer<E>): EventHook<E>
Link copied to clipboard
inline fun <T : Event> EventListener.once(priority: Short = 0, crossinline handler: (T) -> Unit): EventHook<T>
Link copied to clipboard

Remove cached scope and cancel it.

Link copied to clipboard
inline fun <T : Event> EventListener.repeated(times: Int = 1, priority: Short = 1, crossinline handler: (T) -> Unit): EventHook<T>
Link copied to clipboard
inline fun <T : Event> EventListener.sequenceHandler(priority: Short = 0, dispatcher: CoroutineDispatcher? = null, onCancellation: Runnable? = null, crossinline eventHandler: SuspendableEventHandler<T>): EventHook<T>

Registers an event hook for events of type T and launches a sequence

Link copied to clipboard
inline fun <T : Event> EventListener.suspendHandler(context: CoroutineContext = EmptyCoroutineContext, priority: Short = 0, behavior: SuspendHandlerBehavior = SuspendHandlerBehavior.Parallel.Default, noinline handler: SuspendableEventHandler<T>): EventHook<T>

Start a Job on event.

Link copied to clipboard
suspend fun tickConditional(ticks: Int, breakLoop: BooleanSupplier): Boolean

Ticks until the fixed amount of ticks ran out or the breakLoop says to continue.

Link copied to clipboard
inline fun EventListener.tickHandler(dispatcher: CoroutineDispatcher? = null, onCancellation: Runnable? = null, crossinline eventHandler: suspend CoroutineScope.() -> Unit): EventHook<GameTickEvent>

Registers a repeatable sequence which repeats the execution of code on GameTickEvent.

Link copied to clipboard
suspend fun tickUntil(stopAt: IntPredicate): Int

Ticks with stopAt until it returns true. The elapsed ticks (starting from 1) will be passed to stopAt.

Link copied to clipboard
inline fun <T : Event> EventListener.until(priority: Short = 0, crossinline handler: (T) -> Boolean): EventHook<T>
Link copied to clipboard
inline suspend fun <T : Event> EventListener.waitMatches(priority: Short = 0, predicate: Predicate<T>): T

Wait an event of type T which matches given predicate.

suspend fun <T : Event> EventListener.waitMatches(eventClass: Class<T>, priority: Short, predicate: Predicate<T>): T
Link copied to clipboard
inline suspend fun <T : Event> EventListener.waitMatchesWithTimeout(timeout: Duration, priority: Short = 0, predicate: Predicate<T>): T?

Wait an event of type T which matches given predicate. If the timeout is exceeded, return null.

Link copied to clipboard
suspend fun waitSeconds(seconds: Int)

Waits a fixed amount of seconds on tick level before continuing. Re-entry at the game tick.

Link copied to clipboard
suspend fun waitTicks(ticks: Int)

Waits a fixed amount of ticks before continuing. Re-entry at the game tick.

Link copied to clipboard

Wrap the original interceptor and make it auto-detect the listener's running state at suspension to determine whether to resume the continuation.