Skip to content

API reference / @jsprismarine/engine-systems / BlockRandomPositions

Class: BlockRandomPositions ​

Defined in: engine-systems/src/randomTick.ts:37

Java's Level.getBlockRandomPos, which is also the world's own tick-order randomizer: one state, stepped once per draw.

Java holds the state on the level and steps it with randValue * 3 + 1013904223, then uses bits 2 to 5 for x, bits 10 to 13 for z and bits 18 to 21 for y.

Constructors ​

Constructor ​

new BlockRandomPositions(seed?): BlockRandomPositions

Defined in: engine-systems/src/randomTick.ts:43

Parameters ​

seed? ​

number = 0

The starting value, which Java leaves at 0 for a new level.

Returns ​

BlockRandomPositions

Methods ​

next() ​

next(originX, originY, originZ, yMask?): BlockPosition

Defined in: engine-systems/src/randomTick.ts:69

The next position inside one section.

Parameters ​

originX ​

number

The section's lowest x.

originY ​

number

The section's lowest y.

originZ ​

number

The section's lowest z.

yMask? ​

number = 15

The y mask, which tickChunk passes as 15.

Returns ​

BlockPosition


restore() ​

restore(state): void

Defined in: engine-systems/src/randomTick.ts:53

Restores a captured signed 32-bit state without drawing a position.

Parameters ​

state ​

number

Returns ​

void


snapshot() ​

snapshot(): number

Defined in: engine-systems/src/randomTick.ts:48

Returns the current signed 32-bit state for replay comparisons.

Returns ​

number