API reference / @jsprismarine/worldgen / SurfaceSystem
Class: SurfaceSystem
Defined in: surface/SurfaceSystem.ts:132
The surface pass: the stage that turns a column of stone and water into grass, sand, terracotta bands, bedrock and ore veins.
It walks each column of a chunk downward, counts how far each solid block sits from the opening above it and the opening below it, and asks the dimension's material rule tree what to place. The three counters, the randomized surface depth and the preliminary surface level are the whole input the rule tree sees beyond the block position and the biome.
Two biomes extend the pass with code rather than with rules: eroded badlands grows stone pillars above the terrain, and the two frozen oceans grow icebergs. Both run here, as they do in Java.
Constructors
Constructor
new SurfaceSystem(
randomState):SurfaceSystem
Defined in: surface/SurfaceSystem.ts:154
Parameters
randomState
Returns
SurfaceSystem
Properties
defaultBlock
readonlydefaultBlock:string
Defined in: surface/SurfaceSystem.ts:134
The dimension's filler block, which the badlands extension stacks.
generationContext
readonlygenerationContext:WorldGenerationContext
Defined in: surface/SurfaceSystem.ts:140
The dimension extent a vertical anchor resolves against.
preliminarySurface
readonlypreliminarySurface:DensityFunctionNode
Defined in: surface/SurfaceSystem.ts:138
The preliminary surface height function, which is the router's chunk_surface_level.
seaLevel
readonlyseaLevel:number
Defined in: surface/SurfaceSystem.ts:136
The dimension's sea level.
Methods
buildSurface()
buildSurface(
options):SurfacePass
Defined in: surface/SurfaceSystem.ts:204
Runs the material rule over every column of one chunk, writing into the chunk.
Columns are walked from the top down, because the stone depth counters and the water height the rules read are accumulated in that order.
Parameters
options
Returns
The compiled rule and its context, which the carvers query per carved block.
getBand()
getBand(
x,y,z):string
Defined in: surface/SurfaceSystem.ts:191
The terracotta band at one position of a badlands column.
Parameters
x
number
y
number
z
number
Returns
string
getSurfaceDepth()
getSurfaceDepth(
blockX,blockZ):number
Defined in: surface/SurfaceSystem.ts:180
How thick the surface layer is in one column.
The value is a noise sample plus one quarter of a positional random draw, so two neighboring columns differ by a block or so and the grass line is not flat.
Parameters
blockX
number
blockZ
number
Returns
number
getSurfaceSecondary()
getSurfaceSecondary(
blockX,blockZ):number
Defined in: surface/SurfaceSystem.ts:186
The second surface noise, which widens a stone_depth condition's secondary range.
Parameters
blockX
number
blockZ
number
Returns
number