API reference / @jsprismarine/prismarine / world/playerRecord
world/playerRecord
Interfaces
PlayerRecordSource
Defined in: packages/prismarine/src/world/playerRecord.ts:42
What a record reads off a player. A store player has every member.
Properties
attributes
readonlyattributes:Attributes
Defined in: packages/prismarine/src/world/playerRecord.ts:58
The client's attribute table, which holds food, saturation and experience and is saved whole.
gamemode
readonlygamemode:Gametype
Defined in: packages/prismarine/src/world/playerRecord.ts:45
headYaw
readonlyheadYaw:number
Defined in: packages/prismarine/src/world/playerRecord.ts:51
persistentNbt
readonlypersistentNbt:NBTTagCompound|null
Defined in: packages/prismarine/src/world/playerRecord.ts:68
The actor record tags this server does not model, which a script's dynamic properties live in, or null when the player has none.
pitch
readonlypitch:number
Defined in: packages/prismarine/src/world/playerRecord.ts:49
yaw
readonlyyaw:number
Defined in: packages/prismarine/src/world/playerRecord.ts:50
Methods
getFood()
getFood():
number
Defined in: packages/prismarine/src/world/playerRecord.ts:55
Returns
number
getHealth()
getHealth():
number
Defined in: packages/prismarine/src/world/playerRecord.ts:53
Returns
number
getInventory()
getInventory():
HumanInventory
Defined in: packages/prismarine/src/world/playerRecord.ts:52
Returns
getMaxHealth()
getMaxHealth():
number
Defined in: packages/prismarine/src/world/playerRecord.ts:54
Returns
number
getName()
getName():
string
Defined in: packages/prismarine/src/world/playerRecord.ts:44
Returns
string
getPortalCooldown()
getPortalCooldown():
number
Defined in: packages/prismarine/src/world/playerRecord.ts:60
Returns
number
getPosition()
getPosition():
object
Defined in: packages/prismarine/src/world/playerRecord.ts:48
The eye position, 1.62 above the feet, which every record written so far holds.
Returns
object
getX()
getX():
number
Returns
number
getY()
getY():
number
Returns
number
getZ()
getZ():
number
Returns
number
getSaturation()
getSaturation():
number
Defined in: packages/prismarine/src/world/playerRecord.ts:56
Returns
number
getSpawnPoint()
getSpawnPoint():
StoredSpawnPoint|undefined
Defined in: packages/prismarine/src/world/playerRecord.ts:59
Returns
StoredSpawnPoint | undefined
getTimeSinceRest()
getTimeSinceRest():
number
Defined in: packages/prismarine/src/world/playerRecord.ts:63
Ticks since the player last slept or died.
Returns
number
getUUID()
getUUID():
object
Defined in: packages/prismarine/src/world/playerRecord.ts:43
Returns
object
toString()
toString():
string
Returns
string
hasSeenCredits()
hasSeenCredits():
boolean
Defined in: packages/prismarine/src/world/playerRecord.ts:61
Returns
boolean
isFlying()
isFlying():
boolean
Defined in: packages/prismarine/src/world/playerRecord.ts:46
Returns
boolean
PlayerRecordTarget
Defined in: packages/prismarine/src/world/playerRecord.ts:75
What a record writes back into a player. Every write is silent: nothing is sent and no death runs, because a record is loaded before the client has been told its login succeeded.
Properties
attributes
readonlyattributes:Attributes
Defined in: packages/prismarine/src/world/playerRecord.ts:79
gamemode
gamemode:
Gametype
Defined in: packages/prismarine/src/world/playerRecord.ts:76
persistentNbt
persistentNbt:
NBTTagCompound|null
Defined in: packages/prismarine/src/world/playerRecord.ts:92
Writes the actor record tags this server does not model, which the player's entity carries into its store.
Methods
getHealth()
getHealth():
number
Defined in: packages/prismarine/src/world/playerRecord.ts:78
Returns
number
getInventory()
getInventory():
HumanInventory
Defined in: packages/prismarine/src/world/playerRecord.ts:77
Returns
restoreFlying()
restoreFlying(
flying):void
Defined in: packages/prismarine/src/world/playerRecord.ts:83
Writes the flying flag without asking the client or raising an event.
Parameters
flying
boolean
Returns
void
restoreHealth()
restoreHealth(
health):void
Defined in: packages/prismarine/src/world/playerRecord.ts:81
Writes health without the death path, so a player who left on half a heart is not killed.
Parameters
health
number
Returns
void
setFood()
setFood(
food):void
Defined in: packages/prismarine/src/world/playerRecord.ts:84
Parameters
food
number
Returns
void
setPortalCooldown()
setPortalCooldown(
ticks):void
Defined in: packages/prismarine/src/world/playerRecord.ts:89
Parameters
ticks
number
Returns
void
setSaturation()
setSaturation(
saturation):void
Defined in: packages/prismarine/src/world/playerRecord.ts:86
Writes saturation, which never exceeds the food just set.
Parameters
saturation
number
Returns
void
setSeenCredits()
setSeenCredits(
seen):void
Defined in: packages/prismarine/src/world/playerRecord.ts:88
Parameters
seen
boolean
Returns
void
setSpawnPoint()
setSpawnPoint(
spawn):void
Defined in: packages/prismarine/src/world/playerRecord.ts:87
Parameters
spawn
StoredSpawnPoint | undefined
Returns
void
setTimeSinceRest()
setTimeSinceRest(
ticks):void
Defined in: packages/prismarine/src/world/playerRecord.ts:90
Parameters
ticks
number
Returns
void
PlayerServiceState
Defined in: packages/prismarine/src/world/playerRecord.ts:99
The record's fields that per-player services hold, keyed by keyOfPlayer, rather than the player: advancement progress and the enchantment seed.
Properties
advancements
readonlyadvancements:PlayerProgressJson
Defined in: packages/prismarine/src/world/playerRecord.ts:100
enchantmentSeed
readonlyenchantmentSeed:number
Defined in: packages/prismarine/src/world/playerRecord.ts:109
recipeBook?
readonlyoptionalrecipeBook?: readonlystring[]
Defined in: packages/prismarine/src/world/playerRecord.ts:104
The recipe book, which a caller that has none leaves out of the record.
recipeBookHighlight?
readonlyoptionalrecipeBookHighlight?: readonlystring[]
Defined in: packages/prismarine/src/world/playerRecord.ts:108
The recipes the book highlights, which a caller that has none leaves out of the record.
recipeBookSettings?
readonlyoptionalrecipeBookSettings?:Readonly<Record<"crafting"|"furnace"|"smoker"|"blastFurnace",RecipeBookSetting>>
Defined in: packages/prismarine/src/world/playerRecord.ts:106
Each screen's recipe book settings, which a caller that has none leaves out of the record.
statistics?
readonlyoptionalstatistics?:Readonly<Record<string,number>>
Defined in: packages/prismarine/src/world/playerRecord.ts:102
The statistics' totals by criterion name, which a caller that has none leaves out of the record.
RecordedPosition
Defined in: packages/prismarine/src/world/playerRecord.ts:287
Where a record puts a returning player: the eye and the look.
Properties
headYaw
readonlyheadYaw:number
Defined in: packages/prismarine/src/world/playerRecord.ts:293
pitch
readonlypitch:number
Defined in: packages/prismarine/src/world/playerRecord.ts:291
x
readonlyx:number
Defined in: packages/prismarine/src/world/playerRecord.ts:288
y
readonlyy:number
Defined in: packages/prismarine/src/world/playerRecord.ts:289
yaw
readonlyyaw:number
Defined in: packages/prismarine/src/world/playerRecord.ts:292
z
readonlyz:number
Defined in: packages/prismarine/src/world/playerRecord.ts:290
Functions
applyPlayerRecord()
applyPlayerRecord(
player,data,defaultGamemode,content?):void
Defined in: packages/prismarine/src/world/playerRecord.ts:240
Puts a record back into a player: game mode, inventory, attributes, flying, the spawn point, the credits flag, the portal cooldown and the actor tags a script's dynamic properties live in.
The attributes go in whole when the record has the table, which is every record written since it existed, and through the separate health, food, saturation and experience fields otherwise. Saturation is set after food because it is clamped to it. Flying is kept only for a game mode that allows it. The position and the per-player services are the caller's, because placing a player who has no saved position needs the world.
Parameters
player
The player to fill, freshly built.
data
Partial<WorldPlayerData>
The record, or what a first join gets instead of one.
defaultGamemode
string
The game mode named when the record names none.
content?
The content build, which decides each restored item's maximum durability.
Returns
void
playerRecordFrom()
playerRecordFrom(
player,services,dimension):WorldPlayerData
Defined in: packages/prismarine/src/world/playerRecord.ts:125
The record a player's state saves as, built without awaiting anything.
The field order is the order the record is written in, and the fallback JSON file keeps it, so it does not change. position is the eye. The attribute table's health entry is the player's health and maximum health, so a player whose health lives on its store entity saves the same table a live player does.
Parameters
player
Whose state to record.
services
What the per-player services hold for this player.
dimension
The dimension the record is stamped with, so the next login puts the player back in it: the one of the world saving the record.
Returns
The record, with savedAt set to now.
playerRecordOf()
playerRecordOf(
player,keyed,dimension):WorldPlayerData
Defined in: packages/prismarine/src/world/playerRecord.ts:208
A player's record, with what the per-player services hold for them.
Parameters
player
Whose state to record.
keyed
The key the services file the player's state under, and the server they read.
dimension
The dimension the record is stamped with; see playerRecordFrom.
Returns
The record.
recordedPosition()
recordedPosition(
data):RecordedPosition|undefined
Defined in: packages/prismarine/src/world/playerRecord.ts:302
The position a record puts a returning player at, or undefined for a player who has none and is placed the way a first join is.
Parameters
data
Partial<WorldPlayerData>
The record.
Returns
RecordedPosition | undefined
The eye position and the look, with a missing angle read as 0.