Skip to content

API reference / @jsprismarine/prismarine / command/host/support

command/host/support ​

Interfaces ​

CommandPlayer ​

Defined in: packages/prismarine/src/command/host/support.ts:259

What a command reads and changes of a player target: its game mode, inventory, experience, attributes, spawn point and position. What it sends goes through the player's session; see resolveTarget.

Properties ​

attributes ​

readonly attributes: object

Defined in: packages/prismarine/src/command/host/support.ts:266

getValue() ​

getValue(id): number

Parameters ​
id ​

string

Returns ​

number

gamemode ​

readonly gamemode: number

Defined in: packages/prismarine/src/command/host/support.ts:264

Methods ​

getExperience() ​

getExperience(): ExperienceHolder

Defined in: packages/prismarine/src/command/host/support.ts:268

Returns ​

ExperienceHolder

getFormattedUsername() ​

getFormattedUsername(): string

Defined in: packages/prismarine/src/command/host/support.ts:262

Returns ​

string

getInventory() ​

getInventory(): HumanInventory

Defined in: packages/prismarine/src/command/host/support.ts:269

Returns ​

HumanInventory

getName() ​

getName(): string

Defined in: packages/prismarine/src/command/host/support.ts:261

Returns ​

string

getRuntimeId() ​

getRuntimeId(): bigint

Defined in: packages/prismarine/src/command/host/support.ts:260

Returns ​

bigint

getWorld() ​

getWorld(): World

Defined in: packages/prismarine/src/command/host/support.ts:263

Returns ​

World

setAttributeValue() ​

setAttributeValue(name, value): boolean

Defined in: packages/prismarine/src/command/host/support.ts:267

Parameters ​
name ​

string

value ​

number

Returns ​

boolean

setGamemode() ​

setGamemode(mode?): Promise<void>

Defined in: packages/prismarine/src/command/host/support.ts:265

Parameters ​
mode? ​

number

Returns ​

Promise<void>

setPlayerPosition() ​

setPlayerPosition(move): Promise<void>

Defined in: packages/prismarine/src/command/host/support.ts:271

Parameters ​
move ​
headYaw? ​

number

pitch? ​

number

position ​

Vector3

type? ​

MoveMode

yaw? ​

number

Returns ​

Promise<void>

setSpawnPoint() ​

setSpawnPoint(spawn): void

Defined in: packages/prismarine/src/command/host/support.ts:270

Parameters ​
spawn ​

StoredSpawnPoint | undefined

Returns ​

void

setWorld() ​

setWorld(world): void

Defined in: packages/prismarine/src/command/host/support.ts:278

Parameters ​
world ​

World

Returns ​

void


CommandTarget ​

Defined in: packages/prismarine/src/command/host/support.ts:282

A player target a command changes and then tells: the session and the player behind it.

Properties ​

player ​

readonly player: CommandPlayer

Defined in: packages/prismarine/src/command/host/support.ts:284

session ​

readonly session: PlayerSession

Defined in: packages/prismarine/src/command/host/support.ts:283


ReferencedEntity ​

Defined in: packages/prismarine/src/command/host/support.ts:181

What entityRefOf reads of an entity.

Extended by ​

Properties ​

pitch ​

readonly pitch: number

Defined in: packages/prismarine/src/command/host/support.ts:188

yaw ​

readonly yaw: number

Defined in: packages/prismarine/src/command/host/support.ts:187

Methods ​

getFeetY() ​

getFeetY(): number

Defined in: packages/prismarine/src/command/host/support.ts:186

Returns ​

number

getName() ​

getName(): string

Defined in: packages/prismarine/src/command/host/support.ts:184

Returns ​

string

getPosition() ​

getPosition(): object

Defined in: packages/prismarine/src/command/host/support.ts:185

Returns ​

object

getX() ​

getX(): number

Returns ​

number

getZ() ​

getZ(): number

Returns ​

number

getRuntimeId() ​

getRuntimeId(): bigint

Defined in: packages/prismarine/src/command/host/support.ts:182

Returns ​

bigint

getType() ​

getType(): string

Defined in: packages/prismarine/src/command/host/support.ts:183

Returns ​

string

getWorld() ​

getWorld(): World

Defined in: packages/prismarine/src/command/host/support.ts:189

Returns ​

World

Variables ​

refuse ​

const refuse: (message) => never

Defined in: packages/prismarine/src/command/host/support.ts:62

Refuses a command that cannot do what it was asked.

The seam's verbs answer counts and booleans, which say "nothing matched". Some failures are not that: naming a scoreboard objective nobody created is a mistake rather than an empty result, and Java reports it by name. This is how a verb says so.

Parameters ​

message ​

string

What went wrong, written for the player who typed the line.

Returns ​

never

Throws ​

Always; the caller never returns.


unsupported ​

const unsupported: (subsystem) => never

Defined in: packages/prismarine/src/command/host/support.ts:48

Refuses a command whose host verb has no subsystem behind it.

Thrown rather than answered falsely. A verb that reported "nothing happened" would be indistinguishable from a command that ran and found nothing, and the player would be left retyping a command that can never work.

Parameters ​

subsystem ​

string

What the server would need, named so the message is useful.

Returns ​

never

Throws ​

Always; the caller never returns.

Functions ​

blockPositionOf() ​

blockPositionOf(position): Vector3

Defined in: packages/prismarine/src/command/host/support.ts:305

A block position, which Java floors rather than rounds so -0.5 is in block -1.

Parameters ​

position ​

Vector3

Returns ​

Vector3


carryOut() ​

carryOut<T>(work, answer): T

Defined in: packages/prismarine/src/command/host/support.ts:76

Starts work a host verb decided on and hands the promise to the dispatch.

Type Parameters ​

T ​

T

Parameters ​

work ​

Promise<unknown>

The delivery. Rejections reach the sender; see deferCommandWork.

answer ​

T

What the verb reports, decided before the work started.

Returns ​

T

answer, unchanged, so a verb reads as one expression.

Throws ​

When the verb ran outside a dispatch, where nothing would await work.


commandLevelOf() ​

commandLevelOf(server, dimension): Level | undefined

Defined in: packages/prismarine/src/command/host/support.ts:145

The level a dimension a command carries names, or undefined for the default level, which a dimension without a level is in.

Parameters ​

server ​

Server

dimension ​

string

Returns ​

Level | undefined


dimensionIdOf() ​

dimensionIdOf(world): string

Defined in: packages/prismarine/src/command/host/support.ts:105

The dimension a command carries for a world: its Java dimension_type id, with the level's name after LEVEL_MARK for a level other than the default, so a command run at an entity there acts on its level (#3024).

Parameters ​

world ​

World

Returns ​

string


dimensionInLevel() ​

dimensionInLevel(server, dimension, level): string

Defined in: packages/prismarine/src/command/host/support.ts:135

A dimension a command carries, placed in a level when it names none: a script's bare minecraft:overworld means its own level's.

Parameters ​

server ​

Server

dimension ​

string

The dimension, which may carry a level already.

level ​

Level

The level to place it in; the entry level's dimensions carry no level.

Returns ​

string


dimensionInLevelOf() ​

dimensionInLevelOf(current, named): string

Defined in: packages/prismarine/src/command/host/support.ts:126

The dimension execute in moves a source to: the one named, in the level the source is in.

Parameters ​

current ​

string

The source's dimension, which may carry a level.

named ​

string

The dimension the command names.

Returns ​

string


entityRefOf() ​

entityRefOf(entity): EntityRef

Defined in: packages/prismarine/src/command/host/support.ts:199

The seven fields a command sees of an entity.

The id is the runtime id as a string, which is unique per world and stable for as long as the entity lives, so resolveEntity can find the entity back from a reference a command has been carrying across a fork.

Parameters ​

entity ​

ReferencedEntity

Returns ​

EntityRef


javaDimensionIdOf() ​

javaDimensionIdOf(dimension): string

Defined in: packages/prismarine/src/command/host/support.ts:116

The Java dimension_type id a command's dimension argument names: the Bedrock spelling of a vanilla one is translated, and anything else is taken as it is. A level the dimension carries stays with it.

Parameters ​

dimension ​

string

Returns ​

string


loadedDimensions() ​

loadedDimensions(level): readonly string[]

Defined in: packages/prismarine/src/command/host/support.ts:176

Every dimension a command in a level may name: the dimension type of each of its stems, whether or not its world is built yet.

Parameters ​

level ​

Level

Returns ​

readonly string[]


playerSessionOf() ​

playerSessionOf(server, ref): PlayerSession | undefined

Defined in: packages/prismarine/src/command/host/support.ts:239

The session of the player a reference names, found by the runtime id the reference carries in the world that holds the entity.

This is the one place the command host asks for it.

Parameters ​

server ​

Server

ref ​

EntityRef

Returns ​

PlayerSession | undefined

The session, or undefined when the reference names anything but a player or the player has since left.


playersOf() ​

playersOf(server, refs): CommandPlayer[]

Defined in: packages/prismarine/src/command/host/support.ts:309

The players a command's target list names, skipping the ones that have left.

Parameters ​

server ​

Server

refs ​

readonly EntityRef[]

Returns ​

CommandPlayer[]


resolveEntity() ​

resolveEntity(server, ref): StoreActor | undefined

Defined in: packages/prismarine/src/command/host/support.ts:218

Finds the entity a reference stands for, a store entity through its actor.

Each loaded world answers by runtime id. A command touches a handful of entities and runs when a player typed it, so asking every world is the cheaper thing to be correct about than a server-wide index that every despawn and world change would have to keep.

Parameters ​

server ​

Server

ref ​

EntityRef

Returns ​

StoreActor | undefined

The entity, or undefined when it has since despawned.


resolvePlayer() ​

resolvePlayer(server, ref): CommandPlayer | undefined

Defined in: packages/prismarine/src/command/host/support.ts:298

The same, for a verb that sends nothing of its own: the player behind the session.

Parameters ​

server ​

Server

ref ​

EntityRef

Returns ​

CommandPlayer | undefined


resolveTarget() ​

resolveTarget(server, ref): CommandTarget | undefined

Defined in: packages/prismarine/src/command/host/support.ts:292

The session a reference names and the player behind it.

Parameters ​

server ​

Server

ref ​

EntityRef

Returns ​

CommandTarget | undefined

The target, or undefined when the reference names anything but a player or the player has since left.


sessionsOf() ​

sessionsOf(server, refs): PlayerSession[]

Defined in: packages/prismarine/src/command/host/support.ts:248

The sessions of the players a command's target list names, skipping the ones that have left. A verb that only sends to its targets reads these.

Parameters ​

server ​

Server

refs ​

readonly EntityRef[]

Returns ​

PlayerSession[]


splitCommandDimension() ​

splitCommandDimension(dimension): object

Defined in: packages/prismarine/src/command/host/support.ts:91

A dimension a command carries, split into the dimension and the level, undefined for the default.

Parameters ​

dimension ​

string

Returns ​

object

dimension ​

readonly dimension: string

level? ​

readonly optional level?: string


vectorOf() ​

vectorOf(position): Vector3

Defined in: packages/prismarine/src/command/host/support.ts:302

A host position as this server's vector.

Parameters ​

position ​

Vector3

Returns ​

Vector3


worldOf() ​

worldOf(server, dimension): World

Defined in: packages/prismarine/src/command/host/support.ts:160

The world a dimension a command carries names, started if its level has the stem but nobody has entered it yet.

Parameters ​

server ​

Server

dimension ​

string

A Java dimension_type id, or the Bedrock spelling of a vanilla one, naming its level after @ when it is not the default one.

Returns ​

World

That level's world of the dimension, which may still be enabling and then has no chunks loaded, or the Overworld of the dimension's level, then the entry level's, when no stem names the dimension.