API reference / @jsprismarine/features / TestFeatureWorld
Class: TestFeatureWorld
Defined in: world/TestFeatureWorld.ts:103
An in-memory FeatureWorld for tests: a sparse block store, computed heightmaps and a per-position biome override.
It records every write in order, so a test can assert what a feature built without walking the whole volume, and it answers heightmap queries by scanning the stored column, so a feature that reads a heightmap after writing sees its own blocks, as it does in Java.
Implements
Constructors
Constructor
new TestFeatureWorld(
options?):TestFeatureWorld
Defined in: world/TestFeatureWorld.ts:121
Parameters
options?
Returns
TestFeatureWorld
Properties
blocks
readonlyblocks:BlockOracle
Defined in: world/TestFeatureWorld.ts:113
The static block facts, shared across worlds.
Implementation of
height
readonlyheight:number
Defined in: world/TestFeatureWorld.ts:107
The number of y levels the dimension generates, Java's getHeight().
Implementation of
minY
readonlyminY:number
Defined in: world/TestFeatureWorld.ts:105
The lowest y the dimension generates, Java's getMinY().
Implementation of
seaLevel
readonlyseaLevel:number
Defined in: world/TestFeatureWorld.ts:109
The dimension's sea level, which relative_to_sea_level anchors resolve against.
Implementation of
seed
readonlyseed:bigint
Defined in: world/TestFeatureWorld.ts:111
The world seed.
Only the geode reads it, to build a noise field that is the same everywhere in one world and different between worlds.
Implementation of
writes
readonlywrites:object[] =[]
Defined in: world/TestFeatureWorld.ts:115
Every successful write in the order it happened.
position
position:
BlockPos
state
state:
BlockState
Methods
clearWrites()
clearWrites():
void
Defined in: world/TestFeatureWorld.ts:202
Forgets the recorded write log, leaving the blocks in place.
Returns
void
count()
count(
name):number
Defined in: world/TestFeatureWorld.ts:184
Counts the stored positions holding a given identifier.
Parameters
name
string
Returns
number
fill()
fill(
from,to,state):this
Defined in: world/TestFeatureWorld.ts:163
Fills an inclusive box with one state, without recording the writes.
Parameters
from
to
state
Returns
this
fillGround()
fillGround(
topY,state,radius?,center?):this
Defined in: world/TestFeatureWorld.ts:175
Fills every column from minY up to and including topY with one state.
Parameters
topY
number
state
radius?
number = 32
center?
BlockPos = ...
Returns
this
getBiome()
getBiome(
position):string
Defined in: world/TestFeatureWorld.ts:153
Returns the biome identifier at a position.
Parameters
position
Returns
string
Implementation of
getBlock()
getBlock(
position):BlockState
Defined in: world/TestFeatureWorld.ts:131
Returns the state at a position, or air outside the generated region.
Parameters
position
Returns
Implementation of
getHeight()
getHeight(
heightmap,x,z):number
Defined in: world/TestFeatureWorld.ts:144
Returns the first y above the topmost block matching the heightmap's predicate.
Parameters
heightmap
x
number
z
number
Returns
number
Implementation of
positionsOf()
positionsOf(
name):BlockPos[]
Defined in: world/TestFeatureWorld.ts:191
Returns every stored position holding a given identifier, in insertion order.
Parameters
name
string
Returns
BlockPos[]
setBiome()
setBiome(
position,biome):void
Defined in: world/TestFeatureWorld.ts:158
Overrides the biome at one position.
Parameters
position
biome
string
Returns
void
setBlock()
setBlock(
position,state):boolean
Defined in: world/TestFeatureWorld.ts:136
Writes a state. Returns whether the write landed.
Parameters
position
state
Returns
boolean