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
readonlyblocks:Readonly<Record<string,number>>
Defined in: script-host/src/host/entities/world.ts:193
blockTags
readonlyblockTags:Readonly<Record<string,number>>
Defined in: script-host/src/host/entities/world.ts:195
defaultBlockPriority
readonlydefaultBlockPriority:number
Defined in: script-host/src/host/entities/world.ts:191
defaultEntityPriority
readonlydefaultEntityPriority:number
Defined in: script-host/src/host/entities/world.ts:192
entities
readonlyentities:Readonly<Record<string,number>>
Defined in: script-host/src/host/entities/world.ts:194
entityTypeFamilies
readonlyentityTypeFamilies:Readonly<Record<string,number>>
Defined in: script-host/src/host/entities/world.ts:196
identifier
readonlyidentifier: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?
readonlyoptionaldefaultItemSettings?:string
Defined in: script-host/src/host/entities/world.ts:202
excludedBlocks
readonlyexcludedBlocks: readonlystring[]
Defined in: script-host/src/host/entities/world.ts:204
excludedBlockTags
readonlyexcludedBlockTags: readonlystring[]
Defined in: script-host/src/host/entities/world.ts:206
excludedEntities
readonlyexcludedEntities: readonlystring[]
Defined in: script-host/src/host/entities/world.ts:205
excludedEntityTypeFamilies
readonlyexcludedEntityTypeFamilies: readonlystring[]
Defined in: script-host/src/host/entities/world.ts:207
handSettings?
readonlyoptionalhandSettings?:string
Defined in: script-host/src/host/entities/world.ts:203
identifier
readonlyidentifier:string
Defined in: script-host/src/host/entities/world.ts:201
itemSettings
readonlyitemSettings:Readonly<Record<string,string>>
Defined in: script-host/src/host/entities/world.ts:208
liquidTargetingItems
readonlyliquidTargetingItems: readonlystring[]
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
readonlycategories: readonlyScriptAimAssistCategory[]
Defined in: script-host/src/host/entities/world.ts:214
presets
readonlypresets: readonlyScriptAimAssistPreset[]
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
readonlygraphicsMode:"Deferred"|"Fancy"|"RayTraced"|"Simple"
Defined in: script-host/src/host/entities/world.ts:76
inputMode
readonlyinputMode:"Gamepad"|"KeyboardAndMouse"|"MotionController"|"Touch"
Defined in: script-host/src/host/entities/world.ts:77
jump
readonlyjump:boolean
Defined in: script-host/src/host/entities/world.ts:81
locale
readonlylocale:string
Defined in: script-host/src/host/entities/world.ts:73
maxRenderDistance
readonlymaxRenderDistance:number
Defined in: script-host/src/host/entities/world.ts:74
movement
readonlymovement: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
readonlyx:number
y
readonlyy:number
persistentId
readonlypersistentId:string
Defined in: script-host/src/host/entities/world.ts:88
An id that stays the player's across sessions.
ping?
readonlyoptionalping?: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
readonlyplatformType:"Console"|"Desktop"|"Mobile"
Defined in: script-host/src/host/entities/world.ts:75
sneak
readonlysneak:boolean
Defined in: script-host/src/host/entities/world.ts:82
splitScreenSlot?
readonlyoptionalsplitScreenSlot?:"First"|"Fourth"|"Second"|"Third"
Defined in: script-host/src/host/entities/world.ts:86
Absent for a player with no client.
touchOnlyAffectsHotbar
readonlytouchOnlyAffectsHotbar: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
readonlydimension:string
Defined in: script-host/src/host/entities/world.ts:93
x
readonlyx:number
Defined in: script-host/src/host/world.ts:56
Inherited from
y
readonlyy:number
Defined in: script-host/src/host/world.ts:57
Inherited from
z
readonlyz:number
Defined in: script-host/src/host/world.ts:58
Inherited from
ScriptEntityProperty
Defined in: script-host/src/host/entities/world.ts:54
An entity property's definition and its value now.
Properties
defaultValue
readonlydefaultValue:string|number|boolean
Defined in: script-host/src/host/entities/world.ts:57
range?
readonlyoptionalrange?: readonly [number,number]
Defined in: script-host/src/host/entities/world.ts:59
An int or float property's bounds.
type
readonlytype:"float"|"enum"|"int"|"bool"
Defined in: script-host/src/host/entities/world.ts:55
value
readonlyvalue:string|number|boolean
Defined in: script-host/src/host/entities/world.ts:56
values?
readonlyoptionalvalues?: readonlystring[]
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
readonlybox:object
Defined in: script-host/src/host/entities/world.ts:33
Its collision box.
max
readonlymax:ScriptVector3
min
readonlymin:ScriptVector3
climbing
readonlyclimbing: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?
readonlyoptionalemoting?:boolean
Defined in: script-host/src/host/entities/world.ts:50
fireTicks
readonlyfireTicks: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?
readonlyoptionalflying?:boolean
Defined in: script-host/src/host/entities/world.ts:47
A player's flight, glide, jump and emote. Absent reads as false.
gliding?
readonlyoptionalgliding?:boolean
Defined in: script-host/src/host/entities/world.ts:48
inWater
readonlyinWater:boolean
Defined in: script-host/src/host/entities/world.ts:24
jumping?
readonlyoptionaljumping?:boolean
Defined in: script-host/src/host/entities/world.ts:49
leashHolder?
readonlyoptionalleashHolder?:string
Defined in: script-host/src/host/entities/world.ts:41
The entity that holds its leash, by id.
onGround
readonlyonGround:boolean
Defined in: script-host/src/host/entities/world.ts:23
owner?
readonlyoptionalowner?: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
readonlyriders: readonlystring[]
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
readonlysleeping:boolean
Defined in: script-host/src/host/entities/world.ts:27
sprinting
readonlysprinting:boolean
Defined in: script-host/src/host/entities/world.ts:28
swimming
readonlyswimming:boolean
Defined in: script-host/src/host/entities/world.ts:29
tamed
readonlytamed:boolean
Defined in: script-host/src/host/entities/world.ts:45
Whether it is tamed, which a horse can be without an owner.
target?
readonlyoptionaltarget?:string
Defined in: script-host/src/host/entities/world.ts:35
The entity it is attacking, by id. Absent when it attacks none.
vehicle?
readonlyoptionalvehicle?:string
Defined in: script-host/src/host/entities/world.ts:37
The entity it rides, by id.
velocity
readonlyvelocity: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
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
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
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
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
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
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
readonlylevel:number
Defined in: script-host/src/host/entities/world.ts:66
progress
readonlyprogress: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
readonlycommand:number
Defined in: script-host/src/host/entities/world.ts:98
player
readonlyplayer: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
readonlyx:number
Defined in: script-host/src/host/entities/world.ts:15
y
readonlyy: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?
readonlyoptionaleasing?:string
Defined in: script-host/src/host/entities/world.ts:141
An EasingType name, such as InOutSine; absent for linear.
time
readonlytime:number
Defined in: script-host/src/host/entities/world.ts:139
value
readonlyvalue: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: readonlyScriptVector3[];kind:"spline";progressKeyFrames: readonlyScriptSplineKeyFrame<number>[];rotationKeyFrames: readonlyScriptSplineKeyFrame<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?
readonlyoptionalease?:object
ease.time
readonlytime:number
ease.type
readonlytype:string
facing?
readonlyoptionalfacing?:ScriptVector3
facingEntity?
readonlyoptionalfacingEntity?:string
isDefault?
readonlyoptionalisDefault?:boolean
Whether the preset becomes the player's default camera.
kind
readonlykind:"set"
location?
readonlyoptionallocation?:ScriptVector3
preset
readonlypreset:string
The preset's id, such as minecraft:free.
rotation?
readonlyoptionalrotation?: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
readonlycontrolPoints: readonlyScriptVector3[]
kind
readonlykind:"spline"
A camera path Camera.playAnimation plays.
progressKeyFrames
readonlyprogressKeyFrames: readonlyScriptSplineKeyFrame<number>[]
How far along the path the camera is at each time, alpha from 0 to 1.
rotationKeyFrames
readonlyrotationKeyFrames: readonlyScriptSplineKeyFrame<ScriptVector3>[]
totalTime
readonlytotalTime:number
type
readonlytype:"catmullRom"|"linear"
ScriptClientMessage
ScriptClientMessage = {
instruction:ScriptCameraInstruction;kind:"camera"; } | {intensity:number;kind:"shake";seconds:number;type:"positional"|"rotational"; } | {kind:"stopShake"; } | {hidden: readonlynumber[];kind:"hud";visible: readonlynumber[]; } | {kind:"inputLocks";locked: readonlynumber[]; } | {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
readonlydistance:number
kind
readonlykind:"aimAssist"
preset?
readonlyoptionalpreset?:string
Absent turns aim assist off.
targetMode
readonlytargetMode:"Angle"|"Distance"
viewAngle
readonlyviewAngle:object
viewAngle.x
readonlyx:number
viewAngle.y
readonlyy:number
Type Literal
{ entity: string; kind: "propertyOverride"; property: string; value?: number | boolean | string; }
entity
readonlyentity:string
kind
readonlykind:"propertyOverride"
property
readonlyproperty:string
Empty when every override of the entity is cleared.
value?
readonlyoptionalvalue?: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.