Skip to content

API reference / @jsprismarine/prismarine / GenerationRegion

Class: GenerationRegion ​

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:285

A rectangular chunk window of Java block states.

States are held as indices into a per-region palette, so the buffer is two bytes a block rather than one object reference. surfaceChunk and featureWorld project the two seams the generation stages read it through; the two interfaces spell getBlock differently, so neither is implemented on the class itself.

Constructors ​

Constructor ​

new GenerationRegion(options): GenerationRegion

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:336

Parameters ​

options ​

GenerationRegionOptions

Returns ​

GenerationRegion

Properties ​

maxY ​

readonly maxY: number

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:289

The highest y the region holds.


minY ​

readonly minY: number

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:287

The lowest y the region holds.

Methods ​

applyPatch() ​

applyPatch(patch, options?): void

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:828

Applies a feature pass's writes to this region.

Parameters ​

patch ​

RegionChunkPatch

The writes, this chunk's own or a neighbor's.

options? ​

ApplyPatchOptions = {}

What to leave alone. A write, a block entity or its removal at a kept position is dropped; an entity spawn is kept, because it stands in the world rather than in a block.

Returns ​

void


beginWriteTracking() ​

beginWriteTracking(): void

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:679

Starts collecting decoration writes so neighboring chunks can receive their share.

Returns ​

void


biomeSection() ​

biomeSection(index): number | Uint16Array<ArrayBuffer> | undefined

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:546

One section's biome IDs, either a uniform id or its packed 16³ blocks.

Parameters ​

index ​

number

Returns ​

number | Uint16Array<ArrayBuffer> | undefined


blockAt() ​

blockAt(x, y, z): RegionBlock

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:564

The palette entry at a block position, air outside the region.

Parameters ​

x ​

number

y ​

number

z ​

number

Returns ​

RegionBlock


centerBlockEntities() ​

centerBlockEntities(): readonly RegionBlockEntity[]

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:966

The block entities attached inside the center chunk, which is the chunk that is kept.

Returns ​

readonly RegionBlockEntity[]


centerBlockSlots() ​

centerBlockSlots(): CenterBlockSlots

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:982

The center chunk's blocks as palette slots, for the translation pass.

A radius-0 region is already exactly the center chunk in exactly this layout, so it hands its own buffers over rather than copying them. They stay the region's, so a caller reads them and does not keep them.

Returns ​

CenterBlockSlots


centerEntitySpawns() ​

centerEntitySpawns(): readonly RegionEntitySpawn[]

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:971

The entities asked for inside the center chunk, in the order the features asked.

Returns ​

readonly RegionEntitySpawn[]


copyCenterFrom() ​

copyCenterFrom(source): void

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:753

Copies another tile's center terrain and frozen surface heights into this region.

Parameters ​

source ​

GenerationRegion

Returns ​

void


featureWorld() ​

featureWorld(): FeatureWorld

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:942

The seam @jsprismarine/features decorates through.

Returns ​

FeatureWorld


forEachCenterBlock() ​

forEachCenterBlock(visit): void

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:1002

Every non-air block the center chunk holds, for the translation pass.

Parameters ​

visit ​

(localX, y, localZ, block) => void

Returns ​

void


freezeSurfaceHeights() ​

freezeSurfaceHeights(): void

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:918

Freezes the WORLD_SURFACE_WG heightmap, which Java does once the terrain fill is done.

The surface pass reads it while writing into the same columns, so taking it live would let a column's new grass move the surface the next rule reads.

Returns ​

void


setBiomeSections() ​

setBiomeSections(sections): void

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:528

Stores the biome IDs computed for this chunk, ready for promotion or transfer.

Parameters ​

sections ​

PackedBiomeSections

Returns ​

void


spawnEntityAt() ​

spawnEntityAt(type, x, y, z, yaw, options?): void

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:1077

Records an entity at the position it stands on, which a structure template saves whole.

A template's entities sit between blocks: a cushion is saved at y 0.9375 and a villager in the middle of its block, so the coordinates are taken as given rather than snapped to the block the entity happens to be over.

Parameters ​

type ​

string

x ​

number

y ​

number

z ​

number

yaw ​

number

options? ​

Omit<EntitySpawnOptions, "yaw">

What the spawn carries beyond its yaw: an end crystal's beam target, its base plate flag and its invulnerability.

Returns ​

void


stateAt() ​

stateAt(x, y, z): BlockState

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:559

The state at a block position, air outside the region.

Parameters ​

x ​

number

y ​

number

z ​

number

Returns ​

BlockState


surfaceChunk() ​

surfaceChunk(): SurfaceChunk

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:924

The seam @jsprismarine/worldgen's surface pass writes through.

Returns ​

SurfaceChunk


takeTrackedPatches() ​

takeTrackedPatches(): readonly RegionChunkPatch[]

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:707

Returns the writes grouped by destination chunk, then stops tracking.

Returns ​

readonly RegionChunkPatch[]


transfer() ​

transfer(): GenerationRegionTransfer

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:424

Packs the region for postMessage and gives its buffers up.

The region is spent once this returns, whether or not the caller posts the payload: the buffers are already promised to the other side. What travels is the palette and three flat arrays, which is 18 microseconds for a column against 76 structured-cloned.

Returns ​

GenerationRegionTransfer

The payload and the buffers to pass as the transfer list.


withStructureWrites() ​

withStructureWrites<T>(place): T

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:696

Runs a structure piece's placement, marking what it writes as the structure's.

The marks ride along in the patches as RegionChunkPatch.structureBlocks. A later write at the same position by a feature of this pass takes the mark away again, because that feature saw the structure's block and Java would have let it through too.

Type Parameters ​

T ​

T

Parameters ​

place ​

() => T

Returns ​

T


workerInput() ​

workerInput(): GenerationRegionPayload

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:466

Describes this immutable terrain tile for a worker task without spending its buffers.

GenerationPool structured-clones task input before the worker sees it, so its copies cannot mutate this region. This is for the read-only terrain tiles a feature pass needs; callers that hand a tile away must use GenerationRegion.transfer instead.

Returns ​

GenerationRegionPayload

A payload view whose buffers remain owned by this region.


write() ​

write(x, y, z, state): boolean

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:586

Writes a state, ignoring a position outside the region. Returns whether it landed.

Parameters ​

x ​

number

y ​

number

z ​

number

state ​

BlockState

Returns ​

boolean


writeBedrock() ​

writeBedrock(x, y, z, state): boolean

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:670

Writes a block a structure template resolved, which is already a Bedrock state.

The Java view the region keeps beside it is the Bedrock identifier with no properties. That only decides what a later feature reads back at the position, and the two editions agree on the identifier for every block a vanilla template places; the chunk gets the exact Bedrock state.

Parameters ​

x ​

number

y ​

number

z ​

number

state ​

BedrockBlockState

Returns ​

boolean


writeName() ​

writeName(x, y, z, name): boolean

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:595

Writes a name-only state without allocating a BlockState for terrain samples.

Parameters ​

x ​

number

y ​

number

z ​

number

name ​

string

Returns ​

boolean


adopt() ​

static adopt(payload, options): GenerationRegion

Defined in: prismarine/src/world/generators/datadriven/GenerationRegion.ts:494

Rebuilds a region from a payload that arrived on this thread, without copying a buffer.

The palette index is rebuilt rather than carried, because it is a Map and a Map is cheaper to rebuild from a few hundred entries than to clone.

Parameters ​

payload ​

GenerationRegionPayload

What GenerationRegion.transfer produced.

options ​

Omit<GenerationRegionOptions, "chunkX" | "chunkZ" | "minY" | "height" | "radius">

The things that cannot travel: the block oracle, the biome lookup, the sea level, the seed and the template source. The geometry comes from the payload.

Returns ​

GenerationRegion

A region owning the payload's bytes. The payload is spent.