API reference / @jsprismarine/prismarine / world/WorldPersistence
world/WorldPersistence
Interfaces
DragonFightState
Defined in: packages/prismarine/src/world/WorldPersistence.ts:72
The End's dragon fight, as the save stores it.
The fields mirror Java's minecraft:ender_dragon_fight SavedData: dragon_killed, previously_killed, needs_state_scanning, dragon_uuid, exit_portal_location, gateways, respawn_stage, respawn_time and respawn_crystals. The entity references are the data-driven runtime's persistent identities, the stable UUID an actor keeps across saves, because runtime ids are drawn fresh every boot.
Properties
dragonDeathPosition?
optionaldragonDeathPosition?:object
Defined in: packages/prismarine/src/world/WorldPersistence.ts:87
Where the dragon DragonFightState.dragonUniqueId names died, while its portal, gateway, egg and experience still wait for their chunks to load.
x
x:
number
y
y:
number
z
z:
number
dragonKilled
dragonKilled:
boolean
Defined in: packages/prismarine/src/world/WorldPersistence.ts:74
Whether the dragon is dead right now, so none should be spawned.
dragonUniqueId?
optionaldragonUniqueId?:string
Defined in: packages/prismarine/src/world/WorldPersistence.ts:80
The live dragon's persistent identity, when one has been spawned or adopted.
exitPortalLocation?
optionalexitPortalLocation?:object
Defined in: packages/prismarine/src/world/WorldPersistence.ts:82
Where the exit portal's podium stands, once found or placed.
x
x:
number
y
y:
number
z
z:
number
gateways
gateways:
number[]
Defined in: packages/prismarine/src/world/WorldPersistence.ts:89
The gateway indices not yet spent, seed-shuffled on first init and popped per kill.
needsStateScanning
needsStateScanning:
boolean
Defined in: packages/prismarine/src/world/WorldPersistence.ts:78
Whether the fight still has to scan the world for a podium and a dragon.
previouslyKilled
previouslyKilled:
boolean
Defined in: packages/prismarine/src/world/WorldPersistence.ts:76
Whether a dragon has ever been killed in this world, which gates the egg.
respawnCrystalIds
respawnCrystalIds:
string[]
Defined in: packages/prismarine/src/world/WorldPersistence.ts:95
The persistent identities of the four crystals driving a respawn in progress.
respawnStage?
optionalrespawnStage?:"start"|"preparing_to_summon_pillars"|"summoning_pillars"|"summoning_dragon"
Defined in: packages/prismarine/src/world/WorldPersistence.ts:91
The respawn phase in progress, or absent when no respawn sequence runs.
respawnTime
respawnTime:
number
Defined in: packages/prismarine/src/world/WorldPersistence.ts:93
Ticks spent in the current respawn phase.
LegacyWorldEntity
Defined in: packages/prismarine/src/world/WorldPersistence.ts:26
A non-player entity snapshot used by providers without actor storage.
Properties
position
position:
object
Defined in: packages/prismarine/src/world/WorldPersistence.ts:28
headYaw?
optionalheadYaw?:number
pitch?
optionalpitch?:number
x
x:
number
y
y:
number
yaw?
optionalyaw?:number
z
z:
number
type
type:
string
Defined in: packages/prismarine/src/world/WorldPersistence.ts:27
StructureReference
Defined in: packages/prismarine/src/world/WorldPersistence.ts:133
One structure start an explorer map points at: Java's StructureStart.references.
Java See
StructureStart.references
Properties
chunkX
readonlychunkX:number
Defined in: packages/prismarine/src/world/WorldPersistence.ts:138
The chunk the start is in.
chunkZ
readonlychunkZ:number
Defined in: packages/prismarine/src/world/WorldPersistence.ts:139
dimension
readonlydimension:string
Defined in: packages/prismarine/src/world/WorldPersistence.ts:135
The level's id for the dimension the start is in, such as minecraft:overworld.
structure
readonlystructure:string
Defined in: packages/prismarine/src/world/WorldPersistence.ts:136
WorldGenSettings
Defined in: packages/prismarine/src/world/WorldPersistence.ts:45
The generators a save was made with, in the shape of Java's world_gen_settings.dat.
Written once the stems are resolved and read back before they are resolved again, so a world keeps the terrain it was generated with when the config changes under it. The stems are stored as Java dimension documents, which is what parseLevelStem reads.
Properties
dimensions
readonlydimensions:Readonly<Record<string,LevelStem>>
Defined in: packages/prismarine/src/world/WorldPersistence.ts:49
The resolved stem of every dimension, by Java dimension id such as minecraft:the_nether.
seed
readonlyseed:string
Defined in: packages/prismarine/src/world/WorldPersistence.ts:47
The seed as a decimal string, since JSON cannot hold a 64-bit integer.
WorldPersistenceData
Defined in: packages/prismarine/src/world/WorldPersistence.ts:102
World state a provider stores outside the chunk data.
Properties
clockPaused?
optionalclockPaused?:boolean
Defined in: packages/prismarine/src/world/WorldPersistence.ts:123
Whether a script paused the overworld clock.
dimensionNumbers?
optionaldimensionNumbers?:Readonly<Record<string,SavedDimensionNumber>>
Defined in: packages/prismarine/src/world/WorldPersistence.ts:106
Each custom dimension's type and Bedrock number, by its UUID; see DimensionNumbers.
dragonFight?
optionaldragonFight?:DragonFightState
Defined in: packages/prismarine/src/world/WorldPersistence.ts:115
The End's dragon fight, present once a world with one has saved.
entities?
optionalentities?:LegacyWorldEntity[]
Defined in: packages/prismarine/src/world/WorldPersistence.ts:111
Used by providers that do not store actors in chunk data.
gameRules?
optionalgameRules?: [string, [number|boolean,boolean]][]
Defined in: packages/prismarine/src/world/WorldPersistence.ts:108
lastMapId?
optionallastMapId?:number
Defined in: packages/prismarine/src/world/WorldPersistence.ts:125
The last minecraft:map_id the level handed out; see Level.nextMapId.
levelId?
optionallevelId?:string
Defined in: packages/prismarine/src/world/WorldPersistence.ts:104
The level's UUID, its identity whatever it is named; see Level.id.
raids?
optionalraids?:RaidRecord[]
Defined in: packages/prismarine/src/world/WorldPersistence.ts:117
The village raids that were running, which carry on after a restart.
scriptSettings?
optionalscriptSettings?:SavedScriptSettings
Defined in: packages/prismarine/src/world/WorldPersistence.ts:121
What the scripts set on the world that nothing else keeps; see LevelScriptSettings.
spawn?
optionalspawn?:object
Defined in: packages/prismarine/src/world/WorldPersistence.ts:107
x
x:
number
y
y:
number
z
z:
number
tickingAreas?
optionaltickingAreas?:TickingArea[]
Defined in: packages/prismarine/src/world/WorldPersistence.ts:119
The ticking areas the command and the scripts added.
weather?
optionalweather?:WeatherState
Defined in: packages/prismarine/src/world/WorldPersistence.ts:109
worldGenSettings?
optionalworldGenSettings?:WorldGenSettings
Defined in: packages/prismarine/src/world/WorldPersistence.ts:113
The seed and stems the save was generated with.
Type Aliases
DragonRespawnStage
DragonRespawnStage = typeof
DRAGON_RESPAWN_STAGES[number]
Defined in: packages/prismarine/src/world/WorldPersistence.ts:61
One phase of the dragon respawn sequence.
SavedRaid
SavedRaid =
RaidRecord
Defined in: packages/prismarine/src/world/WorldPersistence.ts:99
One village raid as a save holds it: RaidRecord, which is plain data.
Variables
DRAGON_RESPAWN_STAGES
constDRAGON_RESPAWN_STAGES: readonly ["start","preparing_to_summon_pillars","summoning_pillars","summoning_dragon"]
Defined in: packages/prismarine/src/world/WorldPersistence.ts:53
The four phases of the dragon respawn sequence, Java's DragonRespawnStage short of end.
Functions
isFlatGenerator()
isFlatGenerator(
generator):generator is FlatGeneratorDefinition
Defined in: packages/prismarine/src/world/WorldPersistence.ts:225
Whether a stem's generator is minecraft:flat with its layers in the stem, narrowing it to them. A flat stem that names a flat_level_generator_preset instead is not one: its layers live in the pack stack, and the stem is written back as the id it was read with.
Parameters
generator
Returns
generator is FlatGeneratorDefinition
isNoiseGenerator()
isNoiseGenerator(
generator):generator is NoiseGeneratorDefinition
Defined in: packages/prismarine/src/world/WorldPersistence.ts:217
Whether a stem's generator is minecraft:noise, narrowing it to its settings and biome source. GeneratorDefinition carries an unknown-kind variant typed type: string, so a plain comparison on type does not narrow the union by itself.
Parameters
generator
Returns
generator is NoiseGeneratorDefinition
legacyWorldPersistenceDataOf()
legacyWorldPersistenceDataOf(
value):WorldPersistenceData
Defined in: packages/prismarine/src/world/WorldPersistence.ts:318
Validates legacy file data before migrating it and removing its source file.
Parameters
value
unknown
Returns
levelStemJsonOf()
levelStemJsonOf(
stem):Record<string,unknown>
Defined in: packages/prismarine/src/world/WorldPersistence.ts:229
A parsed level stem as the Java dimension document it came from.
Parameters
stem
Returns
Record<string, unknown>
parseWorldPersistenceData()
parseWorldPersistenceData(
text):WorldPersistenceData
Defined in: packages/prismarine/src/world/WorldPersistence.ts:339
Parses world state encoded as JSON inside provider storage.
Parameters
text
string
Returns
structureReferenceKey()
structureReferenceKey(
start):string
Defined in: packages/prismarine/src/world/WorldPersistence.ts:143
The key one StructureReference is held under.
Parameters
start
Returns
string
worldPersistenceDataOf()
worldPersistenceDataOf(
value):WorldPersistenceData
Defined in: packages/prismarine/src/world/WorldPersistence.ts:155
Reads persisted world state at the JSON and NBT boundaries.
A malformed spawn, rule, weather or entity entry is dropped. A malformed stem is not: the stems say which terrain the save holds, and starting with different ones would generate a different world into the same chunks.
Parameters
value
unknown
Returns
Throws
When worldGenSettings is present and one of its stems does not parse.
worldPersistenceJsonOf()
worldPersistenceJsonOf(
data):Record<string,unknown>
Defined in: packages/prismarine/src/world/WorldPersistence.ts:197
The persisted state as the JSON object a provider stores.
Everything but the stems is already plain data. A parsed stem is not: its biome source and flat settings carry camel-cased fields and quantized climate values, so it is written back as the Java document parseLevelStem reads.
Parameters
data
Returns
Record<string, unknown>