Skip to content

API reference / @jsprismarine/engine-systems / TickList

Class: TickList ​

Defined in: engine-systems/src/scheduler.ts:88

One tick list: Java's LevelTicks for a single kind, block or fluid.

Java shards the queue per chunk and merges the shards in drainContainers. This keeps one queue for the whole world, which produces the same order whenever every due tick has the same trigger tick. The two differ only for a backlog that the per-tick budget left behind, and there this ordering is the stricter one: it runs the oldest ticks first.

Constructors ​

Constructor ​

new TickList(): TickList

Returns ​

TickList

Methods ​

clearAt() ​

clearAt(at): void

Defined in: engine-systems/src/scheduler.ts:147

Remove every queued tick at one position, which a destroyed block needs.

Parameters ​

at ​

BlockPosition

Returns ​

void


count() ​

count(): number

Defined in: engine-systems/src/scheduler.ts:132

How many ticks are queued.

Returns ​

number


hasScheduledTick() ​

hasScheduledTick(at, type): boolean

Defined in: engine-systems/src/scheduler.ts:118

Whether a tick is queued for this position and type.

Parameters ​

at ​

BlockPosition

type ​

string

Returns ​

boolean


schedule() ​

schedule(at, type, triggerTick, priority?): boolean

Defined in: engine-systems/src/scheduler.ts:109

Queue a tick, unless one is already queued for the same position and type.

Java's LevelChunkTicks.schedule adds to a ticksPerPosition set first and drops the tick when the set already holds it, which is the rule the wiki states for repeaters: "any attempt to schedule a tick while one already exists is completely ignored".

Parameters ​

at ​

BlockPosition

The position the tick fires for.

type ​

string

The block or fluid identifier.

triggerTick ​

number

The absolute game tick to fire on.

priority? ​

number = TICK_PRIORITIES.NORMAL

One of TICK_PRIORITIES, defaulting to NORMAL.

Returns ​

boolean

True when the tick was queued, false when one already existed.


snapshot() ​

snapshot(): readonly ScheduledTick[]

Defined in: engine-systems/src/scheduler.ts:142

Copies the pending ticks in drain order for diagnostics and replay comparisons.

This sorts a copy, leaving the live queue order untouched. Each position is copied too, so callers cannot mutate a queued tick through the returned state.

Returns ​

readonly ScheduledTick[]


tick() ​

tick(currentTick, run, maxTicks?, deadline?): number

Defined in: engine-systems/src/scheduler.ts:174

Collect every tick due at currentTick, up to the budget, and run them.

Collection takes the oldest ticks first, as Java's per-chunk queues do. The collected batch then runs in INTRA_TICK_DRAIN_ORDER, priority before schedule order. A tick scheduled by a handler during the batch lands in a later game tick, never in the batch being run, which is what makes a repeater chain take its delay rather than collapsing into one tick.

Parameters ​

currentTick ​

number

The game tick to run.

run ​

TickHandler

Called once per due tick, in order.

maxTicks? ​

number = MAX_SCHEDULED_TICKS_PER_TICK

The per-tick budget, defaulting to Java's 65536.

deadline? ​

number = Number.POSITIVE_INFINITY

A performance.now() time after which no further tick starts. The ticks it leaves stay queued, still due, and run first on the next game tick. A count is no bound on time: a slow host, or ticks that each scan a neighborhood, spend seconds inside 65536.

Returns ​

number

How many ticks ran.


willTickThisTick() ​

willTickThisTick(at, type): boolean

Defined in: engine-systems/src/scheduler.ts:127

Whether a queued tick is in the batch the current game tick is running, which is Java's LevelTicks.willTickThisTick. A diode calls it to avoid rescheduling a tick that is about to run.

Parameters ​

at ​

BlockPosition

type ​

string

Returns ​

boolean