Skip to content

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? ​

TestFeatureWorldOptions = {}

Returns ​

TestFeatureWorld

Properties ​

blocks ​

readonly blocks: BlockOracle

Defined in: world/TestFeatureWorld.ts:113

The static block facts, shared across worlds.

Implementation of ​

FeatureWorld.blocks


height ​

readonly height: number

Defined in: world/TestFeatureWorld.ts:107

The number of y levels the dimension generates, Java's getHeight().

Implementation of ​

FeatureWorld.height


minY ​

readonly minY: number

Defined in: world/TestFeatureWorld.ts:105

The lowest y the dimension generates, Java's getMinY().

Implementation of ​

FeatureWorld.minY


seaLevel ​

readonly seaLevel: number

Defined in: world/TestFeatureWorld.ts:109

The dimension's sea level, which relative_to_sea_level anchors resolve against.

Implementation of ​

FeatureWorld.seaLevel


seed ​

readonly seed: 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 ​

FeatureWorld.seed


writes ​

readonly writes: 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 ​

BlockPos

to ​

BlockPos

state ​

BlockState

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 ​

BlockState

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 ​

BlockPos

Returns ​

string

Implementation of ​

FeatureWorld.getBiome


getBlock() ​

getBlock(position): BlockState

Defined in: world/TestFeatureWorld.ts:131

Returns the state at a position, or air outside the generated region.

Parameters ​

position ​

BlockPos

Returns ​

BlockState

Implementation of ​

FeatureWorld.getBlock


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 ​

HeightmapType

x ​

number

z ​

number

Returns ​

number

Implementation of ​

FeatureWorld.getHeight


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 ​

BlockPos

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 ​

BlockPos

state ​

BlockState

Returns ​

boolean

Implementation of ​

FeatureWorld.setBlock