[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/prismarine](https://jsprismarine.dev/api/@jsprismarine/prismarine/index.md) / world/generators/datadriven/mergedChunk

# world/generators/datadriven/mergedChunk

## Interfaces

### MergedChunkParts

Defined in: [packages/prismarine/src/world/generators/datadriven/mergedChunk.ts:41](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/mergedChunk.ts#L41)

What a merged chunk task hands back: everything the server thread builds the chunk from.

#### Properties

##### blockEntities

> `readonly` **blockEntities**: readonly [`RegionBlockEntity`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/generators/datadriven/GenerationRegion/index.md#regionblockentity)[]

Defined in: [packages/prismarine/src/world/generators/datadriven/mergedChunk.ts:45](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/mergedChunk.ts#L45)

The block entities the merge left in the chunk.

##### entitySpawns

> `readonly` **entitySpawns**: readonly [`RegionEntitySpawn`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/generators/datadriven/GenerationRegion/index.md#regionentityspawn)[]

Defined in: [packages/prismarine/src/world/generators/datadriven/mergedChunk.ts:47](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/mergedChunk.ts#L47)

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

##### fluidTicks

> `readonly` **fluidTicks**: readonly [`RegionFluidTick`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/generators/datadriven/GenerationRegion/index.md#regionfluidtick)[]

Defined in: [packages/prismarine/src/world/generators/datadriven/mergedChunk.ts:49](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/mergedChunk.ts#L49)

The fluid ticks and post-processing marks asked for inside the chunk, in the order they were asked for.

##### sections

> `readonly` **sections**: readonly [`BedrockSection`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/generators/datadriven/bedrockSections/index.md#bedrocksection)[]

Defined in: [packages/prismarine/src/world/generators/datadriven/mergedChunk.ts:43](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/mergedChunk.ts#L43)

The non-empty Bedrock sections.

***

### PaletteTranslation

Defined in: [packages/prismarine/src/world/generators/datadriven/mergedChunk.ts:29](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/mergedChunk.ts#L29)

The Bedrock form of every palette entry a merge can produce, keyed by [paletteKeyOf](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/generators/datadriven/GenerationRegion/index.md#palettekeyof).

#### Properties

##### air

> `readonly` **air**: `number`

Defined in: [packages/prismarine/src/world/generators/datadriven/mergedChunk.ts:37](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/mergedChunk.ts#L37)

Air's runtime id.

##### keys

> `readonly` **keys**: readonly `string`[]

Defined in: [packages/prismarine/src/world/generators/datadriven/mergedChunk.ts:31](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/mergedChunk.ts#L31)

The entries' palette keys.

##### runtimeIds

> `readonly` **runtimeIds**: `Int32Array`\<`ArrayBuffer`\>

Defined in: [packages/prismarine/src/world/generators/datadriven/mergedChunk.ts:33](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/mergedChunk.ts#L33)

The Bedrock runtime id of each key, already air where this server maps nothing.

##### water

> `readonly` **water**: `Uint8Array`\<`ArrayBuffer`\>

Defined in: [packages/prismarine/src/world/generators/datadriven/mergedChunk.ts:35](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/mergedChunk.ts#L35)

1 where the entry is a waterlogged Java state, which Bedrock keeps in storage layer 1.

## Functions

### isMergedChunkParts()

> **isMergedChunkParts**(`value`): `value is MergedChunkParts`

Defined in: [packages/prismarine/src/world/generators/datadriven/mergedChunk.ts:112](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/mergedChunk.ts#L112)

Whether a worker's answer to a merged chunk task has the parts a chunk is built from.

#### Parameters

##### value

`unknown`

#### Returns

`value is MergedChunkParts`

***

### isPaletteTranslation()

> **isPaletteTranslation**(`value`): `value is PaletteTranslation`

Defined in: [packages/prismarine/src/world/generators/datadriven/mergedChunk.ts:101](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/mergedChunk.ts#L101)

Whether a value that crossed a thread or process boundary is a translation table.

#### Parameters

##### value

`unknown`

#### Returns

`value is PaletteTranslation`

***

### mergeFeatureWrites()

> **mergeFeatureWrites**(`final`, `inputs`): `void`

Defined in: [packages/prismarine/src/world/generators/datadriven/mergedChunk.ts:139](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/mergedChunk.ts#L139)

Lays a chunk's own feature writes and its neighbors' patches over its terrain.

The patches go in as if the world decorated its chunks in one order, row by row from north to
south and west to east along a row, which `FEATURE_PATCH_ORDER` already follows: the
neighbors before the chunk, then its own writes, then the neighbors after it. Every chunk of a
border agrees on which of two overlapping trees grew second, so that tree's leaves win on both
sides, as one Java run leaves them. Merging every chunk's own writes first let each side's
neighbor win instead, and two canopies swapped halves across the border.

Each pass decorated against its neighbors' bare terrain, so a later write yields to a block an
earlier one placed unless a tree could grow through it; see
`ApplyPatchOptions.yieldToEarlierWrites`. A neighbor's ore vein or grass patch also chose its
blocks without seeing the structure pieces this chunk placed, so those pieces are kept, which
is the outcome Java reaches in either order.

#### Parameters

##### final

[`GenerationRegion`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/generators/datadriven/GenerationRegion/classes/GenerationRegion.md)

The chunk's terrain, which the writes land in.

##### inputs

`MergeInputs`

What the `full` body gathered.

#### Returns

`void`

***

### translatePalette()

> **translatePalette**(`blocks`, `translate`, `air`): [`PaletteTranslation`](#palettetranslation)

Defined in: [packages/prismarine/src/world/generators/datadriven/mergedChunk.ts:57](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/mergedChunk.ts#L57)

Builds the table for a set of palette entries, each translated once.

#### Parameters

##### blocks

`Iterable`\<[`RegionBlock`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/generators/datadriven/GenerationRegion/index.md#regionblock)\>

The entries a merge can produce, repeats allowed.

##### translate

(`block`) => `object`

The server thread's mapping of one entry.

##### air

`number`

#### Returns

[`PaletteTranslation`](#palettetranslation)

***

### translateSlots()

> **translateSlots**(`palette`, `translation`): `object`

Defined in: [packages/prismarine/src/world/generators/datadriven/mergedChunk.ts:83](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/mergedChunk.ts#L83)

Looks up each merged palette entry in the table, slot by slot.

#### Parameters

##### palette

readonly [`RegionBlock`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/generators/datadriven/GenerationRegion/index.md#regionblock)[]

##### translation

[`PaletteTranslation`](#palettetranslation)

#### Returns

`object`

##### runtimeIds

> `readonly` **runtimeIds**: `Int32Array`

##### waterSlots

> `readonly` **waterSlots**: `Uint8Array`

#### Throws

RangeError when an entry is missing, which means the table was built from other blocks
  than the merge read: a chunk built with it would hold air where the block belongs.
