Skip to content

API reference / @jsprismarine/prismarine / world/Generator

world/Generator ​

Classes ​

Interfaces ​

BiomeSearchRequest ​

Defined in: packages/prismarine/src/world/Generator.ts:90

What a biome search asks a generator; see Generator.locateBiome.

Properties ​

horizontalStep ​

readonly horizontalStep: number

Defined in: packages/prismarine/src/world/Generator.ts:98

Blocks between two columns of the sampling grid; Java's 32.

radius ​

readonly radius: number

Defined in: packages/prismarine/src/world/Generator.ts:96

How far out to look, in blocks, as a square around the origin. Java's /locate biome uses 6400.

seed? ​

readonly optional seed?: bigint

Defined in: packages/prismarine/src/world/Generator.ts:103

verticalStep ​

readonly verticalStep: number

Defined in: packages/prismarine/src/world/Generator.ts:100

Blocks between two samples of a column; Java's 64.

wanted ​

readonly wanted: (biome) => boolean

Defined in: packages/prismarine/src/world/Generator.ts:102

Whether a biome identifier is one the caller wants, so a tag costs the same as one biome.

Parameters ​
biome ​

string

Returns ​

boolean

x ​

readonly x: number

Defined in: packages/prismarine/src/world/Generator.ts:92

Where to search from, in blocks.

y ​

readonly y: number

Defined in: packages/prismarine/src/world/Generator.ts:93

z ​

readonly z: number

Defined in: packages/prismarine/src/world/Generator.ts:94


BiomeSearchResult ​

Defined in: packages/prismarine/src/world/Generator.ts:107

Where a biome search found a cell; see Generator.locateBiome.

Properties ​

biome ​

readonly biome: string

Defined in: packages/prismarine/src/world/Generator.ts:109

The biome identifier, for example minecraft:plains.

x ​

readonly x: number

Defined in: packages/prismarine/src/world/Generator.ts:111

The sampled position, in blocks.

y ​

readonly y: number

Defined in: packages/prismarine/src/world/Generator.ts:112

z ​

readonly z: number

Defined in: packages/prismarine/src/world/Generator.ts:113


ChunkRequestOptions ​

Defined in: packages/prismarine/src/world/Generator.ts:148

How a chunk request is scheduled against every other outstanding one.

Properties ​

urgency? ​

readonly optional urgency?: "immediate" | "soon" | "idle"

Defined in: packages/prismarine/src/world/Generator.ts:155

How badly the chunk is wanted, which decides its turn when the generator is busy.

Defaults to immediate, so a caller that has not thought about it waits the way it always did. See GenerationPriority.


GenerationControl ​

Defined in: packages/prismarine/src/world/Generator.ts:120

What a benchmark and the generation governor may do to a generator's worker pools.

Methods ​

cancelQueued() ​

cancelQueued(matching?): number

Defined in: packages/prismarine/src/world/Generator.ts:131

Drops the tasks still waiting for a worker that a rule picks out, or all of them without one, and reports how many went. Dropping a task a player's chunk depends on leaves that chunk waiting, so a benchmark names its own region.

Parameters ​
matching? ​

(task) => boolean

Returns ​

number

outstanding() ​

outstanding(): number

Defined in: packages/prismarine/src/world/Generator.ts:133

How many tasks are with a worker or waiting for one, across every pool.

Returns ​

number

resetStats() ​

resetStats(): void

Defined in: packages/prismarine/src/world/Generator.ts:137

Forgets the recorded task stats.

Returns ​

void

setBackgroundLimit() ​

setBackgroundLimit(limit): void

Defined in: packages/prismarine/src/world/Generator.ts:125

Limits how many soon and idle tasks may be with workers at once. immediate tasks are never limited. Undefined removes the limit.

Parameters ​
limit ​

number | undefined

Returns ​

void

stats() ​

stats(): GenerationStatsSnapshot

Defined in: packages/prismarine/src/world/Generator.ts:135

Every pool's recorded task stats, merged.

Returns ​

GenerationStatsSnapshot


Generator ​

Defined in: packages/prismarine/src/world/Generator.ts:158

Properties ​

generatesInline? ​

readonly optional generatesInline?: boolean

Defined in: packages/prismarine/src/world/Generator.ts:211

True when the generator builds every chunk on the calling thread from a fixed, small amount of work, such as stacking a flat world's layers, with no worker pool behind it.

The chunk scheduler holds deliveries that need generation to twice the worker count, so a pool is never handed more requests than it can start. A chunk that needs no worker does not wait for that depth; the scheduler bounds those by the count one input step admits instead. Optional, and false when absent, which is right for any generator that samples noise.

seaLevel? ​

readonly optional seaLevel?: number

Defined in: packages/prismarine/src/world/Generator.ts:222

The y this generator floods to, Java's ChunkGenerator.getSeaLevel.

A noise generator answers its settings' sea_level; the flat generator answers Java's -63. Optional, because a generator with no water line of its own has nothing to say and the world then assumes the Overworld's 63, which is what Java's debug generator answers.

Java See ​

ChunkGenerator.getSeaLevel

Methods ​

biomeAt()? ​

optional biomeAt(x, y, z, seed?): string | undefined

Defined in: packages/prismarine/src/world/Generator.ts:289

The biome at a block as Java's ServerLevel.getBiome answers it, read from the noise rather than a chunk: the dimension's biome cells with BiomeManager's jitter.

Parameters ​
x ​

number

y ​

number

z ​

number

seed? ​

bigint

Returns ​

string | undefined

Java See ​

LevelReader.getBiome

generateChunk() ​

generateChunk(cx, cz, seed?, config?, options?): Promise<Chunk>

Defined in: packages/prismarine/src/world/Generator.ts:165

This function should return the generated chunk by given parameters.

Parameters ​
cx ​

number

cz ​

number

seed? ​

bigint

config? ​

Partial<WorldData>

options? ​

ChunkRequestOptions

How the request is scheduled. A generator that answers one at a time may ignore it; a pooled one orders its backlog by it.

Returns ​

Promise<Chunk>

generationControl()? ​

optional generationControl(): GenerationControl | undefined

Defined in: packages/prismarine/src/world/Generator.ts:250

A handle on the generator's worker pools, for measurement.

Optional, because a generator with no pool has nothing to hold back or count. The handle does not change what is generated: pausing only delays when a queued task reaches a worker.

Returns ​

GenerationControl | undefined

The handle, or undefined when no pool is running.

locatableNames()? ​

optional locatableNames(kind): readonly string[]

Defined in: packages/prismarine/src/world/Generator.ts:327

Every identifier and #tag a /locate of one kind may name, for its suggestions.

Registry-wide rather than per dimension, as Java's suggestions are: a Nether player is offered minecraft:village_plains and told it is not nearby.

Optional, because a generator without Java's registries has nothing to suggest beyond Mojang's published list.

Parameters ​
kind ​

"biome" | "structure"

Returns ​

readonly string[]

locate()? ​

optional locate(request): StructureSearchResult | undefined

Defined in: packages/prismarine/src/world/Generator.ts:268

The nearest structure a search accepts, without generating anything.

This is what /locate asks. A structure's position is a function of the seed and the placement grid alone, so the answer comes from laying candidates out against the bare noise terrain: no chunk is built, nothing is written, and a search over thousands of blocks costs a few hundred layout attempts rather than thousands of chunks.

Synchronous, like Generator.surfaceAt and for the same reason: the command layer that asks is synchronous, and the work is arithmetic rather than a chunk.

Optional, because a generator that places no structures has nothing to find.

Parameters ​
request ​

StructureSearchRequest

Where to search from, how far, and which structures count.

Returns ​

StructureSearchResult | undefined

The nearest match, or undefined when the radius held none.

locateBiome()? ​

optional locateBiome(request): BiomeSearchResult | undefined

Defined in: packages/prismarine/src/world/Generator.ts:305

The nearest cell of a biome a search accepts, without generating anything.

This is what /locate biome asks: Java's BiomeSource.findClosestBiome3d, a grid laid over the climate sampler and walked outward from the origin. Synchronous for the same reason Generator.locate is.

Optional, because a generator with no biome source of its own has nothing to walk.

Parameters ​
request ​

BiomeSearchRequest

Returns ​

BiomeSearchResult | undefined

The first grid cell met that holds a wanted biome, or undefined when the radius held none or no wanted biome can occur in this dimension.

Java See ​

BiomeSource.findClosestBiome3d

membersOfTag()? ​

optional membersOfTag(registry, tag): ReadonlySet<string> | undefined

Defined in: packages/prismarine/src/world/Generator.ts:316

The identifiers a #tag of one registry names, which is how /locate structure #minecraft:village and an eye of ender's #minecraft:eye_of_ender_located are read.

Optional, because only a generator built from Java's data carries its tags.

Parameters ​
registry ​

LocateTagRegistry

tag ​

string

The tag's identifier without the #, for example minecraft:village.

Returns ​

ReadonlySet<string> | undefined

The members, or undefined when the generator knows no tag by that name.

raiseUrgency()? ​

optional raiseUrgency(cx, cz, urgency): void

Defined in: packages/prismarine/src/world/Generator.ts:240

Says that a chunk already asked for is wanted more than it was.

A chunk is requested once and waited on by everybody who wants it, so the band it was given is whoever asked first. A rim chunk queued as idle is the chunk a player is standing on a moment later, and nothing else would move it up.

Only affects a request still waiting for a worker. One already being built finishes at the speed it was going to finish at either way.

Optional, because a generator with no queue has no turn to move.

Parameters ​
cx ​

number

Chunk x of the request.

cz ​

number

Chunk z of the request.

urgency ​

"immediate" | "soon" | "idle"

The band to move it into. Never lowers one.

Returns ​

void

spawnChunk()? ​

optional spawnChunk(seed?): SpawnChunkResult

Defined in: packages/prismarine/src/world/Generator.ts:200

Selects the spawn chunk from the generator's climate targets without sampling terrain columns. The world resolves a safe block position from that chunk after it is generated.

Parameters ​
seed? ​

bigint

Returns ​

SpawnChunkResult

stopGenerating()? ​

optional stopGenerating(): void

Defined in: packages/prismarine/src/world/Generator.ts:354

Gives up every chunk request that has not started yet, for a server that is shutting down.

A generator that answers one request at a time holds a queue, and a start region fills that queue thirty-two chunks at a time. Waiting for it to drain means a shutdown spends seconds generating terrain that the save it is about to run will not even look at. The request that is already running finishes, so no half-generated chunk is handed back; everything behind it rejects with GenerationStopped.

Optional, because a generator that answers immediately has no queue to give up.

Returns ​

void

structureSpawnOverrideAt()? ​

optional structureSpawnOverrideAt(identifier, at, seed?): boolean | undefined

Defined in: packages/prismarine/src/world/Generator.ts:341

Whether Java structure spawn overrides reserve an entity type at one position.

Generators without Java structure data omit the query. A generator with Java data returns undefined for an entity that also appears in Java's biome spawn tables or has no structure override. Structure-only entities return false outside matching overrides and true inside one.

Parameters ​
identifier ​

string

The Bedrock entity identifier used by the live spawner.

at ​

GeneratorPosition

The entity's candidate spawn position in blocks.

seed? ​

bigint

The world seed used to lay out structures.

Returns ​

boolean | undefined

structureStartsContaining()? ​

optional structureStartsContaining(at, seed?): readonly object[]

Defined in: packages/prismarine/src/world/Generator.ts:278

The structure starts with a piece that holds a block, by structure and start chunk, which is Java's StructureManager.getStructureAt. Like Generator.locate it reads the layout rather than a chunk.

Parameters ​
at ​

The block.

x ​

number

y ​

number

z ​

number

seed? ​

bigint

Returns ​

readonly object[]

Java Source ​

StructureManager.getStructureAt(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/levelgen/structure/Structure;)Lnet/minecraft/world/level/levelgen/structure/StructureStart;

surfaceAt()? ​

optional surfaceAt(x, z, seed?): SurfaceProbe

Defined in: packages/prismarine/src/world/Generator.ts:194

The topmost block of one column, without generating the chunk it is in.

The answer comes from the bare terrain: no surface rule has run and nothing has decorated, so a flooded column reads as water and a wooded one reads as the ground under the trees rather than as a canopy. That is Java's ChunkGenerator.getBaseHeight, and it is what a spawn search wants - whether a player can stand here is a question about the land, and answering it by generating a finished chunk costs four orders of magnitude more.

Optional, because a generator with no cheaper answer than its own chunks has nothing to add here and a caller falls back to generating one.

Parameters ​
x ​

number

z ​

number

seed? ​

bigint

Returns ​

SurfaceProbe

Java See ​

ChunkGenerator.getBaseHeight

useStoredChunks()? ​

optional useStoredChunks(stored): void

Defined in: packages/prismarine/src/world/Generator.ts:178

Tells the generator which chunks its dimension's save already holds, so new terrain can blend toward the old ones the way Java's Blender does. The provider calls it before it asks for a chunk; a generator that does not blend ignores it.

Parameters ​
stored ​

StoredChunkReader

Returns ​

void


GeneratorPosition ​

Defined in: packages/prismarine/src/world/Generator.ts:141

A block position in a generator's world.

Properties ​

x ​

readonly x: number

Defined in: packages/prismarine/src/world/Generator.ts:142

y ​

readonly y: number

Defined in: packages/prismarine/src/world/Generator.ts:143

z ​

readonly z: number

Defined in: packages/prismarine/src/world/Generator.ts:144


SpawnChunkResult ​

Defined in: packages/prismarine/src/world/Generator.ts:35

The chunk selected by a noise generator's climate-based spawn search.

Properties ​

candidates ​

readonly candidates: number

Defined in: packages/prismarine/src/world/Generator.ts:39

Number of climate candidates evaluated, for profiling the search without timing assertions.

chunkX ​

readonly chunkX: number

Defined in: packages/prismarine/src/world/Generator.ts:36

chunkZ ​

readonly chunkZ: number

Defined in: packages/prismarine/src/world/Generator.ts:37


StructureSearchRequest ​

Defined in: packages/prismarine/src/world/Generator.ts:48

What a structure search was asked for.

The origin is in blocks because that is what a player's position is; the radius is in chunks because that is the unit a structure set is spaced in.

Properties ​

radius ​

readonly radius: number

Defined in: packages/prismarine/src/world/Generator.ts:58

How far out to look, in rings of placement regions, which is how Java's /locate and eye of ender count their radius of 100. A village set spaced 34 chunks apart is reached 3400 chunks out; a concentric ring placement such as the strongholds' is searched whole.

seed? ​

readonly optional seed?: bigint

Defined in: packages/prismarine/src/world/Generator.ts:68

skip? ​

readonly optional skip?: (structure, chunkX, chunkZ) => boolean

Defined in: packages/prismarine/src/world/Generator.ts:67

Whether to pass over a start the search would otherwise answer, by its structure and start chunk.

Parameters ​
structure ​

string

chunkX ​

number

chunkZ ​

number

Returns ​

boolean

wanted ​

readonly wanted: (structure) => boolean

Defined in: packages/prismarine/src/world/Generator.ts:65

Whether a structure identifier is one the caller wants.

A predicate so a caller naming a tag does not have to flatten it first, and so a search for "any village" costs the same as one for a single identifier.

Parameters ​
structure ​

string

Returns ​

boolean

x ​

readonly x: number

Defined in: packages/prismarine/src/world/Generator.ts:49

y? ​

readonly optional y?: number

Defined in: packages/prismarine/src/world/Generator.ts:51

The height searched from, which Java measures distances with. Defaults to 0.

z ​

readonly z: number

Defined in: packages/prismarine/src/world/Generator.ts:52


StructureSearchResult ​

Defined in: packages/prismarine/src/world/Generator.ts:72

Where a structure search found something.

Properties ​

origin ​

readonly origin: object

Defined in: packages/prismarine/src/world/Generator.ts:84

The generation point, where the structure's layout started and its biome was checked.

x ​

readonly x: number

y ​

readonly y: number

z ​

readonly z: number

startChunk? ​

readonly optional startChunk?: object

Defined in: packages/prismarine/src/world/Generator.ts:86

The chunk the structure starts in, which is what tells one start of a structure from another.

x ​

readonly x: number

z ​

readonly z: number

structure ​

readonly structure: string

Defined in: packages/prismarine/src/world/Generator.ts:74

The structure identifier, for example minecraft:village_plains.

x ​

readonly x: number

Defined in: packages/prismarine/src/world/Generator.ts:80

Java's locate position, in blocks: the start chunk's corner moved by the structure set's locate_offset. It is what /locate reports and what an eye of ender flies toward, and its y is the offset's own, 0 for every vanilla set, which Java prints as ~.

y ​

readonly y: number

Defined in: packages/prismarine/src/world/Generator.ts:81

z ​

readonly z: number

Defined in: packages/prismarine/src/world/Generator.ts:82

Type Aliases ​

LocateTagRegistry ​

LocateTagRegistry = "worldgen/structure" | "worldgen/biome"

Defined in: packages/prismarine/src/world/Generator.ts:117

The tag registries a /locate name may draw on; see Generator.membersOfTag.


SurfaceProbe ​

SurfaceProbe = { name: string; y: number; } | undefined

Defined in: packages/prismarine/src/world/Generator.ts:32

The topmost block of a column, as Generator.surfaceAt reports it.

Undefined when the column holds nothing at all, which is what an empty dimension answers everywhere and a generated one answers nowhere.