API reference / @jsprismarine/prismarine / BaseProvider
Abstract Class: BaseProvider
Defined in: prismarine/src/world/providers/BaseProvider.ts:37
What the provider formats share: the folder, the server, the fallback world data file and the hooks the owning world or level attaches.
Implements
default
Constructors
Constructor
new BaseProvider(
path,server):BaseProvider
Defined in: prismarine/src/world/providers/BaseProvider.ts:62
Parameters
path
string
server
Returns
BaseProvider
Properties
supportsChunkUnload?
readonlyoptionalsupportsChunkUnload?:boolean
Defined in: prismarine/src/world/providers/BaseProvider.ts:45
True only when writeChunk persists terrain, block entities, and actors for later reload.
Implementation of
Provider.supportsChunkUnload
Methods
captureReplaySnapshot()?
optionalcaptureReplaySnapshot():Uint8Array
Defined in: prismarine/src/world/providers/BaseProvider.ts:48
Captures the provider's persisted state for replay, when the format supports replay.
Returns
Uint8Array
Implementation of
Provider.captureReplaySnapshot
getLevel()
getLevel():
SaveIdentity|undefined
Defined in: prismarine/src/world/providers/BaseProvider.ts:98
The save this provider serves, or undefined before BaseProvider.setLevel.
Returns
SaveIdentity | undefined
getPath()
getPath():
string
Defined in: prismarine/src/world/providers/BaseProvider.ts:145
Returns the path to the world folder.
Returns
string
Implementation of
Provider.getPath
getServer()
getServer():
Server
Defined in: prismarine/src/world/providers/BaseProvider.ts:138
Returns
getWorld()
getWorld():
World
Defined in: prismarine/src/world/providers/BaseProvider.ts:80
Returns
listChunks()?
optionallistChunks(dimension):IterableIterator<{x:number;z:number; }>
Defined in: prismarine/src/world/providers/BaseProvider.ts:54
Every chunk coordinate the save holds for one dimension, when the format can list them.
Parameters
dimension
Returns
IterableIterator<{ x: number; z: number; }>
Implementation of
Provider.listChunks
migrateLegacyWorldData()
migrateLegacyWorldData(
data):Promise<void>
Defined in: prismarine/src/world/providers/BaseProvider.ts:202
Moves legacy metadata into this provider, keeping provider data when both copies exist.
Parameters
data
WorldPersistenceData
Returns
Promise<void>
Implementation of
Provider.migrateLegacyWorldData
readChunk()
abstractreadChunk(dimension,cx,cz,seed,generator,config?,options?):Promise<Chunk>
Defined in: prismarine/src/world/providers/BaseProvider.ts:156
Returns a chunk decoded from the provider, generating it when the save has none.
Parameters
dimension
the dimension the chunk belongs to.
cx
number
the chunk x coordinate.
cz
number
the chunk z coordinate.
seed
bigint
generator
config?
Partial<WorldData>
options?
Returns
Promise<Chunk>
Implementation of
Provider.readChunk
readLevelData()
readLevelData():
LevelDatInputs|null
Defined in: prismarine/src/world/providers/BaseProvider.ts:215
Reads provider-specific level metadata back; null for a format that keeps none.
Returns
LevelDatInputs | null
Implementation of
Provider.readLevelData
readPlayerData()?
optionalreadPlayerData(key):Promise<Partial<WorldPlayerData> |null>
Defined in: prismarine/src/world/providers/BaseProvider.ts:57
Reads player data from provider-specific storage, when the format supports it.
Parameters
key
string
Returns
Promise<Partial<WorldPlayerData> | null>
Implementation of
Provider.readPlayerData
readWorldData()
readWorldData():
Promise<WorldPersistenceData|null>
Defined in: prismarine/src/world/providers/BaseProvider.ts:174
Reads world state from the provider's fallback NBT file.
Returns
Promise<WorldPersistenceData | null>
Implementation of
Provider.readWorldData
restoreReplaySnapshot()?
optionalrestoreReplaySnapshot(snapshot):Promise<void>
Defined in: prismarine/src/world/providers/BaseProvider.ts:51
Restores a snapshot from BaseProvider.captureReplaySnapshot before the provider is enabled.
Parameters
snapshot
Uint8Array
Returns
Promise<void>
Implementation of
Provider.restoreReplaySnapshot
saveLevelData()
saveLevelData(
_level):void
Defined in: prismarine/src/world/providers/BaseProvider.ts:212
Persists provider-specific level metadata when the format supports it.
Parameters
_level
LevelDatInputs
Returns
void
Implementation of
Provider.saveLevelData
setEntitySource()
setEntitySource(
source):void
Defined in: prismarine/src/world/providers/BaseProvider.ts:113
Attaches where a chunk write finds the entities of the chunk's dimension.
Parameters
source
EntitySource
Returns
void
setLevel()
setLevel(
level):void
Defined in: prismarine/src/world/providers/BaseProvider.ts:93
Attaches the level whose save this provider is, which is where the save's name and seed come from once a level owns it. A level has no world until one is asked for, so the metadata a format writes on open cannot wait for one.
The name and seed are all a format reads, so a caller that has to open the save before its level exists, as WorldManager does to read the stems the save was generated with, may attach just those two.
Parameters
level
SaveIdentity
Returns
void
setWorld()
setWorld(
world):void
Defined in: prismarine/src/world/providers/BaseProvider.ts:77
Attaches the world this provider logs and names the save after. Until an entity source is attached, that world's entities are also the ones a chunk write persists.
A provider that serves a Level is told about the level instead; see BaseProvider.setLevel.
Parameters
world
Returns
void
writeChunk()
abstractwriteChunk(chunk,saveContext?):Promise<void>
Defined in: prismarine/src/world/providers/BaseProvider.ts:171
Writes a chunk into the dimension chunk.getDimension() names.
Parameters
chunk
Chunk
the chunk data.
saveContext?
ChunkSaveContext
Returns
Promise<void>
Implementation of
Provider.writeChunk
writePlayerData()?
optionalwritePlayerData(key,data):Promise<void>
Defined in: prismarine/src/world/providers/BaseProvider.ts:60
Writes player data to provider-specific storage, when the format supports it.
Parameters
key
string
data
Returns
Promise<void>
Implementation of
Provider.writePlayerData
writeWorldData()
writeWorldData(
data):Promise<void>
Defined in: prismarine/src/world/providers/BaseProvider.ts:186
Writes world state as one provider-owned NBT compound.
Parameters
data
WorldPersistenceData
Returns
Promise<void>
Implementation of
Provider.writeWorldData
Lifecycle
disable()
disable():
Promise<void>
Defined in: prismarine/src/world/providers/BaseProvider.ts:136
On disable hook.
Returns
Promise<void>
Implementation of
Provider.disable
enable()
enable():
Promise<void>
Defined in: prismarine/src/world/providers/BaseProvider.ts:131
On enable hook.
Returns
Promise<void>
Implementation of
Provider.enable