API reference / @jsprismarine/prismarine / entity/data/storePlayers
entity/data/storePlayers
Classes
Functions
enterStore()
enterStore(
runtime,players,player):DataEntity|undefined
Defined in: packages/prismarine/src/entity/data/storePlayers.ts:104
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
players
player
Returns
DataEntity | 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
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
player
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
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
player
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
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
players
Returns
The callback to set as the runtime's onPlayerReentered.
(entity) => void
spawnStorePlayer()
spawnStorePlayer(
runtime,players,at,identity,fill?):StorePlayer|undefined
Defined in: packages/prismarine/src/entity/data/storePlayers.ts:186
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
players
at
Where the player's feet are. A client reports its eyes, EYE_HEIGHT higher.
identity
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 | undefined
The player, or undefined when the content declares no player.