Creates an empty world with the given generation seed.
master seed for terrain, biome, and erosion noise
Optional fixed vertical chunk-Y band for loading. When set, chunks load over
[min, max] in cy regardless of the camera's height, instead of a
±renderDistanceV window around it — so a finite-height imported world (e.g.
the castle, cy 0..12) keeps its full vertical column resident when you fly up
above it. null = the default camera-relative vertical window.
Optional Minecraft-style colored block-light field. When set, the chunk
mesher samples it per face and the chunk shader adds a colored ambient term
(see block_light.ts) — torches/lamps light surrounding surfaces with no
256-point-light budget. null = feature off (plain block-type verts).
Per-block state (container contents, machine progress, …). Swapped per dimension by setDimension.
Min-heap of scheduled block ticks, drained in game-tick order. Swapped per dimension by setDimension.
Monotonic game-tick counter advanced by update.
Discrete game ticks per second (Minecraft-style 20).
Random ticks per resident chunk per game tick (crops/grass/etc.).
Chunk radius around the player that receives random ticks.
OptionalonOptionalonOptionalonOptionalonFires after any block is placed via setBlockType. World-space coords.
OptionalonFires before a block is removed via mineBlock. World-space coords.
OptionalchunkOptional override for terrain generation, so one engine can host multiple worlds (overworld vs. nether/end) with different generators. When set, it fills a freshly-created chunk instead of the default Chunk.generateBlocks.
Active dimension id (0 = overworld). Switched via setDimension; the
value is opaque to the engine — the game assigns its own ids (see crafty's
Dim). Each dimension keeps its own chunk store, block-entities, scheduled
ticks, erosion cache, and generator, parked in _dimStates while inactive.
Hard cap on the number of resident chunks, derived from the current view
range so a larger renderDistanceH/renderDistanceV raises the budget and
a smaller one frees memory. Sized for the cylindrical load volume (circular
footprint × vertical span) using the +1 removal hysteresis radius, plus a
margin so the steady-state set never bumps the cap and stalls loading.
Number of chunks currently resident in memory.
Iterator over all resident chunks.
Returns the biome at a world-space block position (does not require the chunk to exist).
world X
world Y
world Z
StaticnormalizeConverts a world-space block position to integer chunk coordinates.
world X
world Y
world Z
[cx, cy, cz] chunk coordinates
Returns the chunk containing the given world-space block position, or undefined if not loaded.
world X
world Y
world Z
Returns true if a chunk exists at the given world-space block position.
world X
world Y
world Z
Returns the block type at a world-space position, or BlockType.NONE if the chunk is not loaded.
world X
world Y
world Z
Sets the block at a world-space position, creating the chunk if needed and re-meshing it.
world X
world Y
world Z
new block type
true on success
Returns the Y of the first air block above the highest solid/water block in column (wx, wz).
Scans downward from maxY. Returns 0 if the column is empty.
world X
world Z
upper bound to start scanning from
Like getTopBlockY, but skips water (and props) so it returns the Y of the first air block above the highest solid (walkable) block. Use this to distinguish dry land from ocean: a column whose top solid surface sits below Chunk.SEA_LEVEL is submerged.
Returns 0 if the column has no solid block.
Casts a ray through the voxel grid and returns the first non-water block hit.
Implements the Amanatides & Woo "Fast Voxel Traversal Algorithm for Ray Tracing". Water blocks are skipped (the ray passes through them).
hit description, or null if no block was hit
Places a block adjacent to the hit block on the given face.
The new block goes at (gX + faceX, gY + faceY, gZ + faceZ). Existing
non-air, non-water blocks block placement. Creates the target chunk if needed.
hit block world X
hit block world Y
hit block world Z
face normal X
face normal Y
face normal Z
block type to place
true if a block was placed
Removes the block at the given world position and re-meshes the affected chunk(s).
world X
world Y
world Z
true if a block was removed
Advances world time, streams chunks around the player, and ticks water flow.
current player position
elapsed time in seconds
Advances one discrete game tick: dispatches all scheduled ticks now due, then a random-tick sweep of chunks near the player. Exposed for tests / deterministic stepping; update calls it at tickRate.
OptionalplayerPos: Vec3center for the random-tick sweep (omit to skip random ticks)
Schedules a tick for the block at (wx,wy,wz) delayTicks ticks from now.
Returns the block-entity state at a world position, if any.
Stores block-entity state at a world position.
Removes block-entity state at a world position.
Notifies the 6 face-adjacent blocks that the block at (wx,wy,wz) changed, dispatching each neighbor's registered handler. Handlers that themselves change blocks cascade through this; a depth guard caps runaway chains (handlers that would propagate far should schedule a tick instead).
Removes a chunk from the world, marks it deleted, and notifies listeners.
chunk to delete
Switches the world to another dimension, parking the current dimension's
full state (chunks, block-entities, scheduled ticks, erosion cache,
generator) and restoring the target's. The active world object is
unchanged, so every system holding a reference keeps working — only the
underlying stores swap. Chunk meshes are detached from / re-attached to the
renderer via onChunkRemoved/onChunkAdded; the next
update streams any not-yet-generated chunks around the player.
target dimension id (the game's own numbering; 0 = overworld).
Optionalgenerator: (chunk: Chunk, seed: number) => voidterrain generator for the target if it's being entered for the first time. Omit for the default overworld generation.
Computes a discrete water depth value at the given world position.
Walks upward through stacked chunks of water and accumulates a per-chunk level contribution based on the height of the water column.
world X
world Y
world Z
aggregate water level (0 if not in water)
Returns the cached hydraulic-erosion displacement at world XZ.
Looks up (and lazily generates) the 128x128 region containing (gx, gz).
world X
world Z
Re-mesh every resident chunk. Used when a global meshing input changes at
runtime (e.g. toggling blockLightField) so the change takes effect
without reloading. Fires onChunkUpdated per chunk.
Opt in to off-thread chunk meshing: spins up (lazily) a ChunkMeshPool
so generateVertices runs on workers instead of blocking the frame while
chunks stream in. Safe to call more than once. If workers can't start the
pool reports ChunkMeshPool.unavailable and meshing stays inline.
Streaming voxel world built from
Chunks keyed by integer chunk coordinates.Chunks are stored in a
Map<string, Chunk>keyed by"cx,cy,cz", where chunk coordinates are world coords floor-divided by chunk dimensions.update()generates chunks withinrenderDistanceH/renderDistanceVof the player and removes ones outside that radius. New chunks are created at mostchunksPerFrameper call, sorted by distance to the player. Generation uses a cached 128x128 hydraulic erosion displacement field per region.