Skip to content

API reference / @jsprismarine/prismarine / entity/data/playerSystems / PlayerSystems

Class: PlayerSystems ​

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:190

The player systems of one store, and the component state of its players.

Constructors ​

Constructor ​

new PlayerSystems(ports): PlayerSystems

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:193

Parameters ​

ports ​

PlayerSystemsPorts

Returns ​

PlayerSystems

Methods ​

attach() ​

attach(entity, parts): PlayerLog

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:223

Takes a store player's parts for its entity, so the player has one set of components and the systems run, log and undo the same fields a save reads. Called before the entity enters the store, so what the player brings is part of the form it enters with and is not logged.

Parameters ​

entity ​

DataEntity

A store entity whose client owns its movement.

parts ​

PlayerParts

The player's components and writers, which replace any built for the entity.

Returns ​

PlayerLog

Where the player logs its writes while the entity is in this store.


beforeComponents() ​

beforeComponents(entity): void

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:239

Runs before a store player's components tick. A player's air is the breath system's, so the minecraft:breathable the shipped player declares keeps none, and its tick, which reads its own air, does nothing. The component builds its air again whenever it initializes, such as after a component group change, so this clears it before every tick.

Parameters ​

entity ​

DataEntity

The player.

Returns ​

void


beginMeal() ​

beginMeal(entity, ticks): boolean

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:321

Notes that a store player has started eating or drinking what is in its hand, on the store's tick its meal is counted out on.

Parameters ​

entity ​

DataEntity

The player.

ticks ​

number

How long the meal takes.

Returns ​

boolean

Whether a meal began, which needs an item in hand.


cancelMeal() ​

cancelMeal(entity): void

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:329

Forgets a store player's unfinished meal, as letting go of the button does.

Parameters ​

entity ​

DataEntity

Returns ​

void


componentsOf() ​

componentsOf(entity): PlayerComponents

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:201

A store player's components, built the first time they are asked for with a fresh player's values: the same attributes and actor metadata a joining legacy player starts with.

Parameters ​

entity ​

DataEntity

A store entity whose client owns its movement.

Returns ​

PlayerComponents


died() ​

died(entity): void

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:270

What a store player's death does to its survival state: the drowning in progress ends, and so do the cracks on the block it was mining. The runtime calls this inside the blow that killed it.

Parameters ​

entity ​

DataEntity

The player who died.

Returns ​

void


exhaust() ​

exhaust(entity, amount): void

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:375

Makes a store player hungrier, as moving, jumping, attacking and healing do.

Parameters ​

entity ​

DataEntity

amount ​

number

Returns ​

void


jumped() ​

jumped(entity): void

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:385

Charges a store player for a jump its client reported, four times over for a sprint jump.

Parameters ​

entity ​

DataEntity

Returns ​

void


moved() ​

moved(entity, from, wasOnGround): void

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:406

Charges a store player for a move its client reported and adds it to the fall in progress, then pays for the fall if the move landed it, in the order the legacy movement handler runs them: the step, then the ground. The runtime calls this after it wrote the move.

Parameters ​

entity ​

DataEntity

The player, already at its new position and ground state.

from ​

EntityPosition

Where it was.

wasOnGround ​

boolean

Whether it was on the ground before the move.

Returns ​

void


reaches() ​

reaches(entity, intent): boolean

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:342

Whether a blow reaches a store player in its game mode. Survival and adventure take every blow. Creative takes only what bypasses invulnerability, Java's #bypasses_invulnerability tag, which is the void and /kill, and a spectator takes nothing, as Java's isInvulnerableTo answers before the tag is consulted.

Parameters ​

entity ​

DataEntity

The player hurt.

intent ​

DamageIntent

The blow.

Returns ​

boolean


restore() ​

restore(entity, field, value): boolean

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:454

Writes a logged field of a store player back, without logging it, for the store's undo: a component field, or one the player keeps beside them.

Parameters ​

entity ​

DataEntity

field ​

string

value ​

PlainData

Returns ​

boolean

Whether field names a field of the player.


restoreSlot() ​

restoreSlot(entity, container, slot, value): boolean

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:464

Writes a logged slot of a store player back, without logging it, for the store's undo.

Parameters ​

entity ​

DataEntity

container ​

string

slot ​

number

value ​

PlainData

Returns ​

boolean

Whether the entity's player carries that container and slot.


revived() ​

revived(entity): void

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:283

What a store player's revival gives it besides its health: its attributes back at their defaults, full lungs, and a body that is not running, crouching, flying or sleeping.

Parameters ​

entity ​

DataEntity

The player coming back.

Returns ​

void


setFlying() ​

setFlying(entity, flying): void

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:370

Writes whether a store player is flying. Whether its game mode lets it fly is the caller's.

Parameters ​

entity ​

DataEntity

flying ​

boolean

Returns ​

void


setGamemode() ​

setGamemode(entity, gamemode): void

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:365

Writes a store player's game mode, which decides which blows and survival rules reach it.

Parameters ​

entity ​

DataEntity

gamemode ​

Gametype

Returns ​

void


setMining() ​

setMining(entity, mining): void

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:295

Sets the block a store player is mining, whose cracks the systems animate every tick until it breaks or the player stops. The start of the cracks is the caller's: MineBlockHandler sends it through World.startBlockCracking.

Parameters ​

entity ​

DataEntity

The player.

mining ​

PlayerMining | null

The block, or null when the player stopped or broke it.

Returns ​

void


setSneaking() ​

setSneaking(entity, sneaking): void

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:360

Writes whether a store player is sneaking, as its client reports it, and the tick it began, which is when a shield it holds went up.

Parameters ​

entity ​

DataEntity

sneaking ​

boolean

Returns ​

void


setSprinting() ​

setSprinting(entity, sprinting): void

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:352

Writes whether a store player is sprinting, as its client reports it.

Parameters ​

entity ​

DataEntity

sprinting ​

boolean

Returns ​

void


shownFormOf() ​

shownFormOf(entity): PlayerShownForm | undefined

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:444

What clients are shown of a store player beside its entity (entity/playerShown.ts).

Parameters ​

entity ​

DataEntity

Returns ​

PlayerShownForm | undefined

The form, or undefined for an entity no store player attached to.


statusEffectTicked() ​

statusEffectTicked(entity, effect): void

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:380

One tick of a status effect on a store player: the hunger effect drains it, saturation feeds it.

Parameters ​

entity ​

DataEntity

effect ​

Pick<StatusEffect, "id" | "amplifier">

Returns ​

void


stopMining() ​

stopMining(entity): void

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:305

Stops the cracks on the block a store player was mining, if any, and forgets it, for whatever ends the mining without the client saying so, such as a death.

Parameters ​

entity ​

DataEntity

The player.

Returns ​

void


teleported() ​

teleported(entity): void

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:393

Ends the fall in progress of a store player the server moved, which the runtime calls beside MobBody.teleportTo: a teleport is not a fall, as a legacy player's is not.

Parameters ​

entity ​

DataEntity

Returns ​

void


tick() ​

tick(entity, tick): void

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:251

One tick of a store player's systems, in the order a legacy player runs them: breath and hunger for a player they reach, then the meal in progress and the block being mined for any player.

Parameters ​

entity ​

DataEntity

The player.

tick ​

number

The world tick, which the hunger clock reads.

Returns ​

void


timeSinceRestOf() ​

timeSinceRestOf(entity): number

Defined in: packages/prismarine/src/entity/data/playerSystems.ts:210

A store player's ticks since it last slept or died, Java's Stats.TIME_SINCE_REST.

Parameters ​

entity ​

DataEntity

Returns ​

number

Java Source ​

Stats.TIME_SINCE_REST