Skip to content

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 ​

readonly attributes: 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 ​

readonly gamemode: Gametype

Defined in: packages/prismarine/src/world/playerRecord.ts:45

headYaw ​

readonly headYaw: number

Defined in: packages/prismarine/src/world/playerRecord.ts:51

persistentNbt ​

readonly persistentNbt: 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 ​

readonly pitch: number

Defined in: packages/prismarine/src/world/playerRecord.ts:49

yaw ​

readonly yaw: 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 ​

HumanInventory

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 ​

readonly attributes: 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 ​

HumanInventory

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 ​

readonly advancements: PlayerProgressJson

Defined in: packages/prismarine/src/world/playerRecord.ts:100

enchantmentSeed ​

readonly enchantmentSeed: number

Defined in: packages/prismarine/src/world/playerRecord.ts:109

recipeBook? ​

readonly optional recipeBook?: readonly string[]

Defined in: packages/prismarine/src/world/playerRecord.ts:104

The recipe book, which a caller that has none leaves out of the record.

recipeBookHighlight? ​

readonly optional recipeBookHighlight?: readonly string[]

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

readonly optional recipeBookSettings?: 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? ​

readonly optional statistics?: 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 ​

readonly headYaw: number

Defined in: packages/prismarine/src/world/playerRecord.ts:293

pitch ​

readonly pitch: number

Defined in: packages/prismarine/src/world/playerRecord.ts:291

x ​

readonly x: number

Defined in: packages/prismarine/src/world/playerRecord.ts:288

y ​

readonly y: number

Defined in: packages/prismarine/src/world/playerRecord.ts:289

yaw ​

readonly yaw: number

Defined in: packages/prismarine/src/world/playerRecord.ts:292

z ​

readonly z: 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 ​

PlayerRecordTarget

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

ServerContent

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 ​

PlayerRecordSource

Whose state to record.

services ​

PlayerServiceState

What the per-player services hold for this player.

dimension ​

DimensionType

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 ​

WorldPlayerData

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 ​

PlayerRecordSource

Whose state to record.

keyed ​

KeyedPlayer

The key the services file the player's state under, and the server they read.

dimension ​

DimensionType

The dimension the record is stamped with; see playerRecordFrom.

Returns ​

WorldPlayerData

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.