[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/prismarine](https://jsprismarine.dev/api/@jsprismarine/prismarine/index.md) / entity/data/playerSystems

# entity/data/playerSystems

## Classes

- [PlayerSystems](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/data/playerSystems/classes/PlayerSystems.md)

## Interfaces

### PlayerLog

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:173](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L173)

Where a store player's writes are logged while its entity is in the store.

#### Methods

##### field()

> **field**(`field`, `before`, `after`): `void`

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:175](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L175)

Logs a write to a component field, or a field kept beside them such as the hand slot.

###### Parameters

###### field

`string`

###### before

`unknown`

###### after

`unknown`

###### Returns

`void`

##### slot()

> **slot**(`container`, `slot`, `before`, `after`): `void`

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:177](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L177)

Logs a write to one slot the player carries.

###### Parameters

###### container

`"crafting"` \| `"armor"` \| `"cursor"` \| `"ender_chest"` \| `"mainhand"` \| `"offhand"` \| `"inventory"` \| `"body"`

###### slot

`number`

###### before

[`SlotValue`](https://jsprismarine.dev/api/@jsprismarine/prismarine/inventory/slotLog/index.md#slotvalue)

###### after

[`SlotValue`](https://jsprismarine.dev/api/@jsprismarine/prismarine/inventory/slotLog/index.md#slotvalue)

###### Returns

`void`

***

### PlayerParts

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:141](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L141)

What a store player hands the systems when its entity enters a store: its components, and the
writers that put back what it keeps beside them.

#### Properties

##### components

> `readonly` **components**: [`PlayerComponents`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/playerComponents/classes/PlayerComponents.md)

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:143](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L143)

The player's components, which the systems run and log from now on.

##### rest?

> `readonly` `optional` **rest?**: [`RestClock`](#restclock)

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:163](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L163)

The player's ticks since rest, Java's `Stats.TIME_SINCE_REST`: a statistic the player keeps
beside its components, which the systems count without logging. Absent, the systems keep it.

###### Java See

Stats.TIME_SINCE_REST

#### Methods

##### restoreField()

> **restoreField**(`field`, `value`): `boolean`

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:151](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L151)

Writes a logged field the player keeps beside its components back without logging it, such
as `inventory.handSlot`.

###### Parameters

###### field

`string`

###### value

[`PlainData`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/changelog/PlainData/index.md#plaindata)

###### Returns

`boolean`

Whether the player keeps `field`.

##### restoreSlot()

> **restoreSlot**(`container`, `slot`, `value`, `content`): `boolean`

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:156](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L156)

Writes a logged slot back without logging it.

###### Parameters

###### container

`string`

###### slot

`number`

###### value

[`PlainData`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/changelog/PlainData/index.md#plaindata)

###### content

[`ServerContent`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/ServerContent/index.md#servercontent)

###### Returns

`boolean`

Whether the player carries that container and slot.

##### shownForm()

> **shownForm**(): [`PlayerShownForm`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/playerShown/index.md#playershownform)

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:145](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L145)

What clients are shown of the player beside its entity, which the entity enters the log with.

###### Returns

[`PlayerShownForm`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/playerShown/index.md#playershownform)

***

### PlayerSystemsPorts

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:84](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L84)

What the player systems need from the runtime that holds them.

#### Properties

##### level

> `readonly` **level**: [`ContentLevelFacts`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentlevelfacts)

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:103](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L103)

The level, for its game rules.

#### Methods

##### blockAt()

> **blockAt**(`at`): [`ContentBlock`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentblock) \| `undefined`

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:110](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L110)

The block at a position, or undefined when its chunk is not loaded.

###### Parameters

###### at

[`ContentPosition`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentposition)

###### Returns

[`ContentBlock`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentblock) \| `undefined`

##### breakMinedBlock()

> **breakMinedBlock**(`id`, `mining`): `void`

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:134](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L134)

Breaks the block a player mines for a client that never reports the break, once the
player has mined it for long enough, through the input step; the break ends the mining.

###### Parameters

###### id

`number`

###### mining

[`PlayerMining`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/playerComponents/index.md#playermining)

###### Returns

`void`

##### collisionAt()

> **collisionAt**(`at`): readonly [`BedrockCollisionBox`](https://jsprismarine.dev/api/@jsprismarine/blocks/index.md#bedrockcollisionbox)[] \| `undefined`

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:117](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L117)

The collision boxes of the block at a position, normalized to its cell, or undefined when its
chunk is not loaded.

###### Parameters

###### at

[`ContentPosition`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentposition)

###### Returns

readonly [`BedrockCollisionBox`](https://jsprismarine.dev/api/@jsprismarine/blocks/index.md#bedrockcollisionbox)[] \| `undefined`

##### content()

> **content**(): [`ServerContent`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/ServerContent/index.md#servercontent)

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

The built content, which decides an item's maximum durability when a slot is undone.

###### Returns

[`ServerContent`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/ServerContent/index.md#servercontent)

##### damage()

> **damage**(`intent`): [`DamageOutcome`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/data/damagePipeline/index.md#damageoutcome)

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:121](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L121)

Runs one blow through the store's damage pipeline.

###### Parameters

###### intent

[`DamageIntent`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/data/damagePipeline/index.md#damageintent)

###### Returns

[`DamageOutcome`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/data/damagePipeline/index.md#damageoutcome)

##### dying()

> **dying**(`id`): `boolean`

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

Whether the entity has died and waits to be revived.

###### Parameters

###### id

`number`

###### Returns

`boolean`

##### finishMeal()

> **finishMeal**(`id`, `item`): `void`

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:129](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L129)

Finishes a player's meal of `item`, which feeds it.

###### Parameters

###### id

`number`

###### item

`string`

###### Returns

`void`

##### heal()

> **heal**(`id`, `amount`): `boolean`

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:123](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L123)

Gives health back, up to the maximum.

###### Parameters

###### id

`number`

###### amount

`number`

###### Returns

`boolean`

##### heldItem()

> **heldItem**(`id`): `string` \| `undefined`

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:127](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L127)

The item a player holds in its main hand, or undefined for an empty hand or no inventory.

###### Parameters

###### id

`number`

###### Returns

`string` \| `undefined`

##### levelEvent()

> **levelEvent**(`at`, `event`, `data`): `void`

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:119](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L119)

Sends a level event at a point, such as a tick of crack animation.

###### Parameters

###### at

[`ContentPosition`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentposition)

###### event

`number`

###### data

`number`

###### Returns

`void`

##### random()

> **random**(): `number`

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:101](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L101)

A draw in [0, 1) from the world's random, for Respiration's roll.

###### Returns

`number`

##### runtimeIdAt()

> **runtimeIdAt**(`at`): `number` \| `undefined`

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:112](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L112)

The runtime id at a position, or undefined when its chunk is not loaded.

###### Parameters

###### at

[`ContentPosition`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentposition)

###### Returns

`number` \| `undefined`

##### tick()

> **tick**(): `number`

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:108](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L108)

The store's tick (`EntityStore.tick`), which a meal is counted out on: it only goes forward,
where the level clock moves back under `/time set`.

###### Returns

`number`

##### written()

> **written**(`entity`, `field`, `before`, `after`): `void`

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

Logs one write to a store player's state, as `EntityStore.written` does.

###### Parameters

###### entity

[`DataEntity`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/data/DataEntity/classes/DataEntity.md)

###### field

`string`

###### before

`unknown`

###### after

`unknown`

###### Returns

`void`

##### writtenSlot()

> **writtenSlot**(`entity`, `container`, `slot`, `before`, `after`): `void`

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:91](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L91)

Logs one write to a slot a store player carries, as `EntityStore.writtenSlot` does, once
the entity has entered the store.

###### Parameters

###### entity

[`DataEntity`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/data/DataEntity/classes/DataEntity.md)

###### container

`"crafting"` \| `"armor"` \| `"cursor"` \| `"ender_chest"` \| `"mainhand"` \| `"offhand"` \| `"inventory"` \| `"body"`

###### slot

`number`

###### before

[`SlotValue`](https://jsprismarine.dev/api/@jsprismarine/prismarine/inventory/slotLog/index.md#slotvalue)

###### after

[`SlotValue`](https://jsprismarine.dev/api/@jsprismarine/prismarine/inventory/slotLog/index.md#slotvalue)

###### Returns

`void`

***

### RestClock

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:167](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L167)

Reads and writes a player's ticks since rest.

#### Methods

##### get()

> **get**(): `number`

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:168](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L168)

###### Returns

`number`

##### set()

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

Defined in: [packages/prismarine/src/entity/data/playerSystems.ts:169](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/playerSystems.ts#L169)

###### Parameters

###### ticks

`number`

###### Returns

`void`

## Functions

### writeSneaking()

> **writeSneaking**(`components`, `sneaking`, `tick`): `void`

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

Writes whether a player is sneaking and, when it starts, the tick it started on, which is when
a shield it holds went up.

#### Parameters

##### components

[`PlayerComponents`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/playerComponents/classes/PlayerComponents.md)

##### sneaking

`boolean`

##### tick

`number`

The game tick the client reported it on.

#### Returns

`void`
