Skip to content

API reference / @jsprismarine/script-host / host/entities/world

host/entities/world ​

Interfaces ​

ScriptAimAssistCategory ​

Defined in: script-host/src/host/entities/world.ts:189

One aim assist category: the priorities a player's aim assist gives what it targets.

Properties ​

blocks ​

readonly blocks: Readonly<Record<string, number>>

Defined in: script-host/src/host/entities/world.ts:193

blockTags ​

readonly blockTags: Readonly<Record<string, number>>

Defined in: script-host/src/host/entities/world.ts:195

defaultBlockPriority ​

readonly defaultBlockPriority: number

Defined in: script-host/src/host/entities/world.ts:191

defaultEntityPriority ​

readonly defaultEntityPriority: number

Defined in: script-host/src/host/entities/world.ts:192

entities ​

readonly entities: Readonly<Record<string, number>>

Defined in: script-host/src/host/entities/world.ts:194

entityTypeFamilies ​

readonly entityTypeFamilies: Readonly<Record<string, number>>

Defined in: script-host/src/host/entities/world.ts:196

identifier ​

readonly identifier: string

Defined in: script-host/src/host/entities/world.ts:190


ScriptAimAssistPreset ​

Defined in: script-host/src/host/entities/world.ts:200

One aim assist preset: what a player's aim assist ignores, and the category each held item uses.

Properties ​

defaultItemSettings? ​

readonly optional defaultItemSettings?: string

Defined in: script-host/src/host/entities/world.ts:202

excludedBlocks ​

readonly excludedBlocks: readonly string[]

Defined in: script-host/src/host/entities/world.ts:204

excludedBlockTags ​

readonly excludedBlockTags: readonly string[]

Defined in: script-host/src/host/entities/world.ts:206

excludedEntities ​

readonly excludedEntities: readonly string[]

Defined in: script-host/src/host/entities/world.ts:205

excludedEntityTypeFamilies ​

readonly excludedEntityTypeFamilies: readonly string[]

Defined in: script-host/src/host/entities/world.ts:207

handSettings? ​

readonly optional handSettings?: string

Defined in: script-host/src/host/entities/world.ts:203

identifier ​

readonly identifier: string

Defined in: script-host/src/host/entities/world.ts:201

itemSettings ​

readonly itemSettings: Readonly<Record<string, string>>

Defined in: script-host/src/host/entities/world.ts:208

liquidTargetingItems ​

readonly liquidTargetingItems: readonly string[]

Defined in: script-host/src/host/entities/world.ts:209


ScriptAimAssistRegistry ​

Defined in: script-host/src/host/entities/world.ts:213

The aim assist registry, in the order its entries were added.

Properties ​

categories ​

readonly categories: readonly ScriptAimAssistCategory[]

Defined in: script-host/src/host/entities/world.ts:214

presets ​

readonly presets: readonly ScriptAimAssistPreset[]

Defined in: script-host/src/host/entities/world.ts:215


ScriptClientInfo ​

Defined in: script-host/src/host/entities/world.ts:72

What a player's client told the server about itself.

Properties ​

graphicsMode ​

readonly graphicsMode: "Deferred" | "Fancy" | "RayTraced" | "Simple"

Defined in: script-host/src/host/entities/world.ts:76

inputMode ​

readonly inputMode: "Gamepad" | "KeyboardAndMouse" | "MotionController" | "Touch"

Defined in: script-host/src/host/entities/world.ts:77

jump ​

readonly jump: boolean

Defined in: script-host/src/host/entities/world.ts:81

locale ​

readonly locale: string

Defined in: script-host/src/host/entities/world.ts:73

maxRenderDistance ​

readonly maxRenderDistance: number

Defined in: script-host/src/host/entities/world.ts:74

movement ​

readonly movement: object

Defined in: script-host/src/host/entities/world.ts:80

The movement input this tick, x sideways and y forward, each from -1 to 1.

x ​

readonly x: number

y ​

readonly y: number

persistentId ​

readonly persistentId: string

Defined in: script-host/src/host/entities/world.ts:88

An id that stays the player's across sessions.

ping? ​

readonly optional ping?: number

Defined in: script-host/src/host/entities/world.ts:84

The round trip to the client, in milliseconds. Absent for a player with no client, such as a simulated one.

platformType ​

readonly platformType: "Console" | "Desktop" | "Mobile"

Defined in: script-host/src/host/entities/world.ts:75

sneak ​

readonly sneak: boolean

Defined in: script-host/src/host/entities/world.ts:82

splitScreenSlot? ​

readonly optional splitScreenSlot?: "First" | "Fourth" | "Second" | "Third"

Defined in: script-host/src/host/entities/world.ts:86

Absent for a player with no client.

touchOnlyAffectsHotbar ​

readonly touchOnlyAffectsHotbar: boolean

Defined in: script-host/src/host/entities/world.ts:78


ScriptDimensionLocation ​

Defined in: script-host/src/host/entities/world.ts:92

A point in a dimension.

Extends ​

Properties ​

dimension ​

readonly dimension: string

Defined in: script-host/src/host/entities/world.ts:93

x ​

readonly x: number

Defined in: script-host/src/host/world.ts:56

Inherited from ​

ScriptVector3.x

y ​

readonly y: number

Defined in: script-host/src/host/world.ts:57

Inherited from ​

ScriptVector3.y

z ​

readonly z: number

Defined in: script-host/src/host/world.ts:58

Inherited from ​

ScriptVector3.z


ScriptEntityProperty ​

Defined in: script-host/src/host/entities/world.ts:54

An entity property's definition and its value now.

Properties ​

defaultValue ​

readonly defaultValue: string | number | boolean

Defined in: script-host/src/host/entities/world.ts:57

range? ​

readonly optional range?: readonly [number, number]

Defined in: script-host/src/host/entities/world.ts:59

An int or float property's bounds.

type ​

readonly type: "float" | "enum" | "int" | "bool"

Defined in: script-host/src/host/entities/world.ts:55

value ​

readonly value: string | number | boolean

Defined in: script-host/src/host/entities/world.ts:56

values? ​

readonly optional values?: readonly string[]

Defined in: script-host/src/host/entities/world.ts:61

An enum property's values.


ScriptEntityStatus ​

Defined in: script-host/src/host/entities/world.ts:20

An entity's motion and the states a script reads of it, read in one call.

Properties ​

box ​

readonly box: object

Defined in: script-host/src/host/entities/world.ts:33

Its collision box.

max ​

readonly max: ScriptVector3

min ​

readonly min: ScriptVector3

climbing ​

readonly climbing: boolean

Defined in: script-host/src/host/entities/world.ts:26

Whether it is on a ladder, a vine or another block it climbs.

emoting? ​

readonly optional emoting?: boolean

Defined in: script-host/src/host/entities/world.ts:50

fireTicks ​

readonly fireTicks: number

Defined in: script-host/src/host/entities/world.ts:31

How many ticks it burns for; 0 when it is not on fire.

flying? ​

readonly optional flying?: boolean

Defined in: script-host/src/host/entities/world.ts:47

A player's flight, glide, jump and emote. Absent reads as false.

gliding? ​

readonly optional gliding?: boolean

Defined in: script-host/src/host/entities/world.ts:48

inWater ​

readonly inWater: boolean

Defined in: script-host/src/host/entities/world.ts:24

jumping? ​

readonly optional jumping?: boolean

Defined in: script-host/src/host/entities/world.ts:49

leashHolder? ​

readonly optional leashHolder?: string

Defined in: script-host/src/host/entities/world.ts:41

The entity that holds its leash, by id.

onGround ​

readonly onGround: boolean

Defined in: script-host/src/host/entities/world.ts:23

owner? ​

readonly optional owner?: string

Defined in: script-host/src/host/entities/world.ts:43

The player it is tamed to, by id. Absent for a wild or ownerless entity.

riders ​

readonly riders: readonly string[]

Defined in: script-host/src/host/entities/world.ts:39

The entities that ride it, by id, in the order they took their seats.

sleeping ​

readonly sleeping: boolean

Defined in: script-host/src/host/entities/world.ts:27

sprinting ​

readonly sprinting: boolean

Defined in: script-host/src/host/entities/world.ts:28

swimming ​

readonly swimming: boolean

Defined in: script-host/src/host/entities/world.ts:29

tamed ​

readonly tamed: boolean

Defined in: script-host/src/host/entities/world.ts:45

Whether it is tamed, which a horse can be without an owner.

target? ​

readonly optional target?: string

Defined in: script-host/src/host/entities/world.ts:35

The entity it is attacking, by id. Absent when it attacks none.

vehicle? ​

readonly optional vehicle?: string

Defined in: script-host/src/host/entities/world.ts:37

The entity it rides, by id.

velocity ​

readonly velocity: ScriptVector3

Defined in: script-host/src/host/entities/world.ts:22

Its velocity, in blocks per tick.


ScriptEntitySystems ​

Defined in: script-host/src/host/entities/world.ts:219

The entity and player systems a script reaches. A world without them has none of these members' behavior.

Methods ​

addAimAssist() ​

addAimAssist(added): void

Defined in: script-host/src/host/entities/world.ts:304

Adds categories and presets a script registered, for the clients now in the world and those who join later.

Parameters ​
added ​

ScriptAimAssistRegistry

Returns ​

void

aimAssist() ​

aimAssist(): ScriptAimAssistRegistry

Defined in: script-host/src/host/entities/world.ts:302

The vanilla aim assist registry the world's clients are sent when they join.

Returns ​

ScriptAimAssistRegistry

applyImpulse() ​

applyImpulse(id, impulse): void

Defined in: script-host/src/host/entities/world.ts:244

Adds to an entity's velocity.

Parameters ​
id ​

string

impulse ​

ScriptVector3

Returns ​

void

applyKnockback() ​

applyKnockback(id, horizontal, vertical): void

Defined in: script-host/src/host/entities/world.ts:247

Pushes an entity along a horizontal vector, whose length is the strength, and up by vertical.

Parameters ​
id ​

string

horizontal ​
x ​

number

z ​

number

vertical ​

number

Returns ​

void

clearVelocity() ​

clearVelocity(id): void

Defined in: script-host/src/host/entities/world.ts:245

Parameters ​
id ​

string

Returns ​

void

clientInfo() ​

clientInfo(id): ScriptClientInfo | undefined

Defined in: script-host/src/host/entities/world.ts:287

What a player's client told the server about itself, or undefined for a player who is gone.

Parameters ​
id ​

string

Returns ​

ScriptClientInfo | undefined

components() ​

components(id): ReadonlyMap<string, unknown> | undefined

Defined in: script-host/src/host/entities/world.ts:225

The components active on an entity now, by id, each with its JSON as its definition writes it: the base components, then each active component group's, later ones replacing earlier.

Parameters ​
id ​

string

Returns ​

ReadonlyMap<string, unknown> | undefined

Undefined for an entity that is gone.

dismount() ​

dismount(rider): void

Defined in: script-host/src/host/entities/world.ts:262

Takes a rider off whatever it rides.

Parameters ​
rider ​

string

Returns ​

void

eat() ​

eat(id, typeId): void

Defined in: script-host/src/host/entities/world.ts:300

Applies a food's effect on a player, as eating it does.

Parameters ​
id ​

string

typeId ​

string

Returns ​

void

enderChest() ​

enderChest(id): readonly (ScriptItem | null)[] | undefined

Defined in: script-host/src/host/entities/world.ts:306

A player's ender chest, or undefined for one that is gone.

Parameters ​
id ​

string

Returns ​

readonly (ScriptItem | null)[] | undefined

entityTypes() ​

entityTypes(): readonly string[]

Defined in: script-host/src/host/entities/world.ts:275

Every entity type the world can spawn, by id.

Returns ​

readonly string[]

experience() ​

experience(id): ScriptExperience | undefined

Defined in: script-host/src/host/entities/world.ts:277

A player's experience, or undefined for one that is gone.

Parameters ​
id ​

string

Returns ​

ScriptExperience | undefined

extinguishFire() ​

extinguishFire(id): boolean

Defined in: script-host/src/host/entities/world.ts:255

Puts an entity's fire out, and returns whether it had any.

Parameters ​
id ​

string

Returns ​

boolean

formatVersion() ​

formatVersion(id): string | undefined

Defined in: script-host/src/host/entities/world.ts:231

The format_version of the file that defines an entity's type, such as 1.26.50. BDS reads an item name without a namespace as written from a file of 1.26.60 or later, and with minecraft: from an older one.

Parameters ​
id ​

string

Returns ​

string | undefined

itemIdentifier() ​

itemIdentifier(name): string

Defined in: script-host/src/host/entities/world.ts:273

The item type an item name in an entity's definition names, with a legacy name such as minecraft:fish read as its type now.

Parameters ​
name ​

string

Returns ​

string

leash() ​

leash(id, holder): void

Defined in: script-host/src/host/entities/world.ts:264

Ties an entity's leash to a holder, or unties it with none.

Parameters ​
id ​

string

holder ​

string | undefined

Returns ​

void

permissions() ​

permissions(id): ScriptPermissionLevels | undefined

Defined in: script-host/src/host/entities/world.ts:282

Parameters ​
id ​

string

Returns ​

ScriptPermissionLevels | undefined

playAnimation() ​

playAnimation(id, animation): void

Defined in: script-host/src/host/entities/world.ts:289

Plays an animation on an entity for the clients that see it.

Parameters ​
id ​

string

animation ​
blendOutTime? ​

number

controller? ​

string

name ​

string

nextState? ​

string

stopExpression? ​

string

Returns ​

void

properties() ​

properties(id): ReadonlyMap<string, ScriptEntityProperty> | undefined

Defined in: script-host/src/host/entities/world.ts:240

An entity's properties, by id, or undefined for one that is gone.

Parameters ​
id ​

string

Returns ​

ReadonlyMap<string, ScriptEntityProperty> | undefined

ride() ​

ride(rider, vehicle): boolean

Defined in: script-host/src/host/entities/world.ts:260

Seats a rider on a vehicle.

Parameters ​
rider ​

string

vehicle ​

string

Returns ​

boolean

False when the vehicle has no room or does not take the rider's family.

sendClient() ​

sendClient(id, message): void

Defined in: script-host/src/host/entities/world.ts:285

Sends a player's client a message.

Parameters ​
id ​

string

message ​

ScriptClientMessage

Returns ​

void

setCommandPermissionLevel() ​

setCommandPermissionLevel(id, level): void

Defined in: script-host/src/host/entities/world.ts:283

Parameters ​
id ​

string

level ​

number

Returns ​

void

setComponentField() ​

setComponentField(id, component, field, value): void

Defined in: script-host/src/host/entities/world.ts:271

Writes a script-set field of a component, such as a sheep's color, an NPC's name or a projectile's gravity.

Parameters ​
id ​

string

component ​

string

field ​

string

value ​

unknown

Returns ​

void

setEnderChestItem() ​

setEnderChestItem(id, slot, item): void

Defined in: script-host/src/host/entities/world.ts:307

Parameters ​
id ​

string

slot ​

number

item ​

ScriptItem | undefined

Returns ​

void

setExperience() ​

setExperience(id, experience): void

Defined in: script-host/src/host/entities/world.ts:278

Parameters ​
id ​

string

experience ​

ScriptExperience

Returns ​

void

setOnFire() ​

setOnFire(id, ticks): boolean

Defined in: script-host/src/host/entities/world.ts:253

Sets an entity on fire for a number of ticks.

Parameters ​
id ​

string

ticks ​

number

Returns ​

boolean

False for an entity that cannot burn.

setProperty() ​

setProperty(id, name, value): void

Defined in: script-host/src/host/entities/world.ts:242

Writes a property's value, which the caller checked against its definition.

Parameters ​
id ​

string

name ​

string

value ​

string | number | boolean

Returns ​

void

setRotation() ​

setRotation(id, rotation): void

Defined in: script-host/src/host/entities/world.ts:248

Parameters ​
id ​

string

rotation ​

ScriptRotation

Returns ​

void

setSpawnPoint() ​

setSpawnPoint(id, point): void

Defined in: script-host/src/host/entities/world.ts:281

Parameters ​
id ​

string

point ​

ScriptDimensionLocation | undefined

Returns ​

void

spawnPoint() ​

spawnPoint(id): ScriptDimensionLocation | undefined

Defined in: script-host/src/host/entities/world.ts:280

Where a player respawns; undefined for the world's spawn.

Parameters ​
id ​

string

Returns ​

ScriptDimensionLocation | undefined

status() ​

status(id): ScriptEntityStatus | undefined

Defined in: script-host/src/host/entities/world.ts:233

The entity's motion and state, or undefined for one that is gone.

Parameters ​
id ​

string

Returns ​

ScriptEntityStatus | undefined

tame() ​

tame(id, player): boolean

Defined in: script-host/src/host/entities/world.ts:269

Tames an entity, to a player when one is given.

Parameters ​
id ​

string

player ​

string | undefined

Returns ​

boolean

False for an entity that cannot be tamed or already is.

triggerEvent() ​

triggerEvent(id, event): boolean

Defined in: script-host/src/host/entities/world.ts:238

Runs one of an entity's definition events.

Parameters ​
id ​

string

event ​

string

Returns ​

boolean

False when its definition has no such event.


ScriptExperience ​

Defined in: script-host/src/host/entities/world.ts:65

A player's experience, as Bedrock keeps it: whole levels and how far along the next one the bar is.

Properties ​

level ​

readonly level: number

Defined in: script-host/src/host/entities/world.ts:66

progress ​

readonly progress: number

Defined in: script-host/src/host/entities/world.ts:68

From 0 to 1.


ScriptPermissionLevels ​

Defined in: script-host/src/host/entities/world.ts:97

A player's permission levels, by their numbers in CommandPermissionLevel and PlayerPermissionLevel.

Properties ​

command ​

readonly command: number

Defined in: script-host/src/host/entities/world.ts:98

player ​

readonly player: number

Defined in: script-host/src/host/entities/world.ts:99


ScriptRotation ​

Defined in: script-host/src/host/entities/world.ts:14

A rotation in degrees: x the pitch, y the yaw.

Properties ​

x ​

readonly x: number

Defined in: script-host/src/host/entities/world.ts:15

y ​

readonly y: number

Defined in: script-host/src/host/entities/world.ts:16


ScriptSplineKeyFrame ​

Defined in: script-host/src/host/entities/world.ts:137

One key frame of a camera spline: a value the camera reaches at a time, eased there as EasingType names.

Type Parameters ​

Value ​

Value

Properties ​

easing? ​

readonly optional easing?: string

Defined in: script-host/src/host/entities/world.ts:141

An EasingType name, such as InOutSine; absent for linear.

time ​

readonly time: number

Defined in: script-host/src/host/entities/world.ts:139

value ​

readonly value: Value

Defined in: script-host/src/host/entities/world.ts:138

Type Aliases ​

ScriptCameraInstruction ​

ScriptCameraInstruction = { ease?: { time: number; type: string; }; facing?: ScriptVector3; facingEntity?: string; isDefault?: boolean; kind: "set"; location?: ScriptVector3; preset: string; rotation?: ScriptRotation; } | { kind: "clear"; } | { color?: { blue: number; green: number; red: number; }; kind: "fade"; time?: { fadeIn: number; fadeOut: number; hold: number; }; } | { ease?: { time: number; type: string; }; fov: number; kind: "fov"; } | { entity?: string; kind: "attach"; } | { kind: "detach"; } | { controlPoints: readonly ScriptVector3[]; kind: "spline"; progressKeyFrames: readonly ScriptSplineKeyFrame<number>[]; rotationKeyFrames: readonly ScriptSplineKeyFrame<ScriptVector3>[]; totalTime: number; type: "catmullRom" | "linear"; }

Defined in: script-host/src/host/entities/world.ts:103

A camera instruction a script sends a player, as Camera's members describe it.

Union Members ​

Type Literal ​

{ ease?: { time: number; type: string; }; facing?: ScriptVector3; facingEntity?: string; isDefault?: boolean; kind: "set"; location?: ScriptVector3; preset: string; rotation?: ScriptRotation; }

ease? ​

readonly optional ease?: object

ease.time ​

readonly time: number

ease.type ​

readonly type: string

facing? ​

readonly optional facing?: ScriptVector3

facingEntity? ​

readonly optional facingEntity?: string

isDefault? ​

readonly optional isDefault?: boolean

Whether the preset becomes the player's default camera.

kind ​

readonly kind: "set"

location? ​

readonly optional location?: ScriptVector3

preset ​

readonly preset: string

The preset's id, such as minecraft:free.

rotation? ​

readonly optional rotation?: ScriptRotation


Type Literal ​

{ kind: "clear"; }


Type Literal ​

{ color?: { blue: number; green: number; red: number; }; kind: "fade"; time?: { fadeIn: number; fadeOut: number; hold: number; }; }


Type Literal ​

{ ease?: { time: number; type: string; }; fov: number; kind: "fov"; }


Type Literal ​

{ entity?: string; kind: "attach"; }


Type Literal ​

{ kind: "detach"; }


Type Literal ​

{ controlPoints: readonly ScriptVector3[]; kind: "spline"; progressKeyFrames: readonly ScriptSplineKeyFrame<number>[]; rotationKeyFrames: readonly ScriptSplineKeyFrame<ScriptVector3>[]; totalTime: number; type: "catmullRom" | "linear"; }

controlPoints ​

readonly controlPoints: readonly ScriptVector3[]

kind ​

readonly kind: "spline"

A camera path Camera.playAnimation plays.

progressKeyFrames ​

readonly progressKeyFrames: readonly ScriptSplineKeyFrame<number>[]

How far along the path the camera is at each time, alpha from 0 to 1.

rotationKeyFrames ​

readonly rotationKeyFrames: readonly ScriptSplineKeyFrame<ScriptVector3>[]

totalTime ​

readonly totalTime: number

type ​

readonly type: "catmullRom" | "linear"


ScriptClientMessage ​

ScriptClientMessage = { instruction: ScriptCameraInstruction; kind: "camera"; } | { intensity: number; kind: "shake"; seconds: number; type: "positional" | "rotational"; } | { kind: "stopShake"; } | { hidden: readonly number[]; kind: "hud"; visible: readonly number[]; } | { kind: "inputLocks"; locked: readonly number[]; } | { category: string; kind: "cooldown"; ticks: number; } | { kind: "controlScheme"; scheme: string; } | { kind: "stopSound"; sound?: string; } | { action: "play" | "queue" | "stop"; fade?: number; kind: "music"; loop?: boolean; track?: string; volume?: number; } | { distance: number; kind: "aimAssist"; preset?: string; targetMode: "Angle" | "Distance"; viewAngle: { x: number; y: number; }; } | { entity: string; kind: "propertyOverride"; property: string; value?: number | boolean | string; } | { id: string; kind: "scriptMessage"; value: string; }

Defined in: script-host/src/host/entities/world.ts:145

What a script sends a player's client.

Union Members ​

Type Literal ​

{ instruction: ScriptCameraInstruction; kind: "camera"; }


Type Literal ​

{ intensity: number; kind: "shake"; seconds: number; type: "positional" | "rotational"; }


Type Literal ​

{ kind: "stopShake"; }


Type Literal ​

{ hidden: readonly number[]; kind: "hud"; visible: readonly number[]; }

The HUD elements a script hid, by their numbers in HudElement, all of them sent each time.


Type Literal ​

{ kind: "inputLocks"; locked: readonly number[]; }

The input a script locked, as InputPermissionCategory numbers.


Type Literal ​

{ category: string; kind: "cooldown"; ticks: number; }


Type Literal ​

{ kind: "controlScheme"; scheme: string; }


Type Literal ​

{ kind: "stopSound"; sound?: string; }


Type Literal ​

{ action: "play" | "queue" | "stop"; fade?: number; kind: "music"; loop?: boolean; track?: string; volume?: number; }


Type Literal ​

{ distance: number; kind: "aimAssist"; preset?: string; targetMode: "Angle" | "Distance"; viewAngle: { x: number; y: number; }; }

distance ​

readonly distance: number

kind ​

readonly kind: "aimAssist"

preset? ​

readonly optional preset?: string

Absent turns aim assist off.

targetMode ​

readonly targetMode: "Angle" | "Distance"

viewAngle ​

readonly viewAngle: object

viewAngle.x ​

readonly x: number

viewAngle.y ​

readonly y: number


Type Literal ​

{ entity: string; kind: "propertyOverride"; property: string; value?: number | boolean | string; }

entity ​

readonly entity: string

kind ​

readonly kind: "propertyOverride"

property ​

readonly property: string

Empty when every override of the entity is cleared.

value? ​

readonly optional value?: number | boolean | string

Absent when the property's override is removed.


Type Literal ​

{ id: string; kind: "scriptMessage"; value: string; }

A message to the client's data-driven UI, as Player.postClientMessage posts it.