API reference / @jsprismarine/prismarine / world/providers/SavePass
world/providers/SavePass
Interfaces
LevelRecords
Defined in: packages/prismarine/src/world/providers/SavePass.ts:16
The level-wide records a save keeps apart from level.dat and the world data record: the world's script dynamic properties and the scoreboard, in Bedrock's form, and the command storage, the maps and the structures explorer maps point at, which Bedrock has no record for.
Properties
commandStorage
readonlycommandStorage:SavedCommandStorage
Defined in: packages/prismarine/src/world/providers/SavePass.ts:19
dynamicProperties
readonlydynamicProperties:DynamicProperties
Defined in: packages/prismarine/src/world/providers/SavePass.ts:17
maps
readonlymaps:ReadonlyMap<number,SavedMap>
Defined in: packages/prismarine/src/world/providers/SavePass.ts:21
Every map the level made, by minecraft:map_id; see Level.createMap.
referencedStructures
readonlyreferencedStructures: readonlyStructureReference[]
Defined in: packages/prismarine/src/world/providers/SavePass.ts:23
The structure starts explorer maps point at, which a skipping search passes over.
scoreboard
readonlyscoreboard:SavedScoreboard
Defined in: packages/prismarine/src/world/providers/SavePass.ts:18
ProviderSavePass
Defined in: packages/prismarine/src/world/providers/SavePass.ts:60
One save pass's writes to a provider (ADR 0018).
The level takes the cut at one tick boundary: it hands every chunk that changed or holds entities, every player record and the level record to the pass in one synchronous run. The pass encodes what it can right away and holds back each chunk's changed sub chunks, which it encodes on ProviderSavePass.encode or first when a write is about to reach one. Once nothing is held back, ProviderSavePass.commit writes the pass as one atomic write where the provider can, and marks each chunk saved as it was at the cut.
Properties
pendingEncodes
readonlypendingEncodes:number
Defined in: packages/prismarine/src/world/providers/SavePass.ts:79
How many sub chunks are still to encode.
stats
readonlystats:SavePassStats
Defined in: packages/prismarine/src/world/providers/SavePass.ts:97
Methods
abandon()
abandon():
void
Defined in: packages/prismarine/src/world/providers/SavePass.ts:96
Lets go of every chunk without writing, so they stay dirty for the next pass, and hands the writes held for this pass to the next one.
Returns
void
commit()
commit(
options):Promise<void>
Defined in: packages/prismarine/src/world/providers/SavePass.ts:91
Writes the pass, once nothing is held back, with the writes held for it ahead of its own. A pass that holds nothing writes nothing.
Parameters
options
sync to have the write on disk, not only handed to the operating system.
sync
boolean
Returns
Promise<void>
Throws
When the write fails. Every chunk stays dirty, and the next pass writes it again.
cutChunk()
cutChunk(
chunk,context,fresh?):void
Defined in: packages/prismarine/src/world/providers/SavePass.ts:68
Plans a chunk's write as the chunk is now. The chunk then reports writes to the pass until the pass has encoded it.
Parameters
chunk
context
fresh?
readonly EntitySpawn[]
For a chunk generated since the last pass and untouched by gameplay (ADR 0018), the mobs its generation left: they are written as the chunk's pending record in place of actor records and a digest, which a chunk whose mobs are not live yet has none of.
Returns
void
encode()
encode(
budget):number
Defined in: packages/prismarine/src/world/providers/SavePass.ts:84
Encodes up to budget held-back sub chunks.
Parameters
budget
number
Returns
number
How many it encoded.
putLevelRecord()
putLevelRecord(
data):void
Defined in: packages/prismarine/src/world/providers/SavePass.ts:75
Holds the level record, merged over the one the save holds.
Parameters
data
Returns
void
putLevelRecords()
putLevelRecords(
records):void
Defined in: packages/prismarine/src/world/providers/SavePass.ts:77
Holds the level-wide records, in place of the ones the save holds.
Parameters
records
Returns
void
putPlayer()
putPlayer(
key,record):boolean
Defined in: packages/prismarine/src/world/providers/SavePass.ts:73
Holds a player record.
Parameters
key
string
record
Returns
boolean
False when the provider keeps no player records, and the level writes it elsewhere.
SavePassStats
Defined in: packages/prismarine/src/world/providers/SavePass.ts:27
What one save pass wrote, in keys and bytes; see ProviderSavePass.stats.
Properties
bypassedWrites
readonlybypassedWrites:number
Defined in: packages/prismarine/src/world/providers/SavePass.ts:47
Sub chunks that had changed when their turn came although no write told the cut, which means something wrote around the chunk and the pass saved a later tick's content.
Zero for TypeScript callers: a chunk hands out its sub chunks read-only. It stays as a check that costs one comparison per encode, because a plugin in plain JavaScript can still reach a sub chunk's own setBlock, and so can a generator that kept a sub chunk it handed to a chunk. The save pass tests assert it stays zero.
bytes
readonlybytes:number
Defined in: packages/prismarine/src/world/providers/SavePass.ts:31
The batch's approximate size, keys and values together.
forcedSubChunkEncodes
readonlyforcedSubChunkEncodes:number
Defined in: packages/prismarine/src/world/providers/SavePass.ts:37
Sub chunks a write made the pass encode before their turn.
heldWrites
readonlyheldWrites:number
Defined in: packages/prismarine/src/world/providers/SavePass.ts:33
Keys written outside a pass and held for this one, which it commits ahead of its own.
keys
readonlykeys:number
Defined in: packages/prismarine/src/world/providers/SavePass.ts:29
Keys put or deleted.
subChunkEncodes
readonlysubChunkEncodes:number
Defined in: packages/prismarine/src/world/providers/SavePass.ts:35
Sub chunks encoded after the cut, whether on the pass's own schedule or before a write.