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

# entity/data/storePlayers

## Classes

- [DetachedPlayerView](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/data/storePlayers/classes/DetachedPlayerView.md)
- [StorePlayerActor](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/data/storePlayers/classes/StorePlayerActor.md)
- [StorePlayers](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/data/storePlayers/classes/StorePlayers.md)

## Functions

### enterStore()

> **enterStore**(`runtime`, `players`, `player`): [`DataEntity`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/data/DataEntity/classes/DataEntity.md) \| `undefined`

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

Gives a store player an entity in a store, under the player's id, and files the player.

The player's first entity is spawned; a later one, after a dimension change, is restored from
the record its last entity left with. Either way the player is attached before the entity is
announced, so the clients in range are sent a player's `AddPlayer` with its skin, game mode and
equipment from the start, and what the player held is part of the form the entity enters the
change log with. The name is also the entity's name tag, as a legacy player's name is its
metadata's.

#### Parameters

##### runtime

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

##### players

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

##### player

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

#### Returns

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

The entity, or undefined when the content declares no player; the player is then in
  no store, and filed only if it was before.

***

### leaveStore()

> **leaveStore**(`runtime`, `player`, `reason`): `boolean`

Defined in: [packages/prismarine/src/entity/data/storePlayers.ts:135](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/storePlayers.ts#L135)

Takes a store player's entity out of its store and keeps what the next store needs: the
position, the look, the health, and the entity's record, tags and status effects. The player
stays filed, because it is the same player in the next store; `StorePlayers.delete` forgets it
once it leaves the server. An unfinished meal ends here: it counts on this store's tick, and the
next store's clock is another one.

#### Parameters

##### runtime

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

##### player

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

##### reason

`string`

Why the entity left, as `EntityRuntime.remove` takes it.

#### Returns

`boolean`

Whether the player had an entity in `runtime`'s store.

***

### moveStorePlayer()

> **moveStorePlayer**(`runtime`, `player`, `movement`): `boolean`

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

Applies a move a store player's client reported: the body's position, look and ground through
`EntityRuntime.applyClientMovement`, which charges the walk and pays for a landing, and the head
yaw, which the player keeps beside its entity because the body has none.

#### Parameters

##### runtime

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

##### player

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

##### movement

`object` & `object`

#### Returns

`boolean`

Whether the player's entity is in `runtime`'s store.

***

### reattachStorePlayer()

> **reattachStorePlayer**(`runtime`, `players`): (`entity`) => `void`

Defined in: [packages/prismarine/src/entity/data/storePlayers.ts:154](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/storePlayers.ts#L154)

What a runtime's `onPlayerReentered` runs: hands a player's entity that an undo or a replay adds
back to the store player it belongs to, which the leave detached and kept filed, so the slot and
field entries written back after it find the player's parts. A store player that holds an entity
in another store by then is left as it is.

#### Parameters

##### runtime

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

##### players

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

#### Returns

The callback to set as the runtime's `onPlayerReentered`.

(`entity`) => `void`

***

### spawnStorePlayer()

> **spawnStorePlayer**(`runtime`, `players`, `at`, `identity`, `fill?`): [`StorePlayer`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/storePlayer/classes/StorePlayer.md) \| `undefined`

Defined in: [packages/prismarine/src/entity/data/storePlayers.ts:186](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/storePlayers.ts#L186)

Builds a store player under an id from the runtime's pool, fills it, and enters it into the
store, which is a login and a first spawn in one call.

#### Parameters

##### runtime

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

##### players

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

##### at

[`EntityPosition`](https://jsprismarine.dev/api/@jsprismarine/entities/index.md#entityposition)

Where the player's feet are. A client reports its eyes, `EYE_HEIGHT` higher.

##### identity

[`StorePlayerIdentity`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/storePlayer/index.md#storeplayeridentity)

##### fill?

(`player`) => `void`

Writes the player's parts before it is shown, such as a saved record or the
  skin the login carried.

#### Returns

[`StorePlayer`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/storePlayer/classes/StorePlayer.md) \| `undefined`

The player, or undefined when the content declares no player.
