Skip to content

API reference / @jsprismarine/prismarine / world/providers/Provider

world/providers/Provider ​

Interfaces ​

LevelDatInputs ​

Defined in: packages/prismarine/src/world/providers/Provider.ts:18

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

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

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

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

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

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>>

Defined in: packages/prismarine/src/world/providers/Provider.ts:29

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

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

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 ​

Properties ​

supportsChunkUnload? ​

readonly optional supportsChunkUnload?: boolean

Defined in: packages/prismarine/src/world/providers/Provider.ts:63

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

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

Disable the service.

Returns ​

Promise<void>

A promise that resolves when the service is disabled.

Inherited from ​

Service.disable

enable() ​

abstract enable(): Promise<void>

Defined in: packages/prismarine/src/utils/Service.ts:6

Enable the service.

Returns ​

Promise<void>

A promise that resolves when the service is enabled.

Inherited from ​

Service.enable

getPath() ​

getPath(): string

Defined in: packages/prismarine/src/world/providers/Provider.ts:79

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

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

Parameters ​
dimension ​

DimensionType

Returns ​

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

migrateLegacyWorldData() ​

migrateLegacyWorldData(data): Promise<void>

Defined in: packages/prismarine/src/world/providers/Provider.ts:123

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

Parameters ​
data ​

WorldPersistenceData

Returns ​

Promise<void>

readChunk() ​

readChunk(dimension, cx, cz, seed, generator, config?, options?): Promise<Chunk>

Defined in: packages/prismarine/src/world/providers/Provider.ts:91

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

Parameters ​
dimension ​

DimensionType

the dimension the chunk belongs to.

cx ​

number

chunk x.

cz ​

number

chunk z.

seed ​

bigint

world seed.

generator ​

Generator

chunk generator.

config? ​

Partial<WorldData>

config object.

options? ​

ChunkRequestOptions

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

Returns ​

Promise<Chunk>

readLevelData()? ​

optional readLevelData(): LevelDatInputs | null

Defined in: packages/prismarine/src/world/providers/Provider.ts:133

Reads back the level metadata Provider.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.

Returns ​

LevelDatInputs | null

readPlayerData()? ​

optional readPlayerData(key): Promise<Partial<WorldPlayerData> | null>

Defined in: packages/prismarine/src/world/providers/Provider.ts:136

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

Parameters ​
key ​

string

Returns ​

Promise<Partial<WorldPlayerData> | null>

readWorldData() ​

readWorldData(): Promise<WorldPersistenceData | null>

Defined in: packages/prismarine/src/world/providers/Provider.ts:117

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

Returns ​

Promise<WorldPersistenceData | null>

restoreReplaySnapshot()? ​

optional restoreReplaySnapshot(snapshot): Promise<void>

Defined in: packages/prismarine/src/world/providers/Provider.ts:74

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

Parameters ​
snapshot ​

Uint8Array

Bytes returned by Provider.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

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

Parameters ​
level ​

LevelDatInputs

Returns ​

void

storedChunks()? ​

optional storedChunks(dimension): StoredChunkReader

Defined in: packages/prismarine/src/world/providers/Provider.ts:111

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

Parameters ​
dimension ​

DimensionType

Returns ​

StoredChunkReader

writeChunk() ​

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

Defined in: packages/prismarine/src/world/providers/Provider.ts:105

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

Parameters ​
chunk ​

Chunk

the chunk to write.

saveContext? ​

ChunkSaveContext

Returns ​

Promise<void>

writePlayerData()? ​

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

Defined in: packages/prismarine/src/world/providers/Provider.ts:139

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

Parameters ​
key ​

string

data ​

WorldPlayerData

Returns ​

Promise<void>

writeWorldData() ​

writeWorldData(data): Promise<void>

Defined in: packages/prismarine/src/world/providers/Provider.ts:120

Writes world state outside the chunk records.

Parameters ​
data ​

WorldPersistenceData

Returns ​

Promise<void>


StoredChunkReader ​

Defined in: packages/prismarine/src/world/providers/Provider.ts:48

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 | undefined

Defined in: packages/prismarine/src/world/providers/Provider.ts:50

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 | undefined

terrainAt() ​

terrainAt(chunkX, chunkZ): Chunk | undefined

Defined in: packages/prismarine/src/world/providers/Provider.ts:52

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

Parameters ​
chunkX ​

number

chunkZ ​

number

Returns ​

Chunk | undefined