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

# entity/playerComponents

## Classes

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

## Interfaces

### PlayerMeal

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

A meal in progress, as plain data: the tick it began on, how many ticks it takes and the item
being eaten or drunk. What it does once finished is resolved then, from the item.

#### Properties

##### item

> `readonly` **item**: `string`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:58](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L58)

##### startedAt

> `readonly` **startedAt**: `number`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:56](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L56)

##### ticks

> `readonly` **ticks**: `number`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:57](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L57)

***

### PlayerMining

Defined in: [packages/prismarine/src/entity/playerComponents.ts:36](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L36)

The block a player is mining, as plain data: its position, the face being mined, its runtime id,
how much of the 65535 a full break takes one tick is worth, how many ticks the break takes for
the tool in hand (infinite for a block that never breaks) and the tick the mining began on.

#### Properties

##### breakTicks

> `readonly` **breakTicks**: `number`

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

##### face

> `readonly` **face**: `number`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:40](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L40)

##### progressPerTick

> `readonly` **progressPerTick**: `number`

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

##### runtimeId

> `readonly` **runtimeId**: `number`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:41](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L41)

##### serverBreaks?

> `readonly` `optional` **serverBreaks?**: `true`

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

Set when the server breaks the block once its time is up; see `BlockMining.serverBreaks`.

##### startedAt

> `readonly` **startedAt**: `number`

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

##### startedAtInput?

> `readonly` `optional` **startedAtInput?**: `number`

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

The client's input count when mining began; see `BlockMining.startedAtInput`.

##### x

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

Defined in: [packages/prismarine/src/entity/playerComponents.ts:37](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L37)

##### y

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

Defined in: [packages/prismarine/src/entity/playerComponents.ts:38](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L38)

##### z

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

Defined in: [packages/prismarine/src/entity/playerComponents.ts:39](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L39)

## Type Aliases

### PlayerComponentField

> **PlayerComponentField** = keyof [`PlayerComponentValues`](#playercomponentvalues)

Defined in: [packages/prismarine/src/entity/playerComponents.ts:140](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L140)

The name of one logged component field.

***

### PlayerComponentValues

> **PlayerComponentValues** = `object`

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

Every logged component field of a player, by the name its entries carry, with its value.

#### Properties

##### abilities.flying

> **abilities.flying**: `boolean`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:88](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L88)

Whether the player is flying, which only a creative or spectator player may.

##### abilities.gamemode

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

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

The game mode, which decides whether hunger, breath and falls reach the player.

##### attributes.absorption

> **attributes.absorption**: `number`

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

Absorption, the extra hearts spent before health.

##### attributes.attackDamage

> **attributes.attackDamage**: `number`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:120](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L120)

Attack damage.

##### attributes.followRange

> **attributes.followRange**: `number`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:118](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L118)

Follow range.

##### attributes.knockbackResistance

> **attributes.knockbackResistance**: `number`

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

Knockback resistance, from 0 to 1.

##### attributes.lavaMovement

> **attributes.lavaMovement**: `number`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:116](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L116)

Movement speed in lava.

##### attributes.luck

> **attributes.luck**: `number`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:122](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L122)

Luck.

##### attributes.movement

> **attributes.movement**: `number`

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

Movement speed on land.

##### attributes.underwaterMovement

> **attributes.underwaterMovement**: `number`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:114](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L114)

Movement speed in water.

##### consumption.meal

> **consumption.meal**: [`PlayerMeal`](#playermeal) \| `null`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:132](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L132)

The meal the player has started and not finished, or null.

##### experience.level

> **experience.level**: `number`

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

Whole experience levels.

##### experience.progress

> **experience.progress**: `number`

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

How far along the current level the bar is, from 0 to 1.

##### itemUse.startedAt

> **itemUse.startedAt**: `number` \| `null`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:128](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L128)

The tick a held-item use, such as drawing a bow, began on, or null.

##### mining.block

> **mining.block**: [`PlayerMining`](#playermining) \| `null`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:130](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L130)

The block the player is mining, whose cracks are animated every tick, or null.

##### movement.gliding

> **movement.gliding**: `boolean`

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

Whether the player is gliding on an elytra, Java's fall flying.

##### movement.sleepTimer

> **movement.sleepTimer**: `number`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:102](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L102)

How long the player has slept, up to 100 ticks, and after it gets up how long it has been
awake, up to 110, when it starts again from 0. Java's `SleepTimer`.

##### movement.sneaking

> **movement.sneaking**: `boolean`

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

Whether the client reported the player sneaking.

##### movement.sneakingSince

> **movement.sneakingSince**: `number` \| `null`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:97](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L97)

The game tick the player began sneaking on, or null while it is not sneaking. A Bedrock
player raises a shield by sneaking, so this is when a raised shield went up.

##### movement.sprinting

> **movement.sprinting**: `boolean`

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

Whether the player is sprinting.

##### respawn.seenCredits

> **respawn.seenCredits**: `boolean`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:126](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L126)

Whether the player has watched the end credits.

##### respawn.spawnPoint

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

Defined in: [packages/prismarine/src/entity/playerComponents.ts:124](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L124)

Where the player comes back after a death, or null for the world spawn.

##### vitals.air

> **vitals.air**: `number`

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

Ticks of breath left, out of the metadata's maximum.

##### vitals.breathing

> **vitals.breathing**: `boolean`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:78](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L78)

Whether the player is breathing; false draws the bubble bar.

##### vitals.drowningTicks

> **vitals.drowningTicks**: `number`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:80](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L80)

Ticks spent with no breath left, counting toward the next lungful of damage.

##### vitals.exhaustion

> **vitals.exhaustion**: `number`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:74](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L74)

The counter that spends saturation and then food, a point for every four.

##### vitals.fallDistance

> **vitals.fallDistance**: `number`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:82](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L82)

How far the player has fallen since they were last supported.

##### vitals.food

> **vitals.food**: `number`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:70](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L70)

Food, out of 20.

##### vitals.saturation

> **vitals.saturation**: `number`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:72](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L72)

The hidden buffer spent before food.

***

### PlayerComponentWritten

> **PlayerComponentWritten** = \<`F`\>(`field`, `before`, `after`) => `void`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:349](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L349)

Hears one write to a component field, with its value before and after.

#### Type Parameters

##### F

`F` *extends* [`PlayerComponentField`](#playercomponentfield)

#### Parameters

##### field

`F`

##### before

[`PlayerComponentValues`](#playercomponentvalues)\[`F`\]

##### after

[`PlayerComponentValues`](#playercomponentvalues)\[`F`\]

#### Returns

`void`

***

### PlayerMetadata

> **PlayerMetadata** = `Pick`\<[`Metadata`](https://jsprismarine.dev/api/@jsprismarine/protocol/classes/Metadata.md), `"air"` \| `"setAir"` \| `"maxAir"` \| `"breathing"` \| `"setBreathing"` \| `"sprinting"` \| `"setSprinting"`\>

Defined in: [packages/prismarine/src/entity/playerComponents.ts:62](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L62)

The part of the actor metadata a player's components keep air, breathing and sprinting in.

## Functions

### mayFlyIn()

> **mayFlyIn**(`gamemode`): `boolean`

Defined in: [packages/prismarine/src/entity/playerComponents.ts:136](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/playerComponents.ts#L136)

Whether a player in a game mode may fly, which a creative or spectator player may.

#### Parameters

##### gamemode

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

#### Returns

`boolean`
