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

# world/providers/Provider

## Interfaces

### LevelDatInputs

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

What a provider writes into the save's level metadata, `level.dat` for the LevelDB format.

Every field is per save rather than per dimension: Bedrock keeps one spawn, one clock and one
`Generator` for the whole world. A field left out keeps whatever the file already holds.

#### Properties

##### currentTick?

> `readonly` `optional` **currentTick?**: `number`

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

The game clock in ticks, Bedrock's `currentTick`, which scheduled ticks count by.

##### experiments?

> `readonly` `optional` **experiments?**: readonly `"gametest"`[]

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

The experiments that are on, under `experiments`. Each one is written on and never off,
and a toggle this server does not implement keeps whatever the file holds.

##### javaDataVersion?

> `readonly` `optional` **javaDataVersion?**: `number`

Defined in: [packages/prismarine/src/world/providers/Provider.ts:36](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/Provider.ts#L36)

The data version of the Java release the level was last saved under, written as
`JSPrismarineJavaDataVersion`. A level refuses to open under an older release.

##### netherScale?

> `readonly` `optional` **netherScale?**: `number`

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

The Nether's `coordinate_scale`, written as `NetherScale`. Defaults to Java's 8.

##### spawn?

> `readonly` `optional` **spawn?**: `object`

Defined in: [packages/prismarine/src/world/providers/Provider.ts:20](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/Provider.ts#L20)

The world spawn, which Bedrock always places in the Overworld.

###### x

> **x**: `number`

###### y

> **y**: `number`

###### z

> **z**: `number`

##### stems?

> `readonly` `optional` **stems?**: `Readonly`\<`Record`\<`string`, [`LevelStem`](https://jsprismarine.dev/api/@jsprismarine/worldgen/index.md#levelstem)\>\>

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

The resolved level stems by Java dimension id. The `minecraft:overworld` stem decides
`Generator` (2 for a flat generator, 1 otherwise) and `FlatWorldLayers`.

##### time?

> `readonly` `optional` **time?**: `number`

Defined in: [packages/prismarine/src/world/providers/Provider.ts:22](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/Provider.ts#L22)

The time of day in ticks, Bedrock's `Time`, which stands still while the day cycle is off.

***

### Provider

Defined in: [packages/prismarine/src/world/providers/Provider.ts:61](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/Provider.ts#L61)

Where a save keeps its chunks, players and metadata.

One provider serves one save folder, and a Bedrock save holds every dimension in one database,
so the chunk calls name the dimension they address while the player and level calls do not.

#### Extends

- [`Service`](https://jsprismarine.dev/api/@jsprismarine/prismarine/utils/Service/classes/Service.md)

#### Properties

##### supportsChunkUnload?

> `readonly` `optional` **supportsChunkUnload?**: `boolean`

Defined in: [packages/prismarine/src/world/providers/Provider.ts:63](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/Provider.ts#L63)

True only when `writeChunk` persists terrain, block entities, and actors for later reload.

#### Methods

##### captureReplaySnapshot()?

> `optional` **captureReplaySnapshot**(): `Uint8Array`

Defined in: [packages/prismarine/src/world/providers/Provider.ts:66](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/Provider.ts#L66)

Captures the provider's persisted state for replay, or leaves replay snapshots unsupported.

###### Returns

`Uint8Array`

##### disable()

> `abstract` **disable**(): `Promise`\<`void`\>

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

Disable the service.

###### Returns

`Promise`\<`void`\>

A promise that resolves when the service is disabled.

###### Inherited from

[`Service`](https://jsprismarine.dev/api/@jsprismarine/prismarine/utils/Service/classes/Service.md).[`disable`](https://jsprismarine.dev/api/@jsprismarine/prismarine/utils/Service/classes/Service.md#disable)

##### enable()

> `abstract` **enable**(): `Promise`\<`void`\>

Defined in: [packages/prismarine/src/utils/Service.ts:6](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/utils/Service.ts#L6)

Enable the service.

###### Returns

`Promise`\<`void`\>

A promise that resolves when the service is enabled.

###### Inherited from

[`Service`](https://jsprismarine.dev/api/@jsprismarine/prismarine/utils/Service/classes/Service.md).[`enable`](https://jsprismarine.dev/api/@jsprismarine/prismarine/utils/Service/classes/Service.md#enable)

##### getPath()

> **getPath**(): `string`

Defined in: [packages/prismarine/src/world/providers/Provider.ts:79](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/Provider.ts#L79)

Returns the path to the world folder.

###### Returns

`string`

##### listChunks()?

> `optional` **listChunks**(`dimension`): `IterableIterator`\<\{ `x`: `number`; `z`: `number`; \}\>

Defined in: [packages/prismarine/src/world/providers/Provider.ts:114](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/Provider.ts#L114)

Every chunk coordinate the save holds for one dimension, when the format can list them.

###### Parameters

###### dimension

[`DimensionType`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/DimensionType/index.md#dimensiontype)

###### Returns

`IterableIterator`\<\{ `x`: `number`; `z`: `number`; \}\>

##### migrateLegacyWorldData()

> **migrateLegacyWorldData**(`data`): `Promise`\<`void`\>

Defined in: [packages/prismarine/src/world/providers/Provider.ts:123](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/Provider.ts#L123)

Imports the one-time world state written by older versions to `level.json`.

###### Parameters

###### data

[`WorldPersistenceData`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/WorldPersistence/index.md#worldpersistencedata)

###### Returns

`Promise`\<`void`\>

##### readChunk()

> **readChunk**(`dimension`, `cx`, `cz`, `seed`, `generator`, `config?`, `options?`): `Promise`\<[`Chunk`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/chunk/Chunk/classes/Chunk.md)\>

Defined in: [packages/prismarine/src/world/providers/Provider.ts:91](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/Provider.ts#L91)

Returns the chunk decoded from the provider, generating it when the save has none.

###### Parameters

###### dimension

[`DimensionType`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/DimensionType/index.md#dimensiontype)

the dimension the chunk belongs to.

###### cx

`number`

chunk x.

###### cz

`number`

chunk z.

###### seed

`bigint`

world seed.

###### generator

[`Generator`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/Generator/index.md#generator)

chunk generator.

###### config?

`Partial`\<[`WorldData`](https://jsprismarine.dev/api/@jsprismarine/prismarine/config/JsonConfigTypes/index.md#worlddata)\>

config object.

###### options?

[`ChunkRequestOptions`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/Generator/index.md#chunkrequestoptions)

how the request is scheduled, for a generator that queues.

###### Returns

`Promise`\<[`Chunk`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/chunk/Chunk/classes/Chunk.md)\>

##### readLevelData()?

> `optional` **readLevelData**(): [`LevelDatInputs`](#leveldatinputs) \| `null`

Defined in: [packages/prismarine/src/world/providers/Provider.ts:133](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/Provider.ts#L133)

Reads back the level metadata [Provider.saveLevelData](#saveleveldata) wrote, or null when the format
keeps none. The clock is the field the level needs from here: the spawn, the rules and the
stems reach it through [Provider.readWorldData](#readworlddata).

###### Returns

[`LevelDatInputs`](#leveldatinputs) \| `null`

##### readPlayerData()?

> `optional` **readPlayerData**(`key`): `Promise`\<`Partial`\<[`WorldPlayerData`](https://jsprismarine.dev/api/@jsprismarine/prismarine/config/JsonConfigTypes/index.md#worldplayerdata)\> \| `null`\>

Defined in: [packages/prismarine/src/world/providers/Provider.ts:136](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/Provider.ts#L136)

Reads player data from provider-specific storage, if the format supports it.

###### Parameters

###### key

`string`

###### Returns

`Promise`\<`Partial`\<[`WorldPlayerData`](https://jsprismarine.dev/api/@jsprismarine/prismarine/config/JsonConfigTypes/index.md#worldplayerdata)\> \| `null`\>

##### readWorldData()

> **readWorldData**(): `Promise`\<[`WorldPersistenceData`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/WorldPersistence/index.md#worldpersistencedata) \| `null`\>

Defined in: [packages/prismarine/src/world/providers/Provider.ts:117](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/Provider.ts#L117)

Reads world state outside the chunk records, or null when the provider has none.

###### Returns

`Promise`\<[`WorldPersistenceData`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/WorldPersistence/index.md#worldpersistencedata) \| `null`\>

##### restoreReplaySnapshot()?

> `optional` **restoreReplaySnapshot**(`snapshot`): `Promise`\<`void`\>

Defined in: [packages/prismarine/src/world/providers/Provider.ts:74](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/Provider.ts#L74)

Restores a provider snapshot before the provider is enabled and its worlds are loaded.

###### Parameters

###### snapshot

`Uint8Array`

Bytes returned by [Provider.captureReplaySnapshot](#capturereplaysnapshot).

###### Returns

`Promise`\<`void`\>

###### Throws

When the snapshot is invalid or this provider is already enabled.

##### saveLevelData()?

> `optional` **saveLevelData**(`level`): `void`

Defined in: [packages/prismarine/src/world/providers/Provider.ts:126](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/Provider.ts#L126)

Persists provider-specific level metadata: the spawn, the clock, the generator and its layers.

###### Parameters

###### level

[`LevelDatInputs`](#leveldatinputs)

###### Returns

`void`

##### storedChunks()?

> `optional` **storedChunks**(`dimension`): [`StoredChunkReader`](#storedchunkreader)

Defined in: [packages/prismarine/src/world/providers/Provider.ts:111](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/Provider.ts#L111)

The stored chunks of a dimension as the world blender reads them, when the format keeps a
generation stamp per chunk.

###### Parameters

###### dimension

[`DimensionType`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/DimensionType/index.md#dimensiontype)

###### Returns

[`StoredChunkReader`](#storedchunkreader)

##### writeChunk()

> **writeChunk**(`chunk`, `saveContext?`): `Promise`\<`void`\>

Defined in: [packages/prismarine/src/world/providers/Provider.ts:105](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/Provider.ts#L105)

Writes a chunk into the dimension `chunk.getDimension()` names.

###### Parameters

###### chunk

[`Chunk`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/chunk/Chunk/classes/Chunk.md)

the chunk to write.

###### saveContext?

[`ChunkSaveContext`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/providers/ChunkSaveContext/index.md#chunksavecontext)

###### Returns

`Promise`\<`void`\>

##### writePlayerData()?

> `optional` **writePlayerData**(`key`, `data`): `Promise`\<`void`\>

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

Writes player data to provider-specific storage, if the format supports it.

###### Parameters

###### key

`string`

###### data

[`WorldPlayerData`](https://jsprismarine.dev/api/@jsprismarine/prismarine/config/JsonConfigTypes/index.md#worldplayerdata)

###### Returns

`Promise`\<`void`\>

##### writeWorldData()

> **writeWorldData**(`data`): `Promise`\<`void`\>

Defined in: [packages/prismarine/src/world/providers/Provider.ts:120](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/Provider.ts#L120)

Writes world state outside the chunk records.

###### Parameters

###### data

[`WorldPersistenceData`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/WorldPersistence/index.md#worldpersistencedata)

###### Returns

`Promise`\<`void`\>

***

### StoredChunkReader

Defined in: [packages/prismarine/src/world/providers/Provider.ts:48](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/Provider.ts#L48)

A save's stored chunks of one dimension, as the world blender reads them: which are old
generation, and the blocks and biomes of the ones that are.

#### Methods

##### generationAt()

> **generationAt**(`chunkX`, `chunkZ`): [`ChunkGeneration`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/chunk/ChunkGeneration/index.md#chunkgeneration) \| `undefined`

Defined in: [packages/prismarine/src/world/providers/Provider.ts:50](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/Provider.ts#L50)

The stored chunk's stamp after Java's load rule, or undefined when the save does not hold it.

###### Parameters

###### chunkX

`number`

###### chunkZ

`number`

###### Returns

[`ChunkGeneration`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/chunk/ChunkGeneration/index.md#chunkgeneration) \| `undefined`

##### terrainAt()

> **terrainAt**(`chunkX`, `chunkZ`): [`Chunk`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/chunk/Chunk/classes/Chunk.md) \| `undefined`

Defined in: [packages/prismarine/src/world/providers/Provider.ts:52](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/providers/Provider.ts#L52)

The stored chunk's blocks and biomes, without block entities or actors, or undefined.

###### Parameters

###### chunkX

`number`

###### chunkZ

`number`

###### Returns

[`Chunk`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/chunk/Chunk/classes/Chunk.md) \| `undefined`
