[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/prismarine](https://jsprismarine.dev/api/@jsprismarine/prismarine/index.md) / world/providers/ChunkSaveContext

# world/providers/ChunkSaveContext

## Interfaces

### ChunkSaveContext

Defined in: [packages/prismarine/src/world/providers/ChunkSaveContext.ts:8](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/ChunkSaveContext.ts#L8)

Entity and actor indexes shared by every chunk write in one save or unload pass.

#### Properties

##### actorIdsInWorld

> `readonly` **actorIdsInWorld**: `Set`\<`bigint`\>

Defined in: [packages/prismarine/src/world/providers/ChunkSaveContext.ts:16](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/ChunkSaveContext.ts#L16)

Persistent actor ids in the dimension; providers add ids allocated during this pass.

##### dimensionId

> `readonly` **dimensionId**: `number`

Defined in: [packages/prismarine/src/world/providers/ChunkSaveContext.ts:10](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/ChunkSaveContext.ts#L10)

Bedrock dimension id these entities belong to.

##### entitiesByChunk

> `readonly` **entitiesByChunk**: `ReadonlyMap`\<`number`, readonly [`StoreActor`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/data/storeActors/classes/StoreActor.md)[]\>

Defined in: [packages/prismarine/src/world/providers/ChunkSaveContext.ts:12](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/ChunkSaveContext.ts#L12)

Non-player entities in each chunk, in ascending runtime id order.

##### firstEntityByActorId

> `readonly` **firstEntityByActorId**: `ReadonlyMap`\<`bigint`, [`StoreActor`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/data/storeActors/classes/StoreActor.md)\>

Defined in: [packages/prismarine/src/world/providers/ChunkSaveContext.ts:18](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/ChunkSaveContext.ts#L18)

The persistent entity with the lowest runtime id for each existing actor id.

##### pendingTicks?

> `readonly` `optional` **pendingTicks?**: [`PendingTicksToSave`](#pendingtickstosave)

Defined in: [packages/prismarine/src/world/providers/ChunkSaveContext.ts:24](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/ChunkSaveContext.ts#L24)

The block and fluid ticks still scheduled in each chunk, by `Chunk.packXZ` index, and
the world tick they are due against. Absent when the caller does not track them, which leaves
what a chunk was saved with alone; present, a chunk missing from the map has none.

##### persistentEntitiesByChunk

> `readonly` **persistentEntitiesByChunk**: `ReadonlyMap`\<`number`, readonly [`StoreActor`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/data/storeActors/classes/StoreActor.md)[]\>

Defined in: [packages/prismarine/src/world/providers/ChunkSaveContext.ts:14](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/ChunkSaveContext.ts#L14)

Persistent non-player entities in each chunk, in ascending runtime id order.

***

### PendingTicksToSave

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

A world's scheduled ticks, grouped for a save.

#### Properties

##### byChunk

> `readonly` **byChunk**: `ReadonlyMap`\<`number`, readonly [`TickToSave`](#ticktosave)[]\>

Defined in: [packages/prismarine/src/world/providers/ChunkSaveContext.ts:44](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/ChunkSaveContext.ts#L44)

##### currentTick

> `readonly` **currentTick**: `number`

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

The world tick the save is made at, which a saved tick's due tick is read against.

***

### TickToSave

Defined in: [packages/prismarine/src/world/providers/ChunkSaveContext.ts:28](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/ChunkSaveContext.ts#L28)

One scheduled tick as a save writes it.

#### Properties

##### kind

> `readonly` **kind**: [`TickKind`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#tickkind)

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

Which of the world's tick lists it is on.

##### triggerTick

> `readonly` **triggerTick**: `number`

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

The absolute world tick it is due on.

##### type

> `readonly` **type**: `string`

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

The block or fluid it was scheduled for.

##### x

> `readonly` **x**: `number`

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

##### y

> `readonly` **y**: `number`

Defined in: [packages/prismarine/src/world/providers/ChunkSaveContext.ts:30](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/ChunkSaveContext.ts#L30)

##### z

> `readonly` **z**: `number`

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

## Functions

### createChunkSaveContext()

> **createChunkSaveContext**(`dimensionId`, `entities`, `chunkIndexOf`, `pendingTicks?`): [`ChunkSaveContext`](#chunksavecontext)

Defined in: [packages/prismarine/src/world/providers/ChunkSaveContext.ts:56](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/ChunkSaveContext.ts#L56)

Builds the indexes a provider needs without revisiting the world's entity list per chunk.

The entities may come in any order. What the indexes hold is put in ascending runtime id order,
so a chunk saves its entities in the same order whatever order the world keeps them in.

#### Parameters

##### dimensionId

`number`

##### entities

`Iterable`\<[`StoreActor`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/data/storeActors/classes/StoreActor.md)\>

##### chunkIndexOf

(`entity`) => `number`

##### pendingTicks?

[`PendingTicksToSave`](#pendingtickstosave)

The world's scheduled block and fluid ticks, when it tracks them; see
  [ChunkSaveContext.pendingTicks](#pendingticks).

#### Returns

[`ChunkSaveContext`](#chunksavecontext)
