Skip to content

API reference / @jsprismarine/prismarine / player/PlayerSession

player/PlayerSession ​

Classes ​

Interfaces ​

Arrival ​

Defined in: packages/prismarine/src/player/PlayerSession.ts:155

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 EYE_HEIGHT), so changeWorld raises the arrival once, and ChangeDimensionPacket and the MovePlayer teleport at the end of the change both carry those eyes.

Extended by ​

Properties ​

closesLoadingScreen? ​

optional closesLoadingScreen?: boolean

Defined in: packages/prismarine/src/player/PlayerSession.ts:168

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: packages/prismarine/src/player/PlayerSession.ts:161

position ​

position: Vector3

Defined in: packages/prismarine/src/player/PlayerSession.ts:159

Feet position in world, never the eyes.

respawn? ​

optional respawn?: boolean

Defined in: packages/prismarine/src/player/PlayerSession.ts:163

Whether the change follows a death rather than a portal or a teleport. Defaults to false.

world ​

world: World

Defined in: packages/prismarine/src/player/PlayerSession.ts:157

The world the player arrives in.

yaw ​

yaw: number

Defined in: packages/prismarine/src/player/PlayerSession.ts:160


OpenBlockContainer ​

Defined in: packages/prismarine/src/player/PlayerSession.ts:218

A screen a block opened for one player, as the session remembers it.

Properties ​

bookshelfPower ​

bookshelfPower: number

Defined in: packages/prismarine/src/player/PlayerSession.ts:241

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 ​

readonly identifier: string

Defined in: packages/prismarine/src/player/PlayerSession.ts:224

The block standing there when it was opened.

inputs ​

readonly inputs: (Item | null)[]

Defined in: packages/prismarine/src/player/PlayerSession.ts:234

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.

loomSelection? ​

optional loomSelection?: object

Defined in: packages/prismarine/src/player/PlayerSession.ts:260

A loom's patterns the player may pick from, and the one picked, by its place among them, or -1 for none. Undefined until the loom's slots first change.

patterns ​

readonly patterns: readonly string[]

selected ​

selected: number

mount? ​

readonly optional mount?: OpenMount

Defined in: packages/prismarine/src/player/PlayerSession.ts:245

Set when the window is the inventory screen of the mount the player rides.

pickedOffer? ​

optional pickedOffer?: number

Defined in: packages/prismarine/src/player/PlayerSession.ts:255

The offer of a trade screen the player picked, by its place in the offers, or undefined until a Java client picks one. A pick past the first is the only offer its payment pays for.

pickedRecipe? ​

optional pickedRecipe?: number

Defined in: packages/prismarine/src/player/PlayerSession.ts:265

The stonecutter recipe the player picked, by its place in the list the input is cut by, or undefined before a stack first goes in, and -1 once the list changed with none picked.

position ​

readonly position: Vector3

Defined in: packages/prismarine/src/player/PlayerSession.ts:222

The block it belongs to, which is what an enchanting table needs to count bookshelves.

screen ​

readonly screen: WindowTypes

Defined in: packages/prismarine/src/player/PlayerSession.ts:226

The Container Type the client is drawing.

trade? ​

readonly optional trade?: OpenTrade

Defined in: packages/prismarine/src/player/PlayerSession.ts:243

Set when the window is a villager's trade screen rather than a block's container.

typedName? ​

optional typedName?: string

Defined in: packages/prismarine/src/player/PlayerSession.ts:250

The name the player typed into an anvil's field, or undefined until the client sends one. A Java client sends it with every change, and with the item's own name as the item goes in.

windowId ​

readonly windowId: number

Defined in: packages/prismarine/src/player/PlayerSession.ts:220

The Container Id it was opened under.


OpenMount ​

Defined in: packages/prismarine/src/player/PlayerSession.ts:269

The mount a mount's inventory screen is open on, and where the screen keeps each slot.

Properties ​

columns ​

readonly columns: number

Defined in: packages/prismarine/src/player/PlayerSession.ts:279

How many columns of chest slots the screen shows, three rows each.

entity ​

readonly entity: bigint

Defined in: packages/prismarine/src/player/PlayerSession.ts:271

The mount's runtime id.

slots ​

readonly slots: readonly (number | undefined)[]

Defined in: packages/prismarine/src/player/PlayerSession.ts:277

The mount's inventory container slot behind each of the screen's own slots, in the screen's order: the saddle, the armor or carpet, then the chest slots. A slot the mount lacks, such as a llama's saddle, is undefined and shows empty.


OpenTrade ​

Defined in: packages/prismarine/src/player/PlayerSession.ts:306

A trade screen's trader, and what happens when the player stops trading.

Properties ​

source ​

readonly source: TradeSource

Defined in: packages/prismarine/src/player/PlayerSession.ts:310

title? ​

readonly optional title?: string

Defined in: packages/prismarine/src/player/PlayerSession.ts:309

The title of the screen as a translation key, such as entity.villager.farmer; the trader's name when absent.

trader ​

readonly trader: TradingActor

Defined in: packages/prismarine/src/player/PlayerSession.ts:307

Methods ​

context() ​

context(): TradeContext

Defined in: packages/prismarine/src/player/PlayerSession.ts:312

The player's own state the discounts read, such as Hero of the Village.

Returns ​

TradeContext

release() ​

release(): void

Defined in: packages/prismarine/src/player/PlayerSession.ts:314

Called once when the screen closes, so the trader is free to trade with someone else.

Returns ​

void

traded()? ​

optional traded(result): void

Defined in: packages/prismarine/src/player/PlayerSession.ts:316

Called after each trade that went through, for what the villager does about it.

Parameters ​
result ​

TradeResult

Returns ​

void


PendingDimensionChange ​

Defined in: packages/prismarine/src/player/PlayerSession.ts:172

A dimension change the client has not yet closed the loading screen for.

Properties ​

arrival ​

arrival: Arrival

Defined in: packages/prismarine/src/player/PlayerSession.ts:175

loadingScreenId ​

loadingScreenId: number

Defined in: packages/prismarine/src/player/PlayerSession.ts:174

The Loading Screen Id the client has to report EndLoadingScreen with.


TradeSource ​

Defined in: packages/prismarine/src/player/PlayerSession.ts:283

What a trade screen needs from the trader it is open on.

Properties ​

experience ​

readonly experience: number

Defined in: packages/prismarine/src/player/PlayerSession.ts:299

The experience the trader has earned, which a Java client draws the level bar from.

level ​

readonly level: number

Defined in: packages/prismarine/src/player/PlayerSession.ts:297

The trader's level, from one.

Methods ​

offers() ​

offers(context?): readonly LiveOffer[]

Defined in: packages/prismarine/src/player/PlayerSession.ts:288

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? ​

TradeContext

Returns ​

readonly LiveOffer[]

tierRequirements() ​

tierRequirements(): readonly number[]

Defined in: packages/prismarine/src/player/PlayerSession.ts:295

The experience each level asks for.

Returns ​

readonly number[]

trade() ​

trade(index, context?): TradeResult

Defined in: packages/prismarine/src/player/PlayerSession.ts:293

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? ​

TradeContext

Returns ​

TradeResult

Type Aliases ​

RespawnDestination ​

RespawnDestination = ReturnType<typeof respawnPoint> & object

Defined in: packages/prismarine/src/player/PlayerSession.ts:323

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 ​

readonly world: World


SessionMessage ​

SessionMessage = Pick<ShownMessage, "message"> & Partial<Omit<ShownMessage, "message">>

Defined in: packages/prismarine/src/player/PlayerSession.ts:335

A message for PlayerSession.sendMessage: the text, and what to show it as where it is not a raw line.


TradingActor ​

TradingActor = Pick<ShownActor, "getRuntimeId" | "getPosition" | "getType"> & object

Defined in: packages/prismarine/src/player/PlayerSession.ts:303

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