API reference / @jsprismarine/worldgen / ChunkSampler
Class: ChunkSampler
Defined in: chunk/ChunkSampler.ts:79
Samples one chunk column: the final density per block, then the aquifer's verdict on what fills the positions the density leaves open.
26.3 moved the cell interpolation that used to live in this class into the interpolated density function, so there is no cell grid here any more. The overworld's final_density carries cell_size_xz: 4 and cell_size_y: 8, and the generator reads it per block.
Block states come out as Java identifiers. Translating them to Bedrock belongs to @jsprismarine/mapping, so nothing in this package knows about the Bedrock palette.
Constructors
Constructor
new ChunkSampler(
randomState,options):ChunkSampler
Defined in: chunk/ChunkSampler.ts:115
Parameters
randomState
options
Returns
ChunkSampler
Properties
cellCount
readonlycellCount:number
Defined in: chunk/ChunkSampler.ts:91
How many interpolation cells ChunkSampler.forEachCellBlock splits the chunk into.
One for a dimension whose density functions interpolate nothing, in which case that method walks the chunk column by column exactly as ChunkSampler.fill does.
context
readonlycontext:SampleContext
Defined in: chunk/ChunkSampler.ts:83
The per-chunk mutable state the compiled samplers read.
volume
readonlyvolume:AquiferVolume
Defined in: chunk/ChunkSampler.ts:81
The block extent this sampler covers.
Accessors
aquifer
Get Signature
get aquifer():
Aquifer
Defined in: chunk/ChunkSampler.ts:182
The aquifer bound to this chunk, shared across every column in it.
Built on first use. Its constructor samples the preliminary surface height of 121 quart columns, which is 0.7 milliseconds that a sampler asked only for densities - a surface probe, a structure height walk - never has to spend.
Returns
cellSkipStats
Get Signature
get cellSkipStats():
Readonly<{aquiferCallsSkipped:number;blocksSkipped:number;cellsSkipped:number;densityCallsSkipped:number; }>
Defined in: chunk/ChunkSampler.ts:197
Counts the cells and per-block calls avoided by the proven-cell path.
Returns
Readonly<{ aquiferCallsSkipped: number; blocksSkipped: number; cellsSkipped: number; densityCallsSkipped: number; }>
Methods
blockAt()
blockAt(
x,y,z):ColumnBlock
Defined in: chunk/ChunkSampler.ts:236
Returns the block at one position, running the density and then the aquifer.
Columns are generated from the top down because the aquifer's fluid update flag and its surface probing both assume that order.
Parameters
x
number
y
number
z
number
Returns
column()
column(
x,z):ColumnBlock[]
Defined in: chunk/ChunkSampler.ts:491
Generates one column from the top of the dimension down to its floor.
Parameters
x
number
z
number
Returns
One entry per y level, ordered from minBlockY upward.
columnTop()
columnTop(
x,z,accept,fromY?):number|undefined
Defined in: chunk/ChunkSampler.ts:271
The highest y in a column whose block a predicate accepts, or undefined for none.
This is the walk Java's NoiseBasedChunkGenerator.iterateNoiseColumn makes on behalf of getBaseHeight: the answer depends on the top of the column and nothing under it, so everything below the match goes unsampled. The blocks above it are sampled in the same order ChunkSampler.column uses, which is the order the aquifer expects.
Parameters
x
number
z
number
accept
(state) => boolean
fromY?
number = ...
Where to start, for a caller whose dimension is shorter than the noise. Clamped to the top of the chunk.
Returns
number | undefined
density()
density(
x,y,z):number
Defined in: chunk/ChunkSampler.ts:212
The final density at one block position.
Parameters
x
number
y
number
z
number
Returns
number
fill()
fill():
ColumnBlock[][][]
Defined in: chunk/ChunkSampler.ts:507
Generates every column of the chunk.
Returns
ColumnBlock[][][]
A 16 by 16 grid indexed as [localZ][localX], each entry a column ordered from minBlockY upward.
forEachCellBlock()
forEachCellBlock(
cell,visit):void
Defined in: chunk/ChunkSampler.ts:297
Visits every block of one interpolation cell, top slab first.
A block is the same whichever order it is asked in, so this exists only to keep one interpolation cell current for 128 consecutive samples instead of eight. Walking the chunk column by column crosses a cell boundary every eight blocks and makes the density stack refetch eight cell corners each time; walking it cell by cell crosses one per cell.
Parameters
cell
number
A cell index below ChunkSampler.cellCount. Indices run from the top of the dimension down, so a caller that stops early has filled the sky and not the bedrock.
visit
(x, y, z, state, scheduleFluidUpdate) => void
Returns
void
forEachColumnBlock()
forEachColumnBlock(
x,z,visit):void
Defined in: chunk/ChunkSampler.ts:246
Visits a column from the top down without allocating one result object per block.
Parameters
x
number
z
number
visit
(y, state, scheduleFluidUpdate) => void
Returns
void
sample()
sample(
node,x,y,z):number
Defined in: chunk/ChunkSampler.ts:226
Samples one density function of this dimension at one block position.
Parameters
node
x
number
y
number
z
number
Returns
number