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
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
A store entity whose client owns its movement.
parts
The player's components and writers, which replace any built for the entity.
Returns
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
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
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
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
A store entity whose client owns its movement.
Returns
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
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
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
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
The player, already at its new position and ground state.
from
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
The player hurt.
intent
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
field
string
value
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
container
string
slot
number
value
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
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
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
gamemode
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
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
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
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
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
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
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
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
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
Returns
number
Java Source
Stats.TIME_SINCE_REST