API reference / @jsprismarine/prismarine / Player
Class: Player
Defined in: prismarine/src/Player.ts:143
Constructors
Constructor
new Player(
options):Player
Defined in: prismarine/src/Player.ts:275
Player's constructor.
Parameters
options
The player options.
address
The address the client connected from.
identity
PlayerIdentity
Who the login handshake said this is.
position
Where the player is, and in which world.
Returns
Player
Remarks
Inert on purpose. It assigns fields and nothing else: no session is built, no listener is registered and nothing server-wide is told this player exists. A player that is constructed and then rejected - by online-mode or by a ban - therefore leaves nothing behind, which is what the chat listener and the chunk scheduler entry used to do when both were claimed here and released only in Player.disable.
Overrides
Human.constructor
Properties
attributes
readonlyattributes:Attributes
Defined in: prismarine/src/entity/Entity.ts:168
Entity attributes.
What is in it is decided by Entity.getDefaultAttributes, which subclasses override - a player has a food bar, a cow does not.
Inherited from
Human.attributes
constructor
constructor: typeof
Entity
Defined in: prismarine/src/entity/Entity.ts:119
TypeScript types this.constructor as Function. Declaring it as the class itself lets Entity.getType read the static MOB_ID the subclass set. Emits nothing.
Inherited from
device
device:
Device|null=null
Defined in: prismarine/src/Player.ts:260
gamemode
gamemode:
Gametype=Gametype.WORLD_DEFAULT
Defined in: prismarine/src/Player.ts:182
headYaw
headYaw:
number
Defined in: prismarine/src/entity/Entity.ts:148
Inherited from
Human.headYaw
locale
locale:
string=''
Defined in: prismarine/src/Player.ts:178
metadata
readonlymetadata:Metadata
Defined in: prismarine/src/entity/Entity.ts:153
Entity metadata.
Inherited from
Human.metadata
persistentNbt
persistentNbt:
NBTTagCompound|null=null
Defined in: prismarine/src/entity/Entity.ts:178
Everything the world file said about this entity that the server does not model.
Vanilla actor NBT carries a definitions list naming the behavior pack component groups the entity was built from, along with its attributes, tags and variant. An actor written back without them spawns broken or despawns on sight, so the remainder is kept here and written out again by EntitySerializer. Null for an entity that was never read from disk.
Inherited from
Human.persistentNbt
pitch
pitch:
number
Defined in: prismarine/src/entity/Entity.ts:146
Inherited from
Human.pitch
platformChatId
platformChatId:
string=''
Defined in: prismarine/src/Player.ts:259
randomId
randomId:
number=0
Defined in: prismarine/src/Player.ts:176
skin
skin:
Skin|null=null
Defined in: prismarine/src/Player.ts:179
viewDistance
viewDistance:
number=0
Defined in: prismarine/src/Player.ts:181
xuid
xuid:
string=''
Defined in: prismarine/src/Player.ts:175
yaw
yaw:
number
Defined in: prismarine/src/entity/Entity.ts:147
Inherited from
Human.yaw
MOB_ID
staticMOB_ID:string='minecraft:player'
Defined in: prismarine/src/entity/Human.ts:28
The entity's namespace ID.
Inherited from
Human.MOB_ID
Accessors
[toStringTag]
Get Signature
get [toStringTag]():
string
Defined in: prismarine/src/entity/Entity.ts:409
Get the entity type.
Example
const entityType = entity.getType();
console.log(`Entity type: ${entityType}`);Returns
string
The entity's namespace ID.
Inherited from
Human.[toStringTag]
Methods
addExhaustion()
addExhaustion(
amount):void
Defined in: prismarine/src/Player.ts:1356
Make the player hungrier.
Exhaustion is a counter, not something the player has: every four points spend one point of saturation, or - once saturation is gone - one point of food. Everything that costs hunger in vanilla (moving, jumping, attacking, healing) does it through here.
Parameters
amount
number
Exhaustion to add.
Returns
void
Example
player.addExhaustion(0.1); // one meter sprintedaddFood()
addFood(
food,saturation?):void
Defined in: prismarine/src/Player.ts:1339
Feed the player, as eating does.
Parameters
food
number
Food points to restore.
saturation?
number = 0
Saturation points to restore.
Returns
void
addJumpExhaustion()
addJumpExhaustion():
void
Defined in: prismarine/src/Player.ts:1393
Charges the player for a jump. Sprint-jumping is what actually empties a food bar in vanilla, at four times the cost of a standing jump.
Returns
void
addStatusEffect()
addStatusEffect(
input,notify?):boolean
Defined in: prismarine/src/entity/Entity.ts:747
Applies or refreshes a status effect.
A stronger Bedrock effect replaces the weaker one. An equal-strength effect only replaces the current value when it lasts longer or changes its visible state.
Parameters
input
The effect and its duration, potency, and display flags.
notify?
boolean = true
Whether to send an effect packet for an accepted change.
Returns
boolean
Whether the effect changed.
Inherited from
addTag()
addTag(
tag):boolean
Defined in: prismarine/src/entity/Entity.ts:1358
Adds one of /tag's arbitrary string tags.
Java's /tag is exactly this and nothing more: a set of strings on the entity that @e[tag=...] tests and nothing else reads. The Bedrock client has no notion of it, so it never reaches the wire.
Parameters
tag
string
The tag.
Returns
boolean
true when the entity did not already carry it.
Inherited from
Human.addTag
applyImpulse()
applyImpulse(
impulse):void
Defined in: prismarine/src/Player.ts:1235
Asks the client to apply a world-space impulse, including nonstandard vertical lift.
Parameters
impulse
Returns
void
Overrides
Human.applyImpulse
applyKnockback()
applyKnockback(
directionX,directionZ,strength,_damping?):void
Defined in: prismarine/src/Player.ts:1226
Asks the client to shove the player, rather than shoving them.
The one entity the server cannot simply move. A player's position comes from their own client and is stored here as reported, so writing to it is overruled by the next movement packet and shows up as rubber-banding. A velocity is a request the client honors, and it runs the shove through the same physics as everything else the player does.
Not awaited: knockback is a consequence of a hit, not a step of it, and the damage pipeline has no reason to wait for a packet to be framed before taking the health off.
Parameters
directionX
number
Unit vector away from the blow, x.
directionZ
number
Unit vector away from the blow, z.
strength
number
How hard, with knockback resistance already taken off.
_damping?
number = 0.5
Returns
void
Overrides
Human.applyKnockback
attachNetworkSession()
attachNetworkSession(
session):void
Defined in: prismarine/src/Player.ts:309
Gives this player the client it speaks through. Called once, by the composition helper that builds the pair - see createConnectedPlayer.
Parameters
session
The session built for this player.
Returns
void
beginConsuming()
beginConsuming(
tick,ticks,finish):void
Defined in: prismarine/src/Player.ts:1482
Notes that the player has started eating or drinking what is in their hand.
Parameters
tick
number
The server tick it began on.
ticks
number
How long the meal takes.
finish
() => Promise<void>
What a finished meal does.
Returns
void
beginItemUse()
beginItemUse(
tick):void
Defined in: prismarine/src/Player.ts:1518
Notes that the player has started holding an item down.
Parameters
tick
number
The server tick it began on.
Returns
void
cancelConsuming()
cancelConsuming():
void
Defined in: prismarine/src/Player.ts:1492
Forgets an unfinished meal, as letting go of the button or putting the item away does.
Returns
void
claimUpdate()
claimUpdate(
tick):boolean
Defined in: prismarine/src/entity/Entity.ts:613
Claims this entity's one update of a server tick for the world asking.
The level ticks its worlds one after another, and a portal trip moves an entity from the world being ticked into one that is ticked later in the same pass. That world finds the arrival in its roster and would update it a second time. The first world claims the tick before updating; the second sees the claim and leaves the entity for the next tick.
Parameters
tick
number
The server's tick counter.
Returns
boolean
True the first time a world asks for a given tick, false for every later ask.
Inherited from
Human.claimUpdate
clearStatusEffects()
clearStatusEffects(
notify?):number
Defined in: prismarine/src/entity/Entity.ts:778
Removes every active status effect.
Parameters
notify?
boolean = true
Whether to send a removal packet for each effect.
Returns
number
The number of effects cleared.
Inherited from
completeSpawn()
completeSpawn():
Promise<void>
Defined in: prismarine/src/Player.ts:651
Finishes bringing this player into the game: position, gamemode, inventory, settings.
Returns
Promise<void>
Remarks
Named apart from Player.spawnTo on purpose. This used to be called sendSpawn, overriding the entity method of that name with a different signature and an unrelated meaning - one is "put me into the world", the other is "show me to somebody". Adding a player to a world therefore ran this by accident.
consumesFood()
consumesFood():
boolean
Defined in: prismarine/src/Player.ts:1297
Whether the player's actions cost food at all.
Creative and spectator players are fed by definition in vanilla, and draining their bar would only show up as a client-side flicker: the bar is not even drawn for them.
Returns
boolean
true if hunger applies to this player.
damage()
damage(
amount,source?):Promise<boolean>
Defined in: prismarine/src/Player.ts:1191
Hurt the player - unless the world cannot touch them.
The gamemode check belongs here rather than only at each call site: a creative player is unharmed by everything, not just by the two things that happen to call this today.
Parameters
amount
number
Half-hearts of damage.
source?
DamageCause | DamageSource = DamageCause.Generic
What did it, and who.
Returns
Promise<boolean>
true if any damage was actually taken.
Overrides
despawnFrom()
despawnFrom(
session):Promise<void>
Defined in: prismarine/src/Player.ts:672
Takes this entity off one client.
Parameters
session
The client to remove it from.
Returns
Promise<void>
A promise that resolves once the client has been told.
Overrides
Human.despawnFrom
getAddress()
getAddress():
InetAddress
Defined in: prismarine/src/Player.ts:745
Returns
getArmorDefensePoints()
getArmorDefensePoints():
number
Defined in: prismarine/src/entity/Human.ts:79
Armor points worn.
The last link in a chain that was complete at both ends and joined in the middle by nothing: twenty-four armor items have declared their protection since long before this, and the damage formula has known what to do with it since the pipeline was written - but there were no armor slots to read, so every blow landed as though the player were naked.
Returns
number
Points, out of twenty for a full diamond set.
Inherited from
Human.getArmorDefensePoints
getArmorToughness()
getArmorToughness():
number
Defined in: prismarine/src/entity/Human.ts:84
Armor toughness worn, which softens what a hard blow does to that armor.
Returns
number
Inherited from
Human.getArmorToughness
getBox()
getBox():
EntityBox
Defined in: prismarine/src/entity/Entity.ts:311
How big this entity is, in blocks.
Read from the minecraft:collision_box of its type in the running content build rather than from a table in this repository, so the one number is whatever the pack stack says.
Returns
The box, centered on the position and extending up from the feet.
Inherited from
Human.getBox
getCraftingInput()
getCraftingInput():
CraftingInput
Defined in: prismarine/src/entity/Human.ts:114
Returns
CraftingInput
Inherited from
Human.getCraftingInput
getDefaultPortalCooldown()
getDefaultPortalCooldown():
number
Defined in: prismarine/src/Player.ts:1273
How long this player refuses portals after a dimension change.
Half a second, where a mob waits fifteen: Player.getDimensionChangingDelay in vanilla.
Returns
number
10 ticks.
Overrides
Human.getDefaultPortalCooldown
getEquipment()
getEquipment():
ViewableEquipment
Defined in: prismarine/src/entity/Human.ts:96
What is worn and held, which is what the enchantment effect components are run over.
The armor container's four slots are helmet, chestplate, leggings and boots in the order the client numbers them, so the mapping is positional rather than looked up.
Returns
ViewableEquipment
Inherited from
Human.getEquipment
getEyeHeight()
getEyeHeight():
number
Defined in: prismarine/src/entity/Human.ts:66
How far above the feet the position this human reports is.
Returns
number
The eye height, in blocks; one place to change when a human is not the default size.
Inherited from
Human.getEyeHeight
getFallDistance()
getFallDistance():
number
Defined in: prismarine/src/Player.ts:1542
How far the player has fallen since they were last supported.
Read by the combat code: a blow struck on the way down is a critical, and "on the way down" means this is above zero rather than merely that the player is off the ground - a player rising through a jump is not falling, and vanilla does not let them crit on the way up.
Returns
number
Blocks fallen so far, or zero.
getFeetY()
getFeetY():
number
Defined in: prismarine/src/entity/Human.ts:58
The bottom of a player's body, which is EYE_HEIGHT below what they report.
This is what made a player able to shove a villager and nothing else. Comparing a player's reported height against a mob's body without taking the eyes off puts the player's "feet" at chest height, so only mobs taller than 1.62 - villagers, zombies, skeletons - overlapped them at all. Every cow, sheep, chicken and spider was, geometrically, underfoot.
Returns
number
Inherited from
Human.getFeetY
getFood()
getFood():
number
Defined in: prismarine/src/Player.ts:1305
The player's food level, out of 20 - two per drumstick on the client's bar.
Returns
number
The food level.
getFormattedUsername()
getFormattedUsername():
string
Defined in: prismarine/src/Player.ts:753
Get the entity's formatted name.
Returns
string
The entity's formatted name (including prefix & suffix).
Example
const formattedName = entity.getFormattedUsername();
console.log(`Entity formatted name: ${formattedName}`); // Entity formatted name: SheepOverrides
Human.getFormattedUsername
getHealth()
getHealth():
number
Defined in: prismarine/src/entity/Entity.ts:691
The entity's health, out of Entity.getMaxHealth.
Health is an attribute, not a field beside one: it is the same number the client draws its hearts from, so there is nowhere for the two to disagree.
Returns
number
The health.
Inherited from
Human.getHealth
getHeldItem()
getHeldItem():
Item|null
Defined in: prismarine/src/entity/Entity.ts:331
What this entity is holding, for whoever has to draw it.
Returns
Item | null
The item, or null for empty hands.
Inherited from
getInventory()
getInventory():
HumanInventory
Defined in: prismarine/src/entity/Human.ts:110
Returns
HumanInventory
Inherited from
Human.getInventory
getJoinSpawn()
getJoinSpawn():
PlayerSpawn|null
Defined in: prismarine/src/Player.ts:207
Where this player was placed on joining, or null when they came back to a saved position.
Returns
PlayerSpawn | null
getLastDamageSource()
getLastDamageSource():
DamageSource|null
Defined in: prismarine/src/entity/Entity.ts:1123
What last hurt this entity, if anything has.
How a mob knows who to fight back against, and how a death is reported as the work of somebody rather than of nothing in particular.
Returns
DamageSource | null
The last source, or null if it has never been hurt.
Inherited from
getMaxHealth()
getMaxHealth():
number
Defined in: prismarine/src/entity/Entity.ts:699
The most health this entity can have.
Returns
number
The maximum health.
Inherited from
Human.getMaxHealth
getMining()
getMining():
BlockMining|null
Defined in: prismarine/src/Player.ts:215
The block this player is mining, or null.
Returns
BlockMining | null
getName()
getName():
string
Defined in: prismarine/src/Player.ts:749
Get the entity's (potentially custom) name.
Returns
string
The entity's name without formatting (usually prefix & suffix).
Example
const name = entity.getName();
console.log(`Entity name: ${name}`);Overrides
Human.getName
getNearestEntity()
getNearestEntity(
entities?):Entity[]
Defined in: prismarine/src/entity/Entity.ts:484
Returns the nearest entity from the current entity.
Parameters
entities?
Entity[] = ...
The entities to compare the distance between.
Returns
Entity[]
The nearest entity.
Todo
Customizable radius
Example
const nearestEntity = entity.getNearestEntity();
console.log('Nearest entity:', nearestEntity);Inherited from
Human.getNearestEntity
getNetworkSession()
getNetworkSession():
PlayerSession
Defined in: prismarine/src/Player.ts:740
Returns
getPermissions()
getPermissions():
string[]
Defined in: prismarine/src/Player.ts:762
Get the player's current permissions, read from the permission manager on every call so a revoked operator status or grant applies at once.
Returns
string[]
The player's effective permissions.
getPortalCooldown()
getPortalCooldown():
number
Defined in: prismarine/src/entity/Entity.ts:581
Ticks left before this entity may enter a portal again.
Returns
number
Inherited from
Human.getPortalCooldown
getPortalTransitionTicks()
getPortalTransitionTicks(
rule?):number
Defined in: prismarine/src/Player.ts:1261
Ticks this player has to stand in a portal before going through.
Vanilla reads players_nether_portal_creative_delay (0) for a creative player and players_nether_portal_default_delay (80) for everyone else; the game rules are not modeled yet, so the portal rule's defaults are the answer. An end portal's rule says 0 for both.
Parameters
rule?
PortalRule
The rule of the portal stood in. Without one, a nether portal is assumed.
Returns
number
0 in creative, otherwise the rule's survival delay, 80 for a nether portal.
Overrides
Human.getPortalTransitionTicks
getPosition()
getPosition():
Position
Defined in: prismarine/src/entity/Entity.ts:453
Get the entity's position.
Returns
Where the entity is, and in which world.
Remarks
The stored position, not a copy. It is safe to hand out because a position derives new instances instead of mutating itself, so a caller cannot move the entity through it. Previously this built a fresh Vector3 on every call - one allocation per packet - and that vector had dropped the world, so getWorld() on it was unavailable.
Example
const position = entity.getPosition();Inherited from
Human.getPosition
getRespawnPoint()
getRespawnPoint():
Promise<RespawnDestination>
Defined in: prismarine/src/Player.ts:1065
Where this player comes back after a death, given as a Bedrock Dedicated Server gives it.
Their own spawn point when they have one that still holds, in the world it was set in, which need not be the one they died in: a player who dies in the Nether with an Overworld bed comes back in the Overworld, as Java's findRespawnPositionAndUseSpawnBlock has it. Otherwise the Overworld spawn of the default level, which is Java's server.overworld(). A bed or a respawn anchor only holds a spawn while the block is still there with somewhere free to stand beside it, which is Java's rule and is what resolveRespawn decides; a point /spawnpoint set is used whatever is standing there. A spawn that stopped holding is cleared here, so the player is told once rather than on every death.
The caller compares world with the player's own and changes world first when they differ: see RespawnHandler.
Returns
Promise<RespawnDestination>
See
respawnPoint for the three positions the exchange needs.
getRuntimeId()
getRuntimeId():
bigint
Defined in: prismarine/src/entity/Entity.ts:437
Get the entity's runtime id.
Returns
bigint
The entity's runtime id.
Example
const entityId = entity.getRuntimeId();
console.log(entityId); // Ex. Output: 1nInherited from
Human.getRuntimeId
getSaturation()
getSaturation():
number
Defined in: prismarine/src/Player.ts:1321
The player's saturation - the hidden buffer that is spent before food is.
Returns
number
The saturation level.
getServer()
getServer():
Server
Defined in: prismarine/src/entity/Entity.ts:1167
Get the server instance.
Returns
The server instance.
Example
const server = entity.getServer();
// Do things with the server.Inherited from
Human.getServer
getSpawnPoint()
getSpawnPoint():
StoredSpawnPoint|undefined
Defined in: prismarine/src/Player.ts:1018
This player's own spawn point, or undefined when they come back at the world spawn.
Returns
StoredSpawnPoint | undefined
getStatusEffect()
getStatusEffect(
identifier):StatusEffect|undefined
Defined in: prismarine/src/entity/Entity.ts:724
Reads one active effect by its namespaced id or bare Bedrock effect name.
Parameters
identifier
string
The effect name.
Returns
StatusEffect | undefined
The active effect, or undefined when it is absent.
Inherited from
getStatusEffects()
getStatusEffects(): readonly
StatusEffect[]
Defined in: prismarine/src/entity/Entity.ts:715
The active effects this entity currently carries.
Returns
readonly StatusEffect[]
A snapshot of the active effect instances.
Inherited from
getSyncedProperties()
getSyncedProperties():
SyncedProperties
Defined in: prismarine/src/entity/Entity.ts:1024
The properties this actor sends alongside its metadata.
Most entities do not have data-driven properties. Data-driven entity bodies override this with their current client-synced values.
Returns
SyncedProperties
The actor's current property snapshot.
Inherited from
Human.getSyncedProperties
getTags()
getTags(): readonly
string[]
Defined in: prismarine/src/entity/Entity.ts:1375
The /tag tags this entity carries, in the order they were added.
Returns
readonly string[]
Inherited from
getTrackingInterval()
getTrackingInterval():
number
Defined in: prismarine/src/Player.ts:789
Players move constantly and are the entity everyone is looking at.
Returns
number
The interval in ticks.
Overrides
Human.getTrackingInterval
getTrackingRange()
getTrackingRange():
number
Defined in: prismarine/src/Player.ts:781
Players are followed as far as the viewer can see.
Deliberately past any plausible view distance, so the recipient's own radius is always what decides. Vanilla uses the same trick for the same reason.
Returns
number
The tracking radius in chunks.
Overrides
Human.getTrackingRange
getType()
getType():
string
Defined in: prismarine/src/entity/Entity.ts:413
Returns
string
Inherited from
Human.getType
getUUID()
getUUID():
UUID
Defined in: prismarine/src/Player.ts:805
Get the identity the client logged in with.
Returns
UUID
The player's UUID.
Example
console.log(player.getUUID().toString());getVelocity()
getVelocity():
Vector3
Defined in: prismarine/src/entity/Entity.ts:461
The actor's current velocity in blocks per tick, or zero when it has none.
Returns
The actor's current velocity.
Inherited from
Human.getVelocity
getWorld()
getWorld():
World
Defined in: prismarine/src/entity/Entity.ts:469
Gets the world the entity is currently in.
Returns
The world.
Inherited from
Human.getWorld
getXUID()
getXUID():
string|null
Defined in: prismarine/src/Player.ts:770
Get the XUID of the player.
Returns
string | null
XUID of the player or null if not available
hasSeenCredits()
hasSeenCredits():
boolean
Defined in: prismarine/src/Player.ts:1032
Whether this player has watched the end credits, so a later End exit skips them.
Returns
boolean
hasStatusEffect()
hasStatusEffect(
identifier):boolean
Defined in: prismarine/src/entity/Entity.ts:733
Whether one status effect is active.
Parameters
identifier
string
The effect name.
Returns
boolean
Whether it is active.
Inherited from
Human.hasStatusEffect
heal()
heal(
amount):Promise<boolean>
Defined in: prismarine/src/entity/Entity.ts:1137
Heal the entity, up to its maximum.
Parameters
amount
number
Half-hearts to restore. Ignored if not positive.
Returns
Promise<boolean>
true if any health was actually restored.
Inherited from
Human.heal
isAlive()
isAlive():
boolean
Defined in: prismarine/src/entity/Entity.ts:707
Whether the entity has any health left.
Returns
boolean
true while it is alive.
Inherited from
Human.isAlive
isFlying()
isFlying():
boolean
Defined in: prismarine/src/Player.ts:1408
Returns
boolean
isInvulnerableToHits()
isInvulnerableToHits():
boolean
Defined in: prismarine/src/entity/Entity.ts:1128
Whether the entity is still inside the grace period after a hit.
Returns
boolean
Inherited from
Human.isInvulnerableToHits
isOnGround()
isOnGround():
boolean
Defined in: prismarine/src/Player.ts:1446
Whether this entity is standing on something.
What MoveActorAbsolutePacket's on-ground flag carries, and what the is_on_ground predicate reads. False for anything nothing keeps the state for, which is every entity but a data-driven mob and a player: a projectile in flight and a dropped item are both drawn by the client from its own guess, as they were before the flag was sent at all.
Returns
boolean
Whether it is grounded.
Overrides
Human.isOnGround
isOnline()
isOnline():
boolean
Defined in: prismarine/src/Player.ts:557
Returns
boolean
isOnPortalCooldown()
isOnPortalCooldown():
boolean
Defined in: prismarine/src/entity/Entity.ts:598
Whether this entity is still refusing portals after a recent dimension change.
Returns
boolean
Inherited from
Human.isOnPortalCooldown
isOp()
isOp():
boolean
Defined in: prismarine/src/Player.ts:813
Check if the Player is an operator.
Returns
boolean
true if this player is an operator otherwise false.
isSleeping()
isSleeping():
boolean
Defined in: prismarine/src/Player.ts:1437
Whether the client has reported this player asleep in a bed.
Returns
boolean
isSneaking()
isSneaking():
boolean
Defined in: prismarine/src/Player.ts:1428
Returns
boolean
isVulnerable()
isVulnerable():
boolean
Defined in: prismarine/src/Player.ts:1247
Whether the world can hurt this player at all.
Creative and spectator players do not drown, starve or take damage in vanilla, which is one condition and not three.
Returns
boolean
true if the player can be harmed.
kick()
kick(
reason?,code?):Promise<void>
Defined in: prismarine/src/Player.ts:612
Removes the player from the server and tells the client why.
Parameters
reason?
string = 'unknown reason'
Shown to the client.
code?
DisconnectReason = DisconnectReason.KICKED
The code the client shows beside the reason. Server.shutdown passes SHUTDOWN.
Returns
Promise<void>
Remarks
Torn down through the connection rather than by calling disable directly, so that the player and its session are released together and exactly once, and so the RakNet session is hung up on rather than left for the client to close.
That last part used to be left out: a kick sent the DisconnectPacket and stopped there, on the assumption the client would hang up on seeing it. A vanilla client does. Anything that does not - the bot harness, which after the login sequence has nobody subscribed to the packet, and which keeps pinging - held its slot and its place in the player count for as long as the process ran, because the pings kept the session from ever timing out.
occupiesSpace()
occupiesSpace():
boolean
Defined in: prismarine/src/entity/Human.ts:46
Mobs are shoved out of a player's way.
Only ever in that direction: a player's position comes from their own client, so the server moving them would be overruled on the next movement packet and read as rubber-banding. The player displaces mobs; nothing displaces the player.
Returns
boolean
Inherited from
Human.occupiesSpace
portalContact()
portalContact():
PortalContact|undefined
Defined in: prismarine/src/entity/Entity.ts:622
The portal this entity is currently in contact with, if any.
Returns
PortalContact | undefined
Inherited from
removeStatusEffect()
removeStatusEffect(
identifier,notify?):boolean
Defined in: prismarine/src/entity/Entity.ts:764
Removes one status effect.
Parameters
identifier
string
The effect name.
notify?
boolean = true
Whether to send a removal packet.
Returns
boolean
Whether an active effect was removed.
Inherited from
removeTag()
removeTag(
tag):boolean
Defined in: prismarine/src/entity/Entity.ts:1370
Removes one of /tag's tags.
Parameters
tag
string
The tag.
Returns
boolean
true when the entity carried it.
Inherited from
Human.removeTag
respawn()
respawn():
Promise<void>
Defined in: prismarine/src/Player.ts:1148
Brings the player back after a death, at the world spawn and in one piece.
Returns
Promise<void>
Remarks
Called when the client asks, not when the player dies - the death screen is the client's, and it decides how long it stays up. The client reports ClientReadyToSpawn before it sends this, and has already put itself where the answer to that said: see RespawnHandler.
sendInitialSpawnChunks()
sendInitialSpawnChunks():
Promise<void>
Defined in: prismarine/src/Player.ts:508
Used to match vanilla behavior, will send chunks with an initial view radius of DEFAULT_VIEW_DISTANCE_CHUNKS.
Returns
Promise<void>
sendMessage()
sendMessage(
message,type?,parameters?,needsTranslation?):Promise<void>
Defined in: prismarine/src/Player.ts:686
Sends a line of text to this player's client.
type picks how the client renders it. A JSON text object goes as TextPacketType.TextObject; a translation key with its parameters as TextPacketType.Translate.
Parameters
message
string
The text, or the translation key for a translated type.
type?
TextPacketType = TextPacketType.Raw
How the client renders the message. Raw by default.
parameters?
string[] = []
The values a translated type fills its key with.
needsTranslation?
boolean = false
Whether the client should translate the message.
Returns
Promise<void>
sendSettings()
sendSettings():
Promise<void>
Defined in: prismarine/src/Player.ts:627
Sends this player's gamemode, adventure settings and abilities where each belongs.
The two halves have different audiences, and sending both to everyone was a bug. UpdateAdventureSettingsPacket carries no target actor - it describes the client receiving it and nothing else - so pushing one player's settings to every session made a single spectator set worldImmutable on everybody else's client. It goes to this player alone. UpdateAbilitiesPacket does carry targetActorUniqueId, so it is genuinely about this player and belongs with everyone who can see them.
Returns
Promise<void>
setEquipment()
setEquipment(
equipment):this
Defined in: prismarine/src/entity/Entity.ts:357
Replaces everything this entity is holding and wearing.
Stored rather than broadcast, for the reason Entity.setHeldItem is. The two places that put it on the wire are PlayerSession.sendAddActor, for a client being shown the entity, and WorldChangeSink.entityEquipmentChanged, for one already holding it.
Parameters
equipment
ViewableEquipment
The new set, replacing the old one whole.
Returns
this
The entity, so a caller can chain.
Inherited from
setFlying()
setFlying(
flying):Promise<void>
Defined in: prismarine/src/Player.ts:1411
Parameters
flying
boolean
Returns
Promise<void>
setFood()
setFood(
food):void
Defined in: prismarine/src/Player.ts:1313
Set the player's food level. Clamped to 0..20, and sent on the next tick.
Parameters
food
number
The wanted food level.
Returns
void
setGamemode()
setGamemode(
mode?):Promise<void>
Defined in: prismarine/src/Player.ts:700
Parameters
mode?
Returns
Promise<void>
setGrounded()
setGrounded(
grounded):this
Defined in: prismarine/src/entity/Entity.ts:384
Records whether this entity is standing on something.
Named apart from Player.setOnGround, which is the client reporting it for its own entity and which also pays out the fall damage the landing earned. This one is the server's own answer for an entity it is moving itself.
Parameters
grounded
boolean
Whether it is standing on something.
Returns
this
The entity, so a caller can chain.
Inherited from
setHealth()
setHealth(
health,source?):Promise<void>
Defined in: prismarine/src/entity/Entity.ts:792
Set the entity's health, killing it if that leaves it at zero.
Parameters
health
number
The wanted health; clamped to the attribute's bounds.
source?
DamageCause | DamageSource = DamageCause.Generic
What to report as the cause if this kills it.
Returns
Promise<void>
Inherited from
setHeldItem()
setHeldItem(
item):this
Defined in: prismarine/src/entity/Entity.ts:344
Puts something in this entity's hand.
Stored rather than broadcast, because an entity is often given its item before it is in a world and there is nobody to tell. Everyone who can see it is told when it is spawned to them - see PlayerSession.sendAddActor.
Parameters
item
Item | null
What to hold.
Returns
this
The entity, so a caller can chain.
Inherited from
setMining()
setMining(
mining):void
Defined in: prismarine/src/Player.ts:223
Sets what this player is mining.
Parameters
mining
BlockMining | null
The block, or null when the player stopped or broke it.
Returns
void
setName()
setName(
name):void
Defined in: prismarine/src/entity/Entity.ts:1345
Set the entity's name.
Parameters
name
string
The name.
Returns
void
Example
entity.setName('Mr. Sheep');Inherited from
Human.setName
setOnGround()
setOnGround(
val):Promise<void>
Defined in: prismarine/src/Player.ts:1449
Parameters
val
boolean
Returns
Promise<void>
setPlayerPosition()
setPlayerPosition(
options,broadcast?):Promise<void>
Defined in: prismarine/src/Player.ts:1631
Set the position with a movement mode.
Parameters
options
The options to set the position.
headYaw?
number = ...
The new head yaw.
pitch?
number = ...
The new pitch.
position
The new position.
type?
PositionMode = PositionMode.Normal
The position mode.
yaw?
number = ...
The new yaw.
broadcast?
boolean = true
Whether to tell the player's own client.
Returns
Promise<void>
A promise that resolves when the position is set.
Remarks
Observers snap to a respawn or a teleport instead of interpolating to it.
setPortalCooldown()
setPortalCooldown(
ticks?):void
Defined in: prismarine/src/entity/Entity.ts:591
Starts the portal cooldown.
Called on departure, and by the serializer when restoring a saved actor.
Parameters
ticks?
number = ...
The cooldown in ticks. Defaults to Entity.getDefaultPortalCooldown.
Returns
void
Inherited from
Human.setPortalCooldown
setPosition()
setPosition(
options):Promise<void>
Defined in: prismarine/src/Player.ts:1615
Moves the player as an Entity move: a step, or a teleport when teleport is set.
Parameters
options
The position, rotation and whether to snap.
Returns
Promise<void>
A promise that resolves when the player's client has been told.
Remarks
Player.setPlayerPosition takes the movement mode and the broadcast choice.
Overrides
Human.setPosition
setSaturation()
setSaturation(
saturation):void
Defined in: prismarine/src/Player.ts:1330
Set the player's saturation. Saturation never exceeds the current food level in vanilla, so it is capped there as well as at the attribute's own maximum.
Parameters
saturation
number
The wanted saturation.
Returns
void
setSeenCredits()
setSeenCredits(
seen):void
Defined in: prismarine/src/Player.ts:1044
Records whether this player has watched the end credits.
Set when the credits start rather than when they finish, as Java's showEndCredits does: a client that disconnects mid-credits comes back in the End with the flag kept, and its next exit transfers without a replay.
Parameters
seen
boolean
False puts the credits back on the next End exit.
Returns
void
setSleeping()
setSleeping(
sleeping):void
Defined in: prismarine/src/Player.ts:1442
Records the client's bed-sleeping action for entity filters and goals.
Parameters
sleeping
boolean
Returns
void
setSneaking()
setSneaking(
val):Promise<void>
Defined in: prismarine/src/Player.ts:1431
Parameters
val
boolean
Returns
Promise<void>
setSpawnPoint()
setSpawnPoint(
spawn):void
Defined in: prismarine/src/Player.ts:1027
Moves this player's own spawn point, or clears it back to the world spawn.
Parameters
spawn
StoredSpawnPoint | undefined
The block that holds it, or undefined to go back to the world spawn.
Returns
void
setSprinting()
setSprinting(
sprinting):Promise<void>
Defined in: prismarine/src/Player.ts:1397
Parameters
sprinting
boolean
Returns
Promise<void>
setWorld()
setWorld(
world):Promise<void>
Defined in: prismarine/src/Player.ts:548
Moves the player to another world, arriving at that world's spawn.
The stored spawn is the block under a joining player's feet, so the feet go one block above it, centered, as requestedSpawnPosition says before the terrain is consulted. The sequence lives in PlayerSession.changeWorld; this is the entry point for callers that have a world and no arrival of their own, such as a teleport between worlds, which moves the player again once the change completes.
Parameters
world
the new world
Returns
Promise<void>
setX()
setX(
x,suppress?):Promise<void>
Defined in: prismarine/src/entity/Entity.ts:1252
Set the x position.
Parameters
x
number
The x coordinate.
suppress?
boolean = false
If true, the client won't be notified about the position change.
Returns
Promise<void>
A promise that resolves when the x position is set.
Example
await entity.setX(10);Remarks
This method will also send the position update to the client if suppress is false. The test read the flag the wrong way round, so it notified only when asked not to - which, since nothing passed the flag, meant an entity could be moved anywhere without a single client hearing about it.
Inherited from
setY()
setY(
y,suppress?):Promise<void>
Defined in: prismarine/src/entity/Entity.ts:1268
Set the y position.
Parameters
y
number
The y coordinate.
suppress?
boolean = false
If true, the client won't be notified about the position change.
Returns
Promise<void>
A promise that resolves when the y position is set.
Example
await entity.setY(10);Remarks
This method will also send the position update to the client if suppress is false.
Inherited from
setZ()
setZ(
z,suppress?):Promise<void>
Defined in: prismarine/src/entity/Entity.ts:1284
Set the z position.
Parameters
z
number
The z coordinate.
suppress?
boolean = false
If true, the client won't be notified about the position change.
Returns
Promise<void>
A promise that resolves when the z position is set.
Example
await entity.setZ(10);Remarks
This method will also send the position update to the client if suppress is false.
Inherited from
shouldPersist()
shouldPersist():
boolean
Defined in: prismarine/src/entity/Entity.ts:680
Whether the world should include this entity in saved actor records.
Most entities survive a world save. A data-driven entity can opt out with Bedrock's minecraft:transient component.
Returns
boolean
Whether this entity should be persisted.
Inherited from
Human.shouldPersist
spawnTo()
spawnTo(
session):Promise<void>
Defined in: prismarine/src/Player.ts:668
A player appears to other clients as a player, not as a generic actor.
Parameters
session
The client to show it to.
Returns
Promise<void>
Overrides
Human.spawnTo
stopMining()
stopMining():
Promise<void>
Defined in: prismarine/src/Player.ts:233
Stops the cracks on the block this player was mining, if any, and forgets it.
For whatever ends the mining without the client saying so: a disconnect, a death, a change of game mode or of world. Left alone, the cracks would go out every tick for good.
Returns
Promise<void>
takeItemUseTicks()
takeItemUseTicks(
tick):number
Defined in: prismarine/src/Player.ts:1527
How long the current use has lasted, in ticks, and forgets it.
Parameters
tick
number
The server tick it ended on.
Returns
number
Ticks held, or zero if nothing was being held.
toString()
toString():
string
Defined in: prismarine/src/entity/Entity.ts:424
Convert to a string representation.
Returns
string
The string.
console.log(entity.toString());Inherited from
touchPortal()
touchPortal(
at,portal?):void
Defined in: prismarine/src/entity/Entity.ts:638
Records that this entity overlaps a portal block on the current tick.
The world calls this once per tick for each entity whose box overlaps a portal. The first call opens the contact; later calls refresh it. A touch while on cooldown opens nothing and winds the cooldown back to its full length instead, as Java's Entity.setAsInsidePortal does, so an entity that has just arrived only travels again after it has left the portal for the whole cooldown and stepped back in.
Parameters
at
Where the entity stands, kept as the contact's entry position.
portal?
PortalBlockRef
The portal block overlapped, which the trip is resolved from. Without one the contact counts but never travels.
Returns
void
Inherited from
Human.touchPortal
update()
update(
tick):Promise<void>
Defined in: prismarine/src/Player.ts:561
Fired every tick by the world.
Subclasses that override this must call up, or the grace period after a hit never runs down and the entity becomes permanently unhurtable after the first blow.
Parameters
tick
number
Returns
Promise<void>
A promise that resolves when the update is complete.
Example
entity.update(10);Overrides
Human.update
Lifecycle
disable()
disable():
Promise<void>
Defined in: prismarine/src/Player.ts:434
On disable hook.
Returns
Promise<void>
Remarks
Idempotent, and paired with Player.enable: everything enable claimed is released here and nothing else is. Taking the session out of the chunk scheduler is the session's own business - see PlayerSession.disable - so that a player and its client are torn down by whoever owns each.
enable()
enable():
Promise<void>
Defined in: prismarine/src/Player.ts:326
On enable hook: loads what the server knows about this player and marks them connected.
Returns
Promise<void>
Remarks
Sends nothing. This runs from LoginHandler, before the client has been told its login succeeded, and a retail client at protocol 2193 that is handed game packets in that state drops the connection with InitialConnection-90 (bad packet). It used to send the gamemode, adventure settings and abilities from here, and a MovePlayer for every other player in the world - the first three now go out from the join burst after StartGame, and the last was never needed: AddPlayer carries each player's position when they come into view.