Search the docs

Find a guide, global, type or member

GlobalEmber

world

Block access by integer coordinates. Block ids come from blocks; they are per running experience, so never persist them, persist names instead. Writes raise outside this map's editable bounds or in unloaded chunks, and count toward 4096 block writes per tick.

Functions

world.get(x: number, y: number, z: number) -> number#

Returns the block id at a position. -1 when the chunk is not loaded

world.set(x: number, y: number, z: number, block: number)#

Sets one block. Raises for an unknown id.

world.fill(x: number, y: number, z: number, sx: number, sy: number, sz: number, block: number) -> number#

Fills a box from corner x, y, z spanning sx, sy, sz blocks (all > 0) with one block. Returns the volume. Every block counts toward the 4096 writes per tick, so bigger fills raise: split them across ticks.

world.read(into: buffer, x: number, y: number, z: number, sx: number, sy: number, sz: number) -> number#

Reads a box into a buffer as little-endian i32 ids, x fastest, then z, then y; -1 where not loaded. The buffer needs 4 * volume bytes. Returns the volume (at most 262144).

world.count(x: number, y: number, z: number, sx: number, sy: number, sz: number, block: number) -> number#

Returns how many blocks in the box are exactly block; unloaded blocks never match.