API reference / @jsprismarine/prismarine / network/PlayerSession
network/PlayerSession
Classes
Interfaces
Arrival
Defined in: prismarine/src/network/PlayerSession.ts:177
Where a player lands when PlayerSession.changeWorld moves them.
The position is the feet position in world, as a portal's exit, the End platform, a spawn block and /tp all produce it. A player's own position is their eyes (see import('../entity/playerEyes').EYE_HEIGHT), so changeWorld raises the arrival once, and ChangeDimensionPacket and the MovePlayer teleport at the end of the change both carry those eyes.
Properties
closesLoadingScreen?
optionalclosesLoadingScreen?:boolean
Defined in: prismarine/src/network/PlayerSession.ts:190
Whether the client closes a loading screen for this change, which the change then stays pending on. Defaults to true; a respawn after a death is the one the client does not.
pitch
pitch:
number
Defined in: prismarine/src/network/PlayerSession.ts:183
position
position:
Vector3
Defined in: prismarine/src/network/PlayerSession.ts:181
Feet position in world, never the eyes.
respawn?
optionalrespawn?:boolean
Defined in: prismarine/src/network/PlayerSession.ts:185
Whether the change follows a death rather than a portal or a teleport. Defaults to false.
world
world:
World
Defined in: prismarine/src/network/PlayerSession.ts:179
The world the player arrives in.
yaw
yaw:
number
Defined in: prismarine/src/network/PlayerSession.ts:182
OpenBlockContainer
Defined in: prismarine/src/network/PlayerSession.ts:238
A screen a block opened for one player, as the session remembers it.
Properties
bookshelfPower
bookshelfPower:
number
Defined in: prismarine/src/network/PlayerSession.ts:261
Bookshelves around an enchanting table, as the last redraw counted them.
Kept rather than recounted when a row is taken, so the rows the player was shown and the row that is applied are drawn from one number. Zero for every other screen.
identifier
readonlyidentifier:string
Defined in: prismarine/src/network/PlayerSession.ts:244
The block standing there when it was opened.
inputs
readonlyinputs: (Item|null)[]
Defined in: prismarine/src/network/PlayerSession.ts:254
The workstation's own input slots, in the order that station's recipe declares them.
They live on the window rather than on the block because they are the player's: closing the screen is what gives them back, and a second player at the same table has their own inputs.
position
readonlyposition:Vector3
Defined in: prismarine/src/network/PlayerSession.ts:242
The block it belongs to, which is what an enchanting table needs to count bookshelves.
screen
readonlyscreen:WindowTypes
Defined in: prismarine/src/network/PlayerSession.ts:246
The Container Type the client is drawing.
trade?
readonlyoptionaltrade?:OpenTrade
Defined in: prismarine/src/network/PlayerSession.ts:263
Set when the window is a villager's trade screen rather than a block's container.
windowId
readonlywindowId:number
Defined in: prismarine/src/network/PlayerSession.ts:240
The Container Id it was opened under.
OpenTrade
Defined in: prismarine/src/network/PlayerSession.ts:288
A trade screen's trader, and what happens when the player stops trading.
Properties
source
readonlysource:TradeSource
Defined in: prismarine/src/network/PlayerSession.ts:292
title?
readonlyoptionaltitle?:string
Defined in: prismarine/src/network/PlayerSession.ts:291
The title of the screen as a translation key, such as entity.villager.farmer; the trader's name when absent.
trader
readonlytrader:TradingActor
Defined in: prismarine/src/network/PlayerSession.ts:289
Methods
context()
context():
TradeContext
Defined in: prismarine/src/network/PlayerSession.ts:294
The player's own state the discounts read, such as Hero of the Village.
Returns
release()
release():
void
Defined in: prismarine/src/network/PlayerSession.ts:296
Called once when the screen closes, so the trader is free to trade with someone else.
Returns
void
traded()?
optionaltraded(result):void
Defined in: prismarine/src/network/PlayerSession.ts:298
Called after each trade that went through, for what the villager does about it.
Parameters
result
Returns
void
PendingDimensionChange
Defined in: prismarine/src/network/PlayerSession.ts:194
A dimension change the client has not yet closed the loading screen for.
Properties
arrival
arrival:
Arrival
Defined in: prismarine/src/network/PlayerSession.ts:197
loadingScreenId
loadingScreenId:
number
Defined in: prismarine/src/network/PlayerSession.ts:196
The Loading Screen Id the client has to report EndLoadingScreen with.
TradeSource
Defined in: prismarine/src/network/PlayerSession.ts:267
What a trade screen needs from the trader it is open on.
Properties
level
readonlylevel:number
Defined in: prismarine/src/network/PlayerSession.ts:281
The trader's level, from one.
Methods
offers()
offers(
context?): readonlyLiveOffer[]
Defined in: prismarine/src/network/PlayerSession.ts:272
The offers with the prices the player pays now. A change this makes to the trader, such as a cured discount drawn on the first ask, is logged as the trader's merchant field.
Parameters
context?
Returns
readonly LiveOffer[]
tierRequirements()
tierRequirements(): readonly
number[]
Defined in: prismarine/src/network/PlayerSession.ts:279
The experience each level asks for.
Returns
readonly number[]
trade()
trade(
index,context?):TradeResult
Defined in: prismarine/src/network/PlayerSession.ts:277
Runs one trade; see Merchant.trade. The trade has to log the trader's merchant field: that entry is what sends an open screen its new offers, and nothing else redraws it.
Parameters
index
number
context?
Returns
Type Aliases
MovedActor
MovedActor =
Pick<ShownActor,"getRuntimeId"|"getPosition"|"pitch"|"yaw"|"headYaw"|"isOnGround">
Defined in: prismarine/src/network/PlayerSession.ts:334
What a move packet reads of the actor that moved: its id, where it is, where it faces and whether it stands.
RespawnDestination
RespawnDestination =
ReturnType<typeofrespawnPoint> &object
Defined in: prismarine/src/network/PlayerSession.ts:315
Where a player comes back after a death: the world, and the three positions the respawn exchange needs in it. See respawnPoint for what each position is.
Type Declaration
world
readonlyworld:World
TradingActor
TradingActor =
Pick<ShownActor,"getRuntimeId"|"getPosition"|"getType"> &object
Defined in: prismarine/src/network/PlayerSession.ts:285
What a trade screen reads of its trader: the actor the screen is bound to, and its name for the title.
Type Declaration
getName()
getName():
string
Returns
string