[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/prismarine](https://jsprismarine.dev/api/@jsprismarine/prismarine/index.md) / world/playerRecord

# world/playerRecord

## Interfaces

### PlayerRecordSource

Defined in: [packages/prismarine/src/world/playerRecord.ts:42](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L42)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L58)

The client's attribute table, which holds food, saturation and experience and is saved whole.

##### gamemode

> `readonly` **gamemode**: [`Gametype`](https://jsprismarine.dev/api/@jsprismarine/minecraft/index.md#gametype)

Defined in: [packages/prismarine/src/world/playerRecord.ts:45](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L45)

##### headYaw

> `readonly` **headYaw**: `number`

Defined in: [packages/prismarine/src/world/playerRecord.ts:51](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L51)

##### persistentNbt

> `readonly` **persistentNbt**: [`NBTTagCompound`](https://jsprismarine.dev/api/@jsprismarine/nbt/classes/NBTTagCompound.md) \| `null`

Defined in: [packages/prismarine/src/world/playerRecord.ts:68](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L68)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L49)

##### yaw

> `readonly` **yaw**: `number`

Defined in: [packages/prismarine/src/world/playerRecord.ts:50](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L50)

#### Methods

##### getFood()

> **getFood**(): `number`

Defined in: [packages/prismarine/src/world/playerRecord.ts:55](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L55)

###### Returns

`number`

##### getHealth()

> **getHealth**(): `number`

Defined in: [packages/prismarine/src/world/playerRecord.ts:53](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L53)

###### Returns

`number`

##### getInventory()

> **getInventory**(): [`HumanInventory`](https://jsprismarine.dev/api/@jsprismarine/prismarine/inventory/HumanInventory/classes/HumanInventory.md)

Defined in: [packages/prismarine/src/world/playerRecord.ts:52](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L52)

###### Returns

[`HumanInventory`](https://jsprismarine.dev/api/@jsprismarine/prismarine/inventory/HumanInventory/classes/HumanInventory.md)

##### getMaxHealth()

> **getMaxHealth**(): `number`

Defined in: [packages/prismarine/src/world/playerRecord.ts:54](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L54)

###### Returns

`number`

##### getName()

> **getName**(): `string`

Defined in: [packages/prismarine/src/world/playerRecord.ts:44](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L44)

###### Returns

`string`

##### getPortalCooldown()

> **getPortalCooldown**(): `number`

Defined in: [packages/prismarine/src/world/playerRecord.ts:60](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L60)

###### Returns

`number`

##### getPosition()

> **getPosition**(): `object`

Defined in: [packages/prismarine/src/world/playerRecord.ts:48](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L48)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L56)

###### Returns

`number`

##### getSpawnPoint()

> **getSpawnPoint**(): [`StoredSpawnPoint`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/RespawnPoint/index.md#storedspawnpoint) \| `undefined`

Defined in: [packages/prismarine/src/world/playerRecord.ts:59](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L59)

###### Returns

[`StoredSpawnPoint`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/RespawnPoint/index.md#storedspawnpoint) \| `undefined`

##### getTimeSinceRest()

> **getTimeSinceRest**(): `number`

Defined in: [packages/prismarine/src/world/playerRecord.ts:63](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L63)

Ticks since the player last slept or died.

###### Returns

`number`

##### getUUID()

> **getUUID**(): `object`

Defined in: [packages/prismarine/src/world/playerRecord.ts:43](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L43)

###### Returns

`object`

###### toString()

> **toString**(): `string`

###### Returns

`string`

##### hasSeenCredits()

> **hasSeenCredits**(): `boolean`

Defined in: [packages/prismarine/src/world/playerRecord.ts:61](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L61)

###### Returns

`boolean`

##### isFlying()

> **isFlying**(): `boolean`

Defined in: [packages/prismarine/src/world/playerRecord.ts:46](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L46)

###### Returns

`boolean`

***

### PlayerRecordTarget

Defined in: [packages/prismarine/src/world/playerRecord.ts:75](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L75)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L79)

##### gamemode

> **gamemode**: [`Gametype`](https://jsprismarine.dev/api/@jsprismarine/minecraft/index.md#gametype)

Defined in: [packages/prismarine/src/world/playerRecord.ts:76](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L76)

##### persistentNbt

> **persistentNbt**: [`NBTTagCompound`](https://jsprismarine.dev/api/@jsprismarine/nbt/classes/NBTTagCompound.md) \| `null`

Defined in: [packages/prismarine/src/world/playerRecord.ts:92](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L92)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L78)

###### Returns

`number`

##### getInventory()

> **getInventory**(): [`HumanInventory`](https://jsprismarine.dev/api/@jsprismarine/prismarine/inventory/HumanInventory/classes/HumanInventory.md)

Defined in: [packages/prismarine/src/world/playerRecord.ts:77](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L77)

###### Returns

[`HumanInventory`](https://jsprismarine.dev/api/@jsprismarine/prismarine/inventory/HumanInventory/classes/HumanInventory.md)

##### restoreFlying()

> **restoreFlying**(`flying`): `void`

Defined in: [packages/prismarine/src/world/playerRecord.ts:83](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L83)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L81)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L84)

###### Parameters

###### food

`number`

###### Returns

`void`

##### setPortalCooldown()

> **setPortalCooldown**(`ticks`): `void`

Defined in: [packages/prismarine/src/world/playerRecord.ts:89](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L89)

###### Parameters

###### ticks

`number`

###### Returns

`void`

##### setSaturation()

> **setSaturation**(`saturation`): `void`

Defined in: [packages/prismarine/src/world/playerRecord.ts:86](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L86)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L88)

###### Parameters

###### seen

`boolean`

###### Returns

`void`

##### setSpawnPoint()

> **setSpawnPoint**(`spawn`): `void`

Defined in: [packages/prismarine/src/world/playerRecord.ts:87](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L87)

###### Parameters

###### spawn

[`StoredSpawnPoint`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/RespawnPoint/index.md#storedspawnpoint) \| `undefined`

###### Returns

`void`

##### setTimeSinceRest()

> **setTimeSinceRest**(`ticks`): `void`

Defined in: [packages/prismarine/src/world/playerRecord.ts:90](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L90)

###### Parameters

###### ticks

`number`

###### Returns

`void`

***

### PlayerServiceState

Defined in: [packages/prismarine/src/world/playerRecord.ts:99](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L99)

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`](https://jsprismarine.dev/api/@jsprismarine/advancements/index.md#playerprogressjson)

Defined in: [packages/prismarine/src/world/playerRecord.ts:100](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L100)

##### enchantmentSeed

> `readonly` **enchantmentSeed**: `number`

Defined in: [packages/prismarine/src/world/playerRecord.ts:109](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L109)

##### recipeBook?

> `readonly` `optional` **recipeBook?**: readonly `string`[]

Defined in: [packages/prismarine/src/world/playerRecord.ts:104](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L104)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L108)

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`](https://jsprismarine.dev/api/@jsprismarine/prismarine/player/presenter/SessionPresenter/index.md#recipebooksetting)\>\>

Defined in: [packages/prismarine/src/world/playerRecord.ts:106](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L106)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L102)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L287)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L293)

##### pitch

> `readonly` **pitch**: `number`

Defined in: [packages/prismarine/src/world/playerRecord.ts:291](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L291)

##### x

> `readonly` **x**: `number`

Defined in: [packages/prismarine/src/world/playerRecord.ts:288](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L288)

##### y

> `readonly` **y**: `number`

Defined in: [packages/prismarine/src/world/playerRecord.ts:289](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L289)

##### yaw

> `readonly` **yaw**: `number`

Defined in: [packages/prismarine/src/world/playerRecord.ts:292](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L292)

##### z

> `readonly` **z**: `number`

Defined in: [packages/prismarine/src/world/playerRecord.ts:290](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L290)

## Functions

### applyPlayerRecord()

> **applyPlayerRecord**(`player`, `data`, `defaultGamemode`, `content?`): `void`

Defined in: [packages/prismarine/src/world/playerRecord.ts:240](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L240)

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`](#playerrecordtarget)

The player to fill, freshly built.

##### data

`Partial`\<[`WorldPlayerData`](https://jsprismarine.dev/api/@jsprismarine/prismarine/config/JsonConfigTypes/index.md#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`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/ServerContent/index.md#servercontent)

The content build, which decides each restored item's maximum durability.

#### Returns

`void`

***

### playerRecordFrom()

> **playerRecordFrom**(`player`, `services`, `dimension`): [`WorldPlayerData`](https://jsprismarine.dev/api/@jsprismarine/prismarine/config/JsonConfigTypes/index.md#worldplayerdata)

Defined in: [packages/prismarine/src/world/playerRecord.ts:125](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L125)

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`](#playerrecordsource)

Whose state to record.

##### services

[`PlayerServiceState`](#playerservicestate)

What the per-player services hold for this player.

##### dimension

[`DimensionType`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/DimensionType/index.md#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`](https://jsprismarine.dev/api/@jsprismarine/prismarine/config/JsonConfigTypes/index.md#worldplayerdata)

The record, with `savedAt` set to now.

***

### playerRecordOf()

> **playerRecordOf**(`player`, `keyed`, `dimension`): [`WorldPlayerData`](https://jsprismarine.dev/api/@jsprismarine/prismarine/config/JsonConfigTypes/index.md#worldplayerdata)

Defined in: [packages/prismarine/src/world/playerRecord.ts:208](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L208)

A player's record, with what the per-player services hold for them.

#### Parameters

##### player

[`PlayerRecordSource`](#playerrecordsource)

Whose state to record.

##### keyed

[`KeyedPlayer`](https://jsprismarine.dev/api/@jsprismarine/prismarine/keyedPlayer/index.md#keyedplayer)

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

##### dimension

[`DimensionType`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/DimensionType/index.md#dimensiontype)

The dimension the record is stamped with; see [playerRecordFrom](#playerrecordfrom).

#### Returns

[`WorldPlayerData`](https://jsprismarine.dev/api/@jsprismarine/prismarine/config/JsonConfigTypes/index.md#worldplayerdata)

The record.

***

### recordedPosition()

> **recordedPosition**(`data`): [`RecordedPosition`](#recordedposition) \| `undefined`

Defined in: [packages/prismarine/src/world/playerRecord.ts:302](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/playerRecord.ts#L302)

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`](https://jsprismarine.dev/api/@jsprismarine/prismarine/config/JsonConfigTypes/index.md#worldplayerdata)\>

The record.

#### Returns

[`RecordedPosition`](#recordedposition) \| `undefined`

The eye position and the look, with a missing angle read as 0.
