API reference / @jsprismarine/script-host / host/world
host/world
Interfaces
BlockBreakIntent
Defined in: script-host/src/host/world.ts:419
A block a player is about to break, which a script's before-event sees before the world does.
Properties
block
readonlyblock:ScriptBlockLocation
Defined in: script-host/src/host/world.ts:422
item?
readonlyoptionalitem?:ScriptItem
Defined in: script-host/src/host/world.ts:424
The stack in the player's hand. Absent for an empty hand.
player
readonlyplayer:string
Defined in: script-host/src/host/world.ts:421
The id of the player breaking it, as ScriptWorld.players lists it.
BlockInteractIntent
Defined in: script-host/src/host/world.ts:488
A block a player clicks, which a script's before-event sees before the click does anything.
Properties
block
readonlyblock:ScriptBlockLocation
Defined in: script-host/src/host/world.ts:491
face
readonlyface:ScriptDirection
Defined in: script-host/src/host/world.ts:492
faceLocation
readonlyfaceLocation:ScriptVector3
Defined in: script-host/src/host/world.ts:494
Where on the face the click landed, from the block's lowest corner.
item?
readonlyoptionalitem?:ScriptItem
Defined in: script-host/src/host/world.ts:496
The stack in the player's hand. Absent for an empty hand.
player
readonlyplayer:string
Defined in: script-host/src/host/world.ts:490
The id of the player clicking, as ScriptWorld.players lists it.
ChatSendIntent
Defined in: script-host/src/host/world.ts:30
A line of chat a player typed, which a script's before-event sees before anyone gets it.
Properties
message
readonlymessage:string
Defined in: script-host/src/host/world.ts:33
sender
readonlysender:string
Defined in: script-host/src/host/world.ts:32
The id of the player who typed it, as ScriptWorld.players lists it.
DataDrivenPathValue
Defined in: script-host/src/host/world.ts:660
One path of a data store property and its new value, such as layout[7].value.
Properties
path
readonlypath:string
Defined in: script-host/src/host/world.ts:661
value
readonlyvalue:DataDrivenLeaf
Defined in: script-host/src/host/world.ts:662
DataDrivenRecord
Defined in: script-host/src/host/world.ts:652
A map in a data-driven screen's data store property, by key.
Indexable
[
key:string]:DataDrivenValue
DataDrivenScreen
Defined in: script-host/src/host/world.ts:669
A CustomForm or MessageBox as BDS sends it: one property of the client's minecraft data store, and the screen that reads it.
Properties
instance
readonlyinstance:number
Defined in: script-host/src/host/world.ts:675
The number the property name ends in, which the client is told as the data instance id.
property
readonlyproperty:string
Defined in: script-host/src/host/world.ts:673
The property's name, such as custom_form_data_3, which the client's writes name too.
screenId
readonlyscreenId:string
Defined in: script-host/src/host/world.ts:671
The screen to open: minecraft:custom_form or minecraft:message_box.
updates
readonlyupdates: readonlyDataDrivenPathValue[]
Defined in: script-host/src/host/world.ts:679
Paths to update after the property is set and before the screen opens, as BDS sends them.
value
readonlyvalue:DataDrivenRecord
Defined in: script-host/src/host/world.ts:677
The property's value.
EntityInteractIntent
Defined in: script-host/src/host/world.ts:500
An entity a player clicks, which a script's before-event sees before the click does anything.
Properties
item?
readonlyoptionalitem?:ScriptItem
Defined in: script-host/src/host/world.ts:505
The stack in the player's hand. Absent for an empty hand.
player
readonlyplayer:string
Defined in: script-host/src/host/world.ts:502
The id of the player clicking, as ScriptWorld.players lists it.
target
readonlytarget:ScriptEntityRef
Defined in: script-host/src/host/world.ts:503
ItemUseIntent
Defined in: script-host/src/host/world.ts:428
An item a player is about to use, which a script's before-event sees before the item acts.
Properties
item
readonlyitem:ScriptItem
Defined in: script-host/src/host/world.ts:431
player
readonlyplayer:string
Defined in: script-host/src/host/world.ts:430
The id of the player using it, as ScriptWorld.players lists it.
ScriptAdminServer
Defined in: script-host/src/host/world.ts:1176
The dedicated server @minecraft/server-admin's dedicatedServer and its functions reach, which is the server's, not one world's.
Properties
allowList
readonlyallowList:ScriptAllowList
Defined in: script-host/src/host/world.ts:1187
Methods
isOperator()
isOperator(
player):boolean
Defined in: script-host/src/host/world.ts:1182
Whether a player in the world is an operator, by their id.
Parameters
player
string
Returns
boolean
kick()
kick(
player,reason):void
Defined in: script-host/src/host/world.ts:1186
Disconnects a player, with the reason their client shows.
Parameters
player
string
reason
string | undefined
Returns
void
reloadPermissions()
reloadPermissions():
void
Defined in: script-host/src/host/world.ts:1180
Reads the server's permission files again.
Returns
void
setOperator()
setOperator(
player,operator):void
Defined in: script-host/src/host/world.ts:1184
Makes a player an operator, or stops them being one.
Parameters
player
string
operator
boolean
Returns
void
stopServer()
stopServer():
void
Defined in: script-host/src/host/world.ts:1178
Stops the server, as /stop does, once the script that asked has returned.
Returns
void
ScriptAllowList
Defined in: script-host/src/host/world.ts:1156
The server's allow list, which dedicatedServer.allowList reads and writes.
Methods
add()
add(
entry):void
Defined in: script-host/src/host/world.ts:1162
Adds a player, unless the list has them already.
Parameters
entry
Returns
void
clear()
clear():
void
Defined in: script-host/src/host/world.ts:1165
Returns
void
contains()
contains(
player):boolean
Defined in: script-host/src/host/world.ts:1160
Parameters
player
Returns
boolean
enabled()
enabled():
boolean
Defined in: script-host/src/host/world.ts:1157
Returns
boolean
entries()
entries(): readonly
ScriptAllowListEntry[]
Defined in: script-host/src/host/world.ts:1159
Returns
readonly ScriptAllowListEntry[]
playerOf()
playerOf(
player):ScriptAllowListPlayer|undefined
Defined in: script-host/src/host/world.ts:1169
The name and xuid of a player in the world, by their id, which a Player argument names.
Parameters
player
string
Returns
ScriptAllowListPlayer | undefined
reload()
reload():
void
Defined in: script-host/src/host/world.ts:1167
Reads the list's file again.
Returns
void
remove()
remove(
player):boolean
Defined in: script-host/src/host/world.ts:1164
Parameters
player
Returns
boolean
Whether the player was on the list.
setEnabled()
setEnabled(
enabled):void
Defined in: script-host/src/host/world.ts:1158
Parameters
enabled
boolean
Returns
void
ScriptAllowListEntry
Defined in: script-host/src/host/world.ts:1143
One player on the server's allow list, by name, xuid or both.
Properties
ignoresPlayerLimit
readonlyignoresPlayerLimit:boolean
Defined in: script-host/src/host/world.ts:1146
name?
readonlyoptionalname?:string
Defined in: script-host/src/host/world.ts:1144
xuid?
readonlyoptionalxuid?:string
Defined in: script-host/src/host/world.ts:1145
ScriptAllowListPlayer
Defined in: script-host/src/host/world.ts:1150
Who an allow list lookup names: a name, a xuid, or both.
Properties
name?
readonlyoptionalname?:string
Defined in: script-host/src/host/world.ts:1151
xuid?
readonlyoptionalxuid?:string
Defined in: script-host/src/host/world.ts:1152
ScriptAttribute
Defined in: script-host/src/host/world.ts:448
An entity's attribute, such as its health, as an attribute component reads it.
Properties
current
readonlycurrent:number
Defined in: script-host/src/host/world.ts:449
default
readonlydefault:number
Defined in: script-host/src/host/world.ts:451
The value the entity's type gives it, which resetToDefaultValue returns to.
max
readonlymax:number
Defined in: script-host/src/host/world.ts:453
min
readonlymin:number
Defined in: script-host/src/host/world.ts:452
ScriptBlockLocation
Defined in: script-host/src/host/world.ts:1037
A block position in a dimension.
Extends
Properties
dimension
readonlydimension:string
Defined in: script-host/src/host/world.ts:1038
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
ScriptBlockPermutation
Defined in: script-host/src/host/world.ts:362
A block's type and the value of each of its states, as the Script API's BlockPermutation holds them.
Properties
states
readonlystates:Readonly<Record<string,string|number|boolean>>
Defined in: script-host/src/host/world.ts:364
typeId
readonlytypeId:string
Defined in: script-host/src/host/world.ts:363
ScriptBlockTypeInfo
Defined in: script-host/src/host/world.ts:190
A block type as the Script API describes it.
Properties
air
readonlyair:boolean
Defined in: script-host/src/host/world.ts:211
components
readonlycomponents: readonlystring[]
Defined in: script-host/src/host/world.ts:217
The components a block of the type has, by id.
item
readonlyitem:string|null
Defined in: script-host/src/host/world.ts:194
The item a block of the type gives, or null for none.
liquid
readonlyliquid:boolean
Defined in: script-host/src/host/world.ts:210
liquidFlowStops?
readonlyoptionalliquidFlowStops?: readonlyobject[]
Defined in: script-host/src/host/world.ts:206
The permutations that stop water flowing in from some directions, each with the sides it closes, as Block.liquidCanFlowFromDirection answers. Absent or empty when every permutation lets water in from every side.
localizationKey
readonlylocalizationKey:string
Defined in: script-host/src/host/world.ts:191
mapColor?
readonlyoptionalmapColor?:ScriptRgba
Defined in: script-host/src/host/world.ts:215
The color a block of the type shows on a map, as Block.getMapColor answers in the capture's biome.
mapColorComponent?
readonlyoptionalmapColorComponent?:object
Defined in: script-host/src/host/world.ts:224
color
readonlycolor:ScriptRgba
tintedColor
readonlytintedColor:ScriptRgba
tintMethod
readonlytintMethod:string
movable?
readonlyoptionalmovable?:object
Defined in: script-host/src/host/world.ts:218
movementType
readonlymovementType:string
stickyType
readonlystickyType:string
precipitation?
readonlyoptionalprecipitation?:object
Defined in: script-host/src/host/world.ts:219
accumulatesSnow
readonlyaccumulatesSnow:boolean
isSnowLoggable
readonlyisSnowLoggable:boolean
obstructsRain
readonlyobstructsRain:boolean
solid
readonlysolid:boolean
Defined in: script-host/src/host/world.ts:213
Whether a block of the type is solid and stops movement, as Block.isSolid answers.
tags
readonlytags: readonlystring[]
Defined in: script-host/src/host/world.ts:192
vibration?
readonlyoptionalvibration?:object
Defined in: script-host/src/host/world.ts:229
dampens
readonlydampens:boolean
occludes
readonlyoccludes:boolean
water
readonlywater:ScriptWaterAnswers
Defined in: script-host/src/host/world.ts:195
waterPermutations
readonlywaterPermutations: readonlyobject[]
Defined in: script-host/src/host/world.ts:197
The permutations whose water answers differ from the type's.
ScriptBook
Defined in: script-host/src/host/world.ts:151
What a book holds: its pages, and once signed, its title and author.
Properties
author?
readonlyoptionalauthor?:string
Defined in: script-host/src/host/world.ts:154
pages
readonlypages: readonlyScriptBookPage[]
Defined in: script-host/src/host/world.ts:152
title?
readonlyoptionaltitle?:string
Defined in: script-host/src/host/world.ts:153
ScriptCatalog
Defined in: script-host/src/host/world.ts:276
The game's block, item, enchantment and potion types as the Script API describes them, which BlockTypes, ItemTypes, EnchantmentTypes, Potions and the type facts of blocks and stacks read. Every list is in the order BDS lists it.
Methods
blockStates()
blockStates(): readonly
object[]
Defined in: script-host/src/host/world.ts:281
Every block state and the values the game declares for it.
Returns
readonly object[]
blockType()
blockType(
typeId):ScriptBlockTypeInfo|undefined
Defined in: script-host/src/host/world.ts:279
Parameters
typeId
string
Returns
ScriptBlockTypeInfo | undefined
blockTypes()
blockTypes(): readonly
string[]
Defined in: script-host/src/host/world.ts:278
Every block type's id.
Returns
readonly string[]
enchantments()
enchantments(): readonly
ScriptEnchantmentInfo[]
Defined in: script-host/src/host/world.ts:285
Returns
readonly ScriptEnchantmentInfo[]
itemType()
itemType(
typeId):ScriptItemInfo|undefined
Defined in: script-host/src/host/world.ts:284
Parameters
typeId
string
Returns
ScriptItemInfo | undefined
itemTypes()
itemTypes(): readonly
string[]
Defined in: script-host/src/host/world.ts:283
Every item type's id.
Returns
readonly string[]
potionDeliveries()
potionDeliveries(): readonly
string[]
Defined in: script-host/src/host/world.ts:289
Every potion delivery, such as Consume.
Returns
readonly string[]
potionEffects()
potionEffects(): readonly
object[]
Defined in: script-host/src/host/world.ts:287
Every potion effect, and how long it lasts when it is timed.
Returns
readonly object[]
potionItem()
potionItem(
effect,delivery): {data:number;typeId:string; } |undefined
Defined in: script-host/src/host/world.ts:291
The item and data value a potion of an effect and a delivery is, or undefined when none is.
Parameters
effect
string
delivery
string
Returns
{ data: number; typeId: string; } | undefined
potionOf()
potionOf(
typeId,data): {delivery:string;effect:string; } |undefined
Defined in: script-host/src/host/world.ts:293
The effect and delivery a potion item's data value holds, or undefined when it holds none.
Parameters
typeId
string
data
number
Returns
{ delivery: string; effect: string; } | undefined
ScriptCommandEnum
Defined in: script-host/src/host/world.ts:967
An enum a script registered for its commands' Enum parameters.
Properties
name
readonlyname:string
Defined in: script-host/src/host/world.ts:969
The name with its namespace, which a parameter names.
values
readonlyvalues: readonlystring[]
Defined in: script-host/src/host/world.ts:970
ScriptCommandOrigin
Defined in: script-host/src/host/world.ts:992
Who ran a custom command, as CustomCommandOrigin reads it.
Properties
initiator?
readonlyoptionalinitiator?:ScriptEntityRef
Defined in: script-host/src/host/world.ts:997
The player who talked to the NPC that ran it.
sourceEntity?
readonlyoptionalsourceEntity?:ScriptEntityRef
Defined in: script-host/src/host/world.ts:995
The entity the command runs as, absent for the server.
sourceType
readonlysourceType:ScriptEventSourceType
Defined in: script-host/src/host/world.ts:993
ScriptCommandOutcome
Defined in: script-host/src/host/world.ts:1001
What a custom command's callback answered, which the world tells the sender.
Properties
message?
readonlyoptionalmessage?:string
Defined in: script-host/src/host/world.ts:1004
The message the sender is shown. Absent when the callback gave none.
status
readonlystatus:"success"|"failure"
Defined in: script-host/src/host/world.ts:1002
ScriptCommandParameter
Defined in: script-host/src/host/world.ts:947
One parameter of a custom command.
Properties
enumName?
readonlyoptionalenumName?:string
Defined in: script-host/src/host/world.ts:951
The registered enum an Enum parameter takes its values from.
name
readonlyname:string
Defined in: script-host/src/host/world.ts:948
type
readonlytype:ScriptCommandParamType
Defined in: script-host/src/host/world.ts:949
ScriptCommandSet
Defined in: script-host/src/host/world.ts:1008
The custom commands the scripts registered in startup, and the way to run one.
Properties
commands
readonlycommands: readonlyScriptCustomCommand[]
Defined in: script-host/src/host/world.ts:1009
enums
readonlyenums: readonlyScriptCommandEnum[]
Defined in: script-host/src/host/world.ts:1010
Methods
run()
run(
name,origin,args):ScriptCommandOutcome
Defined in: script-host/src/host/world.ts:1016
Runs a command's callback, in restricted execution, while the command runs.
Parameters
name
string
The command's full name, as ScriptCustomCommand.name gives it.
origin
args
readonly ScriptCommandArgument[]
The arguments in parameter order, mandatory ones first, without the ones left out.
Returns
ScriptComponentSink
Defined in: script-host/src/host/world.ts:1128
Where the world sends the hooks of the custom components its blocks and items name. A hook a script can cancel runs at once, as a guard of the action it is about (ADR 0013); every other hook waits for the script flush at the end of the tick, as on BDS.
Methods
block()
block(
event):boolean
Defined in: script-host/src/host/world.ts:1137
Raises a block hook.
Parameters
event
Returns
boolean
Whether a script canceled it, which only beforeOnPlayerPlace can.
handlesBlock()
handlesBlock(
components,hook):boolean
Defined in: script-host/src/host/world.ts:1130
Whether a script registered one of the components with the hook, so the world can skip building an event.
Parameters
components
readonly ScriptComponentUse[]
hook
"beforeOnPlayerPlace" | "onBlockStateChange" | "onBreak" | "onEntity" | "onEntityFallOn" | "onPlace" | "onPlayerBreak" | "onPlayerInteract" | "onRandomTick" | "onRedstoneUpdate" | "onStepOn" | "onTick"
Returns
boolean
handlesItem()
handlesItem(
components,hook):boolean
Defined in: script-host/src/host/world.ts:1132
Whether a script registered one of the components with the hook.
Parameters
components
readonly ScriptComponentUse[]
hook
"onCompleteUse" | "onConsume" | "onHitEntity" | "onMineBlock" | "onUse" | "onUseOn"
Returns
boolean
item()
item(
event):void
Defined in: script-host/src/host/world.ts:1139
Raises an item hook.
Parameters
event
Returns
void
ScriptComponentUse
Defined in: script-host/src/host/world.ts:1023
A custom component a block or item names, with the parameters it gives it.
Properties
legacy?
readonlyoptionallegacy?:boolean
Defined in: script-host/src/host/world.ts:1033
Whether a block names it in minecraft:custom_components, as the formats before version 2 did. Such a block gets no parameters and none of the hooks Mojang added after it, such as onBreak, as the custom-components scenario recorded on BDS.
name
readonlyname:string
Defined in: script-host/src/host/world.ts:1025
The component's name with its namespace.
params?
readonlyoptionalparams?:unknown
Defined in: script-host/src/host/world.ts:1027
The parameters a version 2 block or item gives the component, as JSON data.
ScriptCustomCommand
Defined in: script-host/src/host/world.ts:955
A command a script registered in startup, as the world's command tree takes it.
Properties
cheatsRequired
readonlycheatsRequired:boolean
Defined in: script-host/src/host/world.ts:961
description
readonlydescription:string
Defined in: script-host/src/host/world.ts:958
mandatoryParameters
readonlymandatoryParameters: readonlyScriptCommandParameter[]
Defined in: script-host/src/host/world.ts:962
name
readonlyname:string
Defined in: script-host/src/host/world.ts:957
The name with its namespace, such as jsp:hello. BDS also answers to it without one.
optionalParameters
readonlyoptionalParameters: readonlyScriptCommandParameter[]
Defined in: script-host/src/host/world.ts:963
permissionLevel
readonlypermissionLevel:number
Defined in: script-host/src/host/world.ts:960
The CommandPermissionLevel it needs: 0 for anyone up to 4 for the owner.
ScriptDamageSource
Defined in: script-host/src/host/world.ts:518
What hurt an entity, as EntityDamageSource reads it.
Properties
cause
readonlycause:string
Defined in: script-host/src/host/world.ts:520
The cause, as EntityDamageCause names it, such as fall or entityAttack.
damagingEntity?
readonlyoptionaldamagingEntity?:ScriptEntityRef
Defined in: script-host/src/host/world.ts:522
The entity answerable for the blow, such as the archer of an arrow.
damagingProjectile?
readonlyoptionaldamagingProjectile?:ScriptEntityRef
Defined in: script-host/src/host/world.ts:524
The projectile that made contact, when it is not the damaging entity.
ScriptDebugShape
Defined in: script-host/src/host/world.ts:812
A debug shape as the world draws it, from what a script set on a @minecraft/debug-utilities shape. Each class's own properties are present for that class only. Floats hold what a 32-bit float keeps of the script's number, as BDS's do.
Properties
attachedTo?
readonlyoptionalattachedTo?:string
Defined in: script-host/src/host/world.ts:825
The id of the entity the shape follows, as ScriptWorld.entity takes it.
backfaceVisible?
readonlyoptionalbackfaceVisible?:boolean
Defined in: script-host/src/host/world.ts:848
backgroundColorOverride?
readonlyoptionalbackgroundColorOverride?:ScriptRgba
Defined in: script-host/src/host/world.ts:845
bound?
readonlyoptionalbound?:ScriptVector3
Defined in: script-host/src/host/world.ts:832
A box's extent.
color
readonlycolor:ScriptRgba
Defined in: script-host/src/host/world.ts:817
defaultVisibleToAll?
readonlyoptionaldefaultVisibleToAll?:boolean
Defined in: script-host/src/host/world.ts:855
Whether a player visibleTo does not name sees it, when visibleTo names none; true when absent.
depth?
readonlyoptionaldepth?:number
Defined in: script-host/src/host/world.ts:841
depthTest?
readonlyoptionaldepthTest?:boolean
Defined in: script-host/src/host/world.ts:847
dimension?
readonlyoptionaldimension?:string
Defined in: script-host/src/host/world.ts:816
The dimension it is drawn in, when the shape or addShape names one.
endLocation?
readonlyoptionalendLocation?:ScriptVector3
Defined in: script-host/src/host/world.ts:827
A line's or an arrow's other end.
headLength?
readonlyoptionalheadLength?:number
Defined in: script-host/src/host/world.ts:828
headRadius?
readonlyoptionalheadRadius?:number
Defined in: script-host/src/host/world.ts:829
headSegments?
readonlyoptionalheadSegments?:number
Defined in: script-host/src/host/world.ts:830
height?
readonlyoptionalheight?:number
Defined in: script-host/src/host/world.ts:835
hiddenFrom?
readonlyoptionalhiddenFrom?: readonlystring[]
Defined in: script-host/src/host/world.ts:853
The players it is never drawn for, by id.
kind
readonlykind:ScriptDebugShapeKind
Defined in: script-host/src/host/world.ts:813
lineGapHeight?
readonlyoptionallineGapHeight?:number
Defined in: script-host/src/host/world.ts:846
location
readonlylocation:ScriptVector3
Defined in: script-host/src/host/world.ts:814
maximumRenderDistance?
readonlyoptionalmaximumRenderDistance?:number
Defined in: script-host/src/host/world.ts:823
numSegments?
readonlyoptionalnumSegments?:number
Defined in: script-host/src/host/world.ts:837
A cone's or a cylinder's segments.
radii?
readonlyoptionalradii?:ScriptVector3|ScriptVector2
Defined in: script-host/src/host/world.ts:834
A cone's or a cylinder's radii along X and Z, or an ellipsoid's along X, Y and Z.
rotation
readonlyrotation:ScriptVector3
Defined in: script-host/src/host/world.ts:820
Pitch, yaw and roll, as the script gave them.
scale
readonlyscale:number
Defined in: script-host/src/host/world.ts:818
segmentsPerAxis?
readonlyoptionalsegmentsPerAxis?:number
Defined in: script-host/src/host/world.ts:838
text?
readonlyoptionaltext?:string
Defined in: script-host/src/host/world.ts:843
A text's words, with a RawMessage read as chat reads one.
textBackfaceVisible?
readonlyoptionaltextBackfaceVisible?:boolean
Defined in: script-host/src/host/world.ts:849
timeLeft?
readonlyoptionaltimeLeft?:number
Defined in: script-host/src/host/world.ts:822
The seconds left before the shape goes, as the tick counts them; absent for a shape that stays.
useRotation?
readonlyoptionaluseRotation?:boolean
Defined in: script-host/src/host/world.ts:844
visibleTo?
readonlyoptionalvisibleTo?: readonlystring[]
Defined in: script-host/src/host/world.ts:851
The players it is drawn for, by id. Absent or empty, it is drawn as defaultVisibleToAll says.
width?
readonlyoptionalwidth?:number
Defined in: script-host/src/host/world.ts:840
A pyramid's base.
ScriptDebugShapeChange
Defined in: script-host/src/host/world.ts:869
One change to the debug shapes a world draws: a shape to draw, or to draw again as it now is, or, without shape, one to stop drawing.
Properties
id
readonlyid:number
Defined in: script-host/src/host/world.ts:871
The shape's id, unique in the world for as long as the world's scripts run.
shape?
readonlyoptionalshape?:ScriptDebugShape
Defined in: script-host/src/host/world.ts:872
ScriptDisplay
Defined in: script-host/src/host/world.ts:324
What a display slot shows: an objective, and its order, as ObjectiveSortOrder numbers it.
Properties
objective
readonlyobjective:string
Defined in: script-host/src/host/world.ts:325
sortOrder
readonlysortOrder:0|1
Defined in: script-host/src/host/world.ts:327
0 for ascending, 1 for descending.
ScriptEffect
Defined in: script-host/src/host/world.ts:378
A status effect on an entity, as Effect reads it.
Extended by
Properties
amplifier
readonlyamplifier:number
Defined in: script-host/src/host/world.ts:382
One below the potency the effect's name shows.
duration
readonlyduration:number
Defined in: script-host/src/host/world.ts:384
The ticks left.
typeId
readonlytypeId:string
Defined in: script-host/src/host/world.ts:380
The effect's type, such as minecraft:speed.
ScriptEffectRequest
Defined in: script-host/src/host/world.ts:388
A status effect a script adds to an entity.
Extends
Properties
amplifier
readonlyamplifier:number
Defined in: script-host/src/host/world.ts:382
One below the potency the effect's name shows.
Inherited from
duration
readonlyduration:number
Defined in: script-host/src/host/world.ts:384
The ticks left.
Inherited from
showParticles
readonlyshowParticles:boolean
Defined in: script-host/src/host/world.ts:389
typeId
readonlytypeId:string
Defined in: script-host/src/host/world.ts:380
The effect's type, such as minecraft:speed.
Inherited from
ScriptEnchantment
Defined in: script-host/src/host/world.ts:142
An enchantment on a stack.
Properties
id
readonlyid:string
Defined in: script-host/src/host/world.ts:143
level
readonlylevel:number
Defined in: script-host/src/host/world.ts:144
ScriptEnchantmentInfo
Defined in: script-host/src/host/world.ts:264
An enchantment type, the items it goes on and the enchantments it refuses beside it.
Properties
conflicts
readonlyconflicts: readonlystring[]
Defined in: script-host/src/host/world.ts:268
id
readonlyid:string
Defined in: script-host/src/host/world.ts:265
items
readonlyitems: readonlystring[]
Defined in: script-host/src/host/world.ts:267
maxLevel
readonlymaxLevel:number
Defined in: script-host/src/host/world.ts:266
ScriptEntityRef
Defined in: script-host/src/host/world.ts:974
An entity a command argument or a hook names: its id, and its type, which picks its class.
Properties
id
readonlyid:string
Defined in: script-host/src/host/world.ts:975
typeId
readonlytypeId:string
Defined in: script-host/src/host/world.ts:976
ScriptEntityState
Defined in: script-host/src/host/world.ts:62
An entity as the world holds it now, read in one call.
Properties
dimension
readonlydimension:string
Defined in: script-host/src/host/world.ts:68
The dimension it is in, as ScriptWorld.dimensions names it.
gameMode?
readonlyoptionalgameMode?:ScriptGameMode
Defined in: script-host/src/host/world.ts:85
A player's game mode. Absent for every other entity.
headLocation?
readonlyoptionalheadLocation?:ScriptVector3
Defined in: script-host/src/host/world.ts:81
Where its eyes are. Absent reads as its location.
id
readonlyid:string
Defined in: script-host/src/host/world.ts:64
The entity's id, which every other read and write names it by.
inventorySize?
readonlyoptionalinventorySize?:number
Defined in: script-host/src/host/world.ts:77
How many slots its inventory has. Absent for an entity without one.
location
readonlylocation:ScriptVector3
Defined in: script-host/src/host/world.ts:70
Where its feet are.
name?
readonlyoptionalname?:string
Defined in: script-host/src/host/world.ts:75
A player's name. Absent for every other entity.
nameTag
readonlynameTag:string
Defined in: script-host/src/host/world.ts:72
Its name tag; a player's is their name. Empty when it has none.
rotation?
readonlyoptionalrotation?:object
Defined in: script-host/src/host/world.ts:79
Its rotation in degrees: x the pitch, y the yaw. Absent reads as facing south, level.
x
readonlyx:number
y
readonlyy:number
selectedSlot?
readonlyoptionalselectedSlot?:number
Defined in: script-host/src/host/world.ts:87
The hotbar slot a player holds, from 0 to 8. Absent for every other entity.
sneaking?
readonlyoptionalsneaking?:boolean
Defined in: script-host/src/host/world.ts:83
Whether it is sneaking.
tags
readonlytags: readonlystring[]
Defined in: script-host/src/host/world.ts:73
typeId
readonlytypeId:string
Defined in: script-host/src/host/world.ts:66
Its type, such as minecraft:armor_stand.
ScriptEquipment
Defined in: script-host/src/host/world.ts:438
What an entity wears and holds, as EntityEquippableComponent reads it.
Properties
armor
readonlyarmor:number
Defined in: script-host/src/host/world.ts:442
The armor points the worn pieces give, out of 20 for a full diamond set.
slots
readonlyslots:Readonly<Partial<Record<ScriptEquipmentSlot,ScriptItem>>>
Defined in: script-host/src/host/world.ts:440
The stack in each slot, with an empty slot left out.
toughness
readonlytoughness:number
Defined in: script-host/src/host/world.ts:444
The armor toughness the worn pieces give.
ScriptFormChannel
Defined in: script-host/src/host/world.ts:708
How the scripts' forms reach the world's players, and their answers come back.
Methods
closeAll()
closeAll(
player):void
Defined in: script-host/src/host/world.ts:712
Closes every form a player has open: a ClientboundCloseFormPacket.
Parameters
player
string
Returns
void
closeDataDriven()?
optionalcloseDataDriven(player,formId):void
Defined in: script-host/src/host/world.ts:723
Asks the player's client to close one data-driven screen, which it reports closed in reply.
Parameters
player
string
formId
number
Returns
void
show()
show(
player,formId,json):void
Defined in: script-host/src/host/world.ts:710
Sends a player a form: a ModalFormRequestPacket with the id and the JSON as they are.
Parameters
player
string
formId
number
json
string
Returns
void
showDataDriven()?
optionalshowDataDriven(player,formId,screen):boolean
Defined in: script-host/src/host/world.ts:719
Shows a player a data-driven screen: sets its data store property and opens it.
Parameters
player
string
formId
number
screen
Returns
boolean
Whether the player's client can show one. A world that cannot show any leaves this out.
takeDataDrivenResponses()?
optionaltakeDataDrivenResponses(): readonlyDataDrivenResponse[]
Defined in: script-host/src/host/world.ts:725
The data-driven screen writes and closes the input step admitted since the last call, in order.
Returns
readonly DataDrivenResponse[]
takeResponses()
takeResponses(): readonly
ScriptFormResponse[]
Defined in: script-host/src/host/world.ts:714
The answers the input step admitted since the last call, in the order they arrived.
Returns
readonly ScriptFormResponse[]
updateDataDriven()?
optionalupdateDataDriven(player,property,change):void
Defined in: script-host/src/host/world.ts:721
Changes one path of a data-driven screen's property the player has open.
Parameters
player
string
property
string
change
Returns
void
ScriptFormResponse
Defined in: script-host/src/host/world.ts:633
A client's answer to a form, which reaches the scripts as an input of the tick it arrived in.
Properties
cancelReason
readonlycancelReason:number|null
Defined in: script-host/src/host/world.ts:641
The cancel reason byte the client sent, or null when it sent none.
formId
readonlyformId:number
Defined in: script-host/src/host/world.ts:637
The id the form was sent with.
player
readonlyplayer:string
Defined in: script-host/src/host/world.ts:635
The id of the player who answered, as ScriptWorld.players lists it.
response
readonlyresponse:string|null
Defined in: script-host/src/host/world.ts:639
The JSON text the client sent, or null when it sent none.
ScriptGameEvent
Defined in: script-host/src/host/world.ts:620
An event the world raises for the scripts, by the Script API class its object has, such as PlayerPlaceBlockAfterEvent, with each member's value by the member's name. A member with no value reads undefined.
Properties
event
readonlyevent:string
Defined in: script-host/src/host/world.ts:621
fields
readonlyfields:Readonly<Record<string,ScriptEventValue>>
Defined in: script-host/src/host/world.ts:622
ScriptHttpChannel
Defined in: script-host/src/host/world.ts:764
How the scripts' @minecraft/server-net requests reach the network, and their results come back. The network runs off the tick, and a result is an input: it enters the world in a later tick's input step, which records it, so a replay gets it back without the network (ADR 0021).
Methods
cancel()
cancel(
id):void
Defined in: script-host/src/host/world.ts:771
Abandons a request in flight; its result, if one comes, is dropped.
Parameters
id
number
Returns
void
send()
send(
id,request):void
Defined in: script-host/src/host/world.ts:769
Starts a request off the tick.
Parameters
id
number
The request's id, which its result carries. The runtime counts them from 1 and never reuses one.
request
Returns
void
takeResponses()
takeResponses(): readonly
ScriptHttpResult[]
Defined in: script-host/src/host/world.ts:773
The results the input step admitted since the last call, in the order it admitted them.
Returns
readonly ScriptHttpResult[]
ScriptHttpRequest
Defined in: script-host/src/host/world.ts:732
One HTTP request a script sent, as the network gets it.
Properties
body
readonlybody:string
Defined in: script-host/src/host/world.ts:739
The body; a Get or Head request sends none.
headers
readonlyheaders: readonly (readonly [string,string])[]
Defined in: script-host/src/host/world.ts:737
The headers in the order the script added them, each secret's text in place of its SecretString.
method
readonlymethod:ScriptHttpMethod
Defined in: script-host/src/host/world.ts:735
timeout
readonlytimeout:number
Defined in: script-host/src/host/world.ts:741
Seconds before the request is abandoned; 0 for no limit.
uri
readonlyuri:string
Defined in: script-host/src/host/world.ts:734
An http or https URI.
ScriptItem
Defined in: script-host/src/host/world.ts:103
An item stack as plain data.
Properties
amount
readonlyamount:number
Defined in: script-host/src/host/world.ts:106
blockProperties?
readonlyoptionalblockProperties?:ScriptProperties
Defined in: script-host/src/host/world.ts:138
The dynamic properties the stack gives the block it places, by id. Absent or empty for none.
book?
readonlyoptionalbook?:ScriptBook
Defined in: script-host/src/host/world.ts:132
A book's pages, title and author. Absent for a book with nothing written.
canDestroy?
readonlyoptionalcanDestroy?: readonlystring[]
Defined in: script-host/src/host/world.ts:120
The blocks an adventure-mode player may break with the stack. Absent or empty for none.
canPlaceOn?
readonlyoptionalcanPlaceOn?: readonlystring[]
Defined in: script-host/src/host/world.ts:122
The blocks an adventure-mode player may place the stack on. Absent or empty for none.
damage?
readonlyoptionaldamage?:number
Defined in: script-host/src/host/world.ts:112
The durability the stack has lost, for an item with durability. Absent or 0 when it has lost none.
data?
readonlyoptionaldata?:number
Defined in: script-host/src/host/world.ts:130
The stack's aux value, which picks a potion's effect. Absent for 0.
dyeColor?
readonlyoptionaldyeColor?:ScriptRgb
Defined in: script-host/src/host/world.ts:134
The color a dyeable item was dyed, as red, green and blue from 0 to 1. Absent for its own.
dynamicProperties?
readonlyoptionaldynamicProperties?:ReadonlyMap<string,ScriptProperties>
Defined in: script-host/src/host/world.ts:118
The stack's dynamic properties, by the script module UUID of the pack that set them, as BDS keys them on an item. Absent or empty when it has none. Only a stack of one item can hold them.
enchantments?
readonlyoptionalenchantments?: readonlyScriptEnchantment[]
Defined in: script-host/src/host/world.ts:128
The enchantments on the stack, by the Script API's id without a namespace, such as sharpness.
keepOnDeath?
readonlyoptionalkeepOnDeath?:boolean
Defined in: script-host/src/host/world.ts:124
Whether the stack stays in its owner's inventory when they die. Absent for false.
lockMode?
readonlyoptionallockMode?:"slot"|"inventory"
Defined in: script-host/src/host/world.ts:126
Where the stack is locked, as ItemLockMode names it. Absent for none.
lore?
readonlyoptionallore?: readonlystring[]
Defined in: script-host/src/host/world.ts:110
The lines of lore under its name. Absent or empty when it has none.
nameTag?
readonlyoptionalnameTag?:string
Defined in: script-host/src/host/world.ts:108
The stack's custom name. Absent when it has none.
typeId
readonlytypeId:string
Defined in: script-host/src/host/world.ts:105
The item's type, such as minecraft:apple.
unbreakable?
readonlyoptionalunbreakable?:boolean
Defined in: script-host/src/host/world.ts:136
Whether the stack takes no damage from use. Absent for false.
ScriptItemInfo
Defined in: script-host/src/host/world.ts:233
An item type as the Script API describes it.
Properties
components
readonlycomponents: readonlystring[]
Defined in: script-host/src/host/world.ts:240
The components a new stack of the type has, by id.
compostable?
readonlyoptionalcompostable?:object
Defined in: script-host/src/host/world.ts:253
chance
readonlychance:number
containerRules?
readonlyoptionalcontainerRules?: {allowedItems: readonlystring[];allowNestedStorageItems:boolean;bannedItems: readonlystring[];weightLimit?:number; } |null
Defined in: script-host/src/host/world.ts:255
cooldown?
readonlyoptionalcooldown?:object
Defined in: script-host/src/host/world.ts:248
category
readonlycategory:string
ticks
readonlyticks:number
durability?
readonlyoptionaldurability?:object
Defined in: script-host/src/host/world.ts:241
damageChance
readonlydamageChance: readonlynumber[]
maxDurability
readonlymaxDurability:number
dyeable?
readonlyoptionaldyeable?:object
Defined in: script-host/src/host/world.ts:252
defaultColor?
readonlyoptionaldefaultColor?:ScriptRgb
enchantable?
readonlyoptionalenchantable?:object
Defined in: script-host/src/host/world.ts:250
The enchantment slots of the type, one entry each, which BDS hands back as undefined.
slots
readonlyslots: readonlyunknown[]
food?
readonlyoptionalfood?:object
Defined in: script-host/src/host/world.ts:242
canAlwaysEat
readonlycanAlwaysEat:boolean
nutrition
readonlynutrition:number
saturationModifier
readonlysaturationModifier:number
usingConvertsTo
readonlyusingConvertsTo:string
inventorySize?
readonlyoptionalinventorySize?:number
Defined in: script-host/src/host/world.ts:254
localizationKey
readonlylocalizationKey:string
Defined in: script-host/src/host/world.ts:234
maxAmount
readonlymaxAmount:number
Defined in: script-host/src/host/world.ts:235
potion?
readonlyoptionalpotion?:object
Defined in: script-host/src/host/world.ts:251
delivery
readonlydelivery:string
effect
readonlyeffect:string
stackable
readonlystackable:boolean
Defined in: script-host/src/host/world.ts:236
tags
readonlytags: readonlystring[]
Defined in: script-host/src/host/world.ts:238
weight
readonlyweight:number
Defined in: script-host/src/host/world.ts:237
ScriptItemType
Defined in: script-host/src/host/world.ts:368
An item type the world knows.
Properties
maxDurability?
readonlyoptionalmaxDurability?:number
Defined in: script-host/src/host/world.ts:374
The durability a new stack has, for a type that wears out. Absent for every other type.
maxStackSize
readonlymaxStackSize:number
Defined in: script-host/src/host/world.ts:372
How many items one stack holds at most.
typeId
readonlytypeId:string
Defined in: script-host/src/host/world.ts:370
The type's full id, with its namespace.
ScriptLegacyStates
Defined in: script-host/src/host/world.ts:171
How BDS's Script API reports a block type's states: every state of its default permutation, and for a state another one decides, that state with the value each of its values gives.
Properties
defaults
readonlydefaults:Readonly<Record<string,ScriptStateValue>>
Defined in: script-host/src/host/world.ts:172
follows
readonlyfollows:Readonly<Record<string, readonlyobject[]>>
Defined in: script-host/src/host/world.ts:173
ScriptObjective
Defined in: script-host/src/host/world.ts:315
A scoreboard objective.
Properties
displayName
readonlydisplayName:string
Defined in: script-host/src/host/world.ts:317
id
readonlyid:string
Defined in: script-host/src/host/world.ts:316
ScriptParticipant
Defined in: script-host/src/host/world.ts:300
A scoreboard participant: a name with no entity, an entity or a player.
Properties
displayName
readonlydisplayName:string
Defined in: script-host/src/host/world.ts:305
A fake player's name, a player's name, or an entity's id.
entity?
readonlyoptionalentity?:string
Defined in: script-host/src/host/world.ts:307
The id of its entity, when it is an entity or a player who is in the world.
id
readonlyid:number
Defined in: script-host/src/host/world.ts:302
The id the scoreboard gave it, which a save keeps.
type
readonlytype:ScriptParticipantType
Defined in: script-host/src/host/world.ts:303
ScriptRgb
Defined in: script-host/src/host/world.ts:158
A color without alpha, each part from 0 to 1.
Properties
blue
readonlyblue:number
Defined in: script-host/src/host/world.ts:161
green
readonlygreen:number
Defined in: script-host/src/host/world.ts:160
red
readonlyred:number
Defined in: script-host/src/host/world.ts:159
ScriptRgba
Defined in: script-host/src/host/world.ts:794
A color with alpha, each part from 0 to 1 as a script gives it, though nothing clamps it.
Properties
alpha
readonlyalpha:number
Defined in: script-host/src/host/world.ts:798
blue
readonlyblue:number
Defined in: script-host/src/host/world.ts:797
green
readonlygreen:number
Defined in: script-host/src/host/world.ts:796
red
readonlyred:number
Defined in: script-host/src/host/world.ts:795
ScriptScoreboard
Defined in: script-host/src/host/world.ts:331
The world's one scoreboard, which /scoreboard and the scripts share.
Methods
addObjective()
addObjective(
id,displayName):boolean
Defined in: script-host/src/host/world.ts:336
Parameters
id
string
displayName
string
Returns
boolean
False when an objective with the id exists.
display()
display(
slot):ScriptDisplay|undefined
Defined in: script-host/src/host/world.ts:356
What a display slot shows, or undefined when it is empty.
Parameters
slot
Returns
ScriptDisplay | undefined
objective()
objective(
id):ScriptObjective|undefined
Defined in: script-host/src/host/world.ts:334
Parameters
id
string
Returns
ScriptObjective | undefined
objectives()
objectives(): readonly
ScriptObjective[]
Defined in: script-host/src/host/world.ts:333
Every objective, in the order they were added.
Returns
readonly ScriptObjective[]
participant()
participant(
ref):ScriptParticipant|undefined
Defined in: script-host/src/host/world.ts:342
Finds a participant that has a score in some objective, without making one.
Parameters
ref
Returns
ScriptParticipant | undefined
participants()
participants(): readonly
ScriptParticipant[]
Defined in: script-host/src/host/world.ts:340
Every participant with a score in some objective, in the order they first got one.
Returns
readonly ScriptParticipant[]
removeObjective()
removeObjective(
id):boolean
Defined in: script-host/src/host/world.ts:338
Removes an objective, its scores, and every display slot showing it.
Parameters
id
string
Returns
boolean
False when there is none.
removeScore()
removeScore(
objective,participant):boolean
Defined in: script-host/src/host/world.ts:354
Parameters
objective
string
participant
number
Returns
boolean
False when the participant had no score in the objective.
score()
score(
objective,participant):number|undefined
Defined in: script-host/src/host/world.ts:346
A participant's score, or undefined when it has none in the objective.
Parameters
objective
string
participant
number
Returns
number | undefined
scores()
scores(
objective): readonlyobject[]
Defined in: script-host/src/host/world.ts:344
Every score of an objective, by participant, in the order the participants first got one.
Parameters
objective
string
Returns
readonly object[]
setDisplay()
setDisplay(
slot,display):void
Defined in: script-host/src/host/world.ts:358
Shows an objective in a slot, or empties the slot when display is undefined.
Parameters
slot
display
ScriptDisplay | undefined
Returns
void
setScore()
setScore(
objective,ref,score):ScriptParticipant
Defined in: script-host/src/host/world.ts:352
Writes a score, making the participant when it has none.
Parameters
objective
string
ref
score
number
A whole number in the 32-bit range.
Returns
The participant.
ScriptSimulatedPlayers
Defined in: script-host/src/host/world.ts:914
The GameTest simulated players of a world: players with no client, which every script, command and other player sees as a player (ADR 0009).
Methods
act()
act(
id,action):boolean
Defined in: script-host/src/host/world.ts:927
Makes a simulated player act.
Parameters
id
string
action
Returns
boolean
Whether the action happened, such as a jump from the ground or a swing that hit.
remove()
remove(
id):void
Defined in: script-host/src/host/world.ts:922
Takes a simulated player out of the world, as a client's disconnect does.
Parameters
id
string
Returns
void
spawn()
spawn(
name,dimension,location,gameMode):string|undefined
Defined in: script-host/src/host/world.ts:920
Adds a player with no client to the world, in the tick the call is made.
Parameters
name
string
dimension
string
location
gameMode
Returns
string | undefined
The new player's id, as ScriptWorld.players lists it, or undefined when the world cannot place a player there.
tick()
tick():
void
Defined in: script-host/src/host/world.ts:929
Moves the simulated players one tick on: their walks and jumps.
Returns
void
ScriptSound
Defined in: script-host/src/host/world.ts:407
A sound a script plays, as /playsound plays one.
Properties
dimension
readonlydimension:string
Defined in: script-host/src/host/world.ts:410
location
readonlylocation:ScriptVector3
Defined in: script-host/src/host/world.ts:411
pitch
readonlypitch:number
Defined in: script-host/src/host/world.ts:413
player?
readonlyoptionalplayer?:string
Defined in: script-host/src/host/world.ts:415
The id of the one player who hears it. Everyone near the location hears it when absent.
sound
readonlysound:string
Defined in: script-host/src/host/world.ts:409
The sound's name, such as random.orb.
volume
readonlyvolume:number
Defined in: script-host/src/host/world.ts:412
ScriptStructure
Defined in: script-host/src/host/world.ts:463
A structure as plain data: a box of blocks, each an index into its palette, or -1 where the structure has no block, as a structure void leaves one.
Properties
blocks
readonlyblocks: readonlynumber[]
Defined in: script-host/src/host/world.ts:467
The blocks, x outermost, then y, then z, as a .mcstructure orders them.
palette
readonlypalette: readonlyScriptBlockPermutation[]
Defined in: script-host/src/host/world.ts:465
saveMode
readonlysaveMode:ScriptStructureSaveMode
Defined in: script-host/src/host/world.ts:468
size
readonlysize:ScriptVector3
Defined in: script-host/src/host/world.ts:464
ScriptStructureStore
Defined in: script-host/src/host/world.ts:476
The structures of a world, by their ids with a namespace, such as mystructure:house: the ones scripts keep, and the ones the world's behavior packs ship in structures/, which get finds when no kept structure has the id.
Methods
delete()
delete(
id):boolean
Defined in: script-host/src/host/world.ts:480
Parameters
id
string
Returns
boolean
False when there was none.
get()
get(
id):ScriptStructure|undefined
Defined in: script-host/src/host/world.ts:477
Parameters
id
string
Returns
ScriptStructure | undefined
ids()
ids(): readonly
string[]
Defined in: script-host/src/host/world.ts:482
Every id scripts keep, in the order the structures were first kept.
Returns
readonly string[]
packIds()?
optionalpackIds(): readonlystring[]
Defined in: script-host/src/host/world.ts:484
The ids of the structures the packs ship, which getPackStructureIds lists. None when absent.
Returns
readonly string[]
set()
set(
id,structure):void
Defined in: script-host/src/host/world.ts:478
Parameters
id
string
structure
Returns
void
ScriptVector2
Defined in: script-host/src/host/world.ts:802
A pair of numbers, such as a cone's radii along X and Z.
Properties
x
readonlyx:number
Defined in: script-host/src/host/world.ts:803
y
readonlyy:number
Defined in: script-host/src/host/world.ts:804
ScriptVector3
Defined in: script-host/src/host/world.ts:55
A position in a dimension, in blocks.
Extended by
Properties
x
readonlyx:number
Defined in: script-host/src/host/world.ts:56
y
readonlyy:number
Defined in: script-host/src/host/world.ts:57
z
readonlyz:number
Defined in: script-host/src/host/world.ts:58
ScriptWaterAnswers
Defined in: script-host/src/host/world.ts:182
What water does to a permutation, by the four LiquidType.Water questions of the Script API.
Properties
blocking
readonlyblocking:boolean
Defined in: script-host/src/host/world.ts:184
contain
readonlycontain:boolean
Defined in: script-host/src/host/world.ts:183
destroyed
readonlydestroyed:boolean
Defined in: script-host/src/host/world.ts:185
spawns
readonlyspawns:boolean
Defined in: script-host/src/host/world.ts:186
ScriptWorld
Defined in: script-host/src/host/world.ts:1191
What the script host reads and writes of one world.
Properties
catalog?
readonlyoptionalcatalog?:ScriptCatalog
Defined in: script-host/src/host/world.ts:1496
The game's block, item, enchantment and potion types. A world without it has only the types it resolves.
entitySystems?
readonlyoptionalentitySystems?:ScriptEntitySystems
Defined in: script-host/src/host/world.ts:1494
The entity and player systems the entity members reach. A world without them gives those members no behavior.
forms?
readonlyoptionalforms?:ScriptFormChannel
Defined in: script-host/src/host/world.ts:1355
The channel @minecraft/server-ui forms travel over. A world without one sends no form.
http?
readonlyoptionalhttp?:ScriptHttpChannel
Defined in: script-host/src/host/world.ts:1357
The channel @minecraft/server-net requests travel over. A world without one fails each request.
scoreboard
readonlyscoreboard:ScriptScoreboard
Defined in: script-host/src/host/world.ts:1353
The world's scoreboard, which /scoreboard shares.
simulatedPlayers?
readonlyoptionalsimulatedPlayers?:ScriptSimulatedPlayers
Defined in: script-host/src/host/world.ts:1367
The world's GameTest simulated players. A world without them refuses to spawn one.
structures?
readonlyoptionalstructures?:ScriptStructureStore
Defined in: script-host/src/host/world.ts:1471
The world's structures, which world.structureManager reads and writes. A world without them keeps none.
worldSystem?
readonlyoptionalworldSystem?:ScriptWorldSystem
Defined in: script-host/src/host/world.ts:1519
The world's clock, spawn, difficulty, game rules and music, which the world and system members read and write. A world without it keeps them in memory for as long as its packs run.
Methods
addEffect()?
optionaladdEffect(id,effect):void
Defined in: script-host/src/host/world.ts:1405
Adds a status effect to an entity, as /effect does: one that is no stronger and no longer than the effect it already has changes nothing.
Parameters
id
string
effect
Returns
void
addTag()
addTag(
id,tag):boolean
Defined in: script-host/src/host/world.ts:1239
Parameters
id
string
tag
string
Returns
boolean
False when the entity already has the tag.
applyDamage()?
optionalapplyDamage(id,amount,source):boolean
Defined in: script-host/src/host/world.ts:1480
Hurts an entity through the world's damage pipeline, as /damage does.
Parameters
id
string
amount
number
The blow, before armor and resistance.
source
Returns
boolean
Whether the blow landed. A blow no stronger than the one the entity is still recovering from lands without taking health, and one at a dead entity does not land.
attribute()?
optionalattribute(id,name):ScriptAttribute|undefined
Defined in: script-host/src/host/world.ts:1460
One of an entity's attributes.
Parameters
id
string
name
string
The attribute component's id, such as minecraft:health.
Returns
ScriptAttribute | undefined
Undefined for an entity that is gone or whose type has no such attribute.
bindComponents()?
optionalbindComponents(sink): () =>void
Defined in: script-host/src/host/world.ts:1492
Sends the hooks of the custom components the world's blocks and items name to sink, once the scripts have registered them. A world without it raises no hook.
Parameters
sink
Returns
A function that stops it.
() => void
block()
block(
dimension,location):ScriptBlockPermutation|undefined
Defined in: script-host/src/host/world.ts:1256
Reads one block.
Parameters
dimension
string
location
A block position, in whole numbers.
Returns
ScriptBlockPermutation | undefined
Undefined when its chunk is not loaded.
blockInventory()?
optionalblockInventory(dimension,location): readonly (ScriptItem|null)[] |undefined
Defined in: script-host/src/host/world.ts:1412
The slots of the container a block holds, such as a chest's, each the stack it holds or null.
Parameters
dimension
string
location
Returns
readonly (ScriptItem | null)[] | undefined
Undefined for a block that holds none, or one in a chunk that is not loaded.
blockLight()?
optionalblockLight(dimension,location): {block:number;sky:number; } |undefined
Defined in: script-host/src/host/world.ts:1498
The block light and sky light at a loaded block, each from 0 to 15, or undefined where its chunk is not loaded.
Parameters
dimension
string
location
Returns
{ block: number; sky: number; } | undefined
clearDynamicProperties()
clearDynamicProperties(
owner,pack):void
Defined in: script-host/src/host/world.ts:1351
Deletes every dynamic property one pack set on the world or on a live entity.
Parameters
owner
pack
string
Returns
void
clock()
clock():
number
Defined in: script-host/src/host/world.ts:1327
The wall clock as the input step admitted it for the current tick, in milliseconds since the epoch. Date reads this rather than the host's clock, so a replay sees the same dates (ADR 0021).
Returns
number
dimensions()
dimensions(): readonly
string[]
Defined in: script-host/src/host/world.ts:1193
The world's dimensions, as Bedrock names them, such as minecraft:overworld.
Returns
readonly string[]
dimensionTypes()?
optionaldimensionTypes(): readonlystring[]
Defined in: script-host/src/host/world.ts:1467
Every dimension type the world registers, as Bedrock names them, in the order of their numeric ids. A world without it lists its dimensions.
Returns
readonly string[]
drawDebugShapes()?
optionaldrawDebugShapes(changes):void
Defined in: script-host/src/host/world.ts:1365
Draws, redraws or removes @minecraft/debug-utilities shapes for every player, once per script flush that changed any. A world without it draws none, and the scripts still read their shapes back the same.
Parameters
changes
readonly ScriptDebugShapeChange[]
Returns
void
dynamicProperties()
dynamicProperties(
owner,pack):ScriptProperties|undefined
Defined in: script-host/src/host/world.ts:1339
One pack's dynamic properties of the world or of an entity.
Parameters
owner
pack
string
The pack's header UUID, which BDS keys a world's and an entity's properties by.
Returns
ScriptProperties | undefined
Undefined for an entity that is gone.
effects()?
optionaleffects(id): readonlyScriptEffect[] |undefined
Defined in: script-host/src/host/world.ts:1400
The status effects on an entity, in the order they were added.
Parameters
id
string
Returns
readonly ScriptEffect[] | undefined
Undefined for an entity that is gone.
effectTypes()?
optionaleffectTypes(): readonlystring[]
Defined in: script-host/src/host/world.ts:1469
Every status effect type the world knows, by its id with a namespace.
Returns
readonly string[]
entities()
entities(
dimension): readonlyScriptEntityState[]
Defined in: script-host/src/host/world.ts:1220
Every entity of a dimension that is loaded, players included, in a fixed order.
Parameters
dimension
string
Returns
readonly ScriptEntityState[]
entity()
entity(
id):ScriptEntityState|undefined
Defined in: script-host/src/host/world.ts:1218
Reads one entity, a player included.
Parameters
id
string
Returns
ScriptEntityState | undefined
Undefined once the entity is dead or gone, which makes its script object invalid.
equipment()?
optionalequipment(id):ScriptEquipment|undefined
Defined in: script-host/src/host/world.ts:1449
What an entity wears and holds.
Parameters
id
string
Returns
ScriptEquipment | undefined
Undefined for an entity that is gone or has no equipment a script reaches, which is any but a player, as on BDS.
guardBlockBreak()?
optionalguardBlockBreak(guard): () =>void
Defined in: script-host/src/host/world.ts:1425
Adds a guard to the block breaking of the world's players, which runs before the block goes. A veto leaves the block where it is.
Parameters
guard
Returns
A function that removes it.
() => void
guardBlockInteract()?
optionalguardBlockInteract(guard): () =>void
Defined in: script-host/src/host/world.ts:1437
Adds a guard to the block clicks of the world's players, which runs before the click opens, uses or places anything. A veto drops the click.
Parameters
guard
VetoGuard<BlockInteractIntent>
Returns
A function that removes it.
() => void
guardChat()
guardChat(
guard): () =>void
Defined in: script-host/src/host/world.ts:1319
Adds a guard to the chat action of the world's players, which runs before any other player, the console or a plugin gets the line. A veto drops the line. The guard cannot change the line: ChatSendBeforeEvent.message is read-only in the Script API.
Parameters
guard
Returns
A function that removes it.
() => void
guardEntityInteract()?
optionalguardEntityInteract(guard): () =>void
Defined in: script-host/src/host/world.ts:1443
Adds a guard to the entity clicks of the world's players, which runs before the click does anything. A veto drops the click.
Parameters
guard
VetoGuard<EntityInteractIntent>
Returns
A function that removes it.
() => void
guardGameEvents()?
optionalguardGameEvents(guard): () =>void
Defined in: script-host/src/host/world.ts:1514
Adds a guard to every action a before-event of ScriptGameEvent describes, such as a player's block placement. The world calls it before the action, and the action goes on with the fields the verdict hands back. A world without it raises none of those before-events.
Parameters
guard
Returns
A function that removes the guard.
() => void
guardItemUse()?
optionalguardItemUse(guard): () =>void
Defined in: script-host/src/host/world.ts:1431
Adds a guard to the item use of the world's players, which runs before the item acts. A veto stops the use.
Parameters
guard
Returns
A function that removes it.
() => void
guardWeather()
guardWeather(
guard): () =>void
Defined in: script-host/src/host/world.ts:1312
Adds a guard to the weather action's guard stage.
Parameters
guard
Returns
A function that removes it.
() => void
heightRange()
heightRange(
dimension):object
Defined in: script-host/src/host/world.ts:1250
The lowest block height of a dimension, and the height above its top block.
Parameters
dimension
string
Returns
object
max
readonlymax:number
min
readonlymin:number
inventory()
inventory(
id): readonly (ScriptItem|null)[] |undefined
Defined in: script-host/src/host/world.ts:1246
The slots of an entity's inventory, in order, each the stack it holds or null.
Parameters
id
string
Returns
readonly (ScriptItem | null)[] | undefined
Undefined for an entity without an inventory.
isEffectType()?
optionalisEffectType(typeId):boolean
Defined in: script-host/src/host/world.ts:1395
Whether the world knows a status effect type, such as minecraft:speed.
Parameters
typeId
string
Returns
boolean
itemType()
itemType(
typeId):ScriptItemType|undefined
Defined in: script-host/src/host/world.ts:1280
Looks an item type up.
Parameters
typeId
string
The type with its namespace.
Returns
ScriptItemType | undefined
jobSteps()?
optionaljobSteps():number
Defined in: script-host/src/host/world.ts:1333
The interpreter steps the system.runJob jobs may take this tick, as the input step admitted them: BDS gives jobs a time slice from its frame-time estimates, and a host that measures its ticks turns the time left into steps. Absent, jobs take JOB_STEPS_PER_TICK.
Returns
number
kill()
kill(
id):boolean
Defined in: script-host/src/host/world.ts:1234
Kills an entity through the world's damage pipeline, as /kill does.
Parameters
id
string
Returns
boolean
Whether it died.
legacyStates()?
optionallegacyStates(typeId):ScriptLegacyStates|undefined
Defined in: script-host/src/host/world.ts:1275
The states BDS's Script API reports for a block type beside the ones the world keeps, such as an oak log's old_log_type or a slab's top_slot_bit, or undefined for a world without them. A permutation a script reads carries them, and one a script writes may name them.
Parameters
typeId
string
Returns
ScriptLegacyStates | undefined
placeStructure()?
optionalplaceStructure(dimension,location,structure):void
Defined in: script-host/src/host/world.ts:1373
Places a GameTest's .mcstructure with its lowest corner at a location. A world that cannot read the format leaves the blocks there as they are.
Parameters
dimension
string
location
structure
Uint8Array
The file's bytes.
Returns
void
players()
players(): readonly
string[]
Defined in: script-host/src/host/world.ts:1208
The ids of the players in the world, in the order they joined.
Returns
readonly string[]
playSound()?
optionalplaySound(sound):void
Defined in: script-host/src/host/world.ts:1381
Plays a sound, as /playsound does. A world without it plays none.
Parameters
sound
Returns
void
redstonePower()?
optionalredstonePower(dimension,location):number|undefined
Defined in: script-host/src/host/world.ts:1507
The redstone power a loaded block holds, or undefined for a block that carries none.
Parameters
dimension
string
location
Returns
number | undefined
registerCommands()?
optionalregisterCommands(commands): () =>void
Defined in: script-host/src/host/world.ts:1486
Puts the custom commands the scripts registered into the world's command tree, after startup. A world without it has no custom commands.
Parameters
commands
Returns
A function that takes them out again, which a reload calls before it registers anew.
() => void
registerCustomDimension()?
optionalregisterCustomDimension(typeId):"registered"|"new-after-reload"
Defined in: script-host/src/host/world.ts:1200
Adds a void dimension a script registered in startup, which ScriptWorld.dimensions lists from then on. A dimension the world already has is registered again. A world that cannot add a dimension once its first scripts have started answers new-after-reload, as BDS does. Left out, the world takes every registration and adds no dimension.
Parameters
typeId
string
Returns
"registered" | "new-after-reload"
remove()
remove(
id):void
Defined in: script-host/src/host/world.ts:1236
Takes an entity out of the world without killing it, so it drops nothing.
Parameters
id
string
Returns
void
removeEffect()?
optionalremoveEffect(id,typeId):boolean
Defined in: script-host/src/host/world.ts:1407
Parameters
id
string
typeId
string
Returns
boolean
False when the entity has no such effect.
removeTag()
removeTag(
id,tag):boolean
Defined in: script-host/src/host/world.ts:1241
Parameters
id
string
tag
string
Returns
boolean
False when the entity does not have the tag.
resolveBlock()
resolveBlock(
typeId,states):ScriptBlockPermutation|undefined
Defined in: script-host/src/host/world.ts:1266
Completes a block permutation from its type and some of its states, each state left out taking its default.
Parameters
typeId
string
The type with its namespace.
states
Readonly<Record<string, string | number | boolean>>
Returns
ScriptBlockPermutation | undefined
Undefined for a type the world does not have, or a state the type does not have. A state value the type does not allow takes the state's default.
runCommand()
runCommand(
command,source):ScriptCommandResult
Defined in: script-host/src/host/world.ts:1285
Runs a command as source, to its end, and tells what it did.
Parameters
command
string
The command without its slash.
source
Returns
selectEntities()?
optionalselectEntities(selector,player): readonlystring[] |undefined
Defined in: script-host/src/host/world.ts:1293
The entities a target selector matches, read by the world's own selector grammar, for a template's selector node: @a, @a[tag=vip], @e[type=pig] or a player's name.
Parameters
selector
string
player
string | undefined
The entity the selector is read for, which @s and @p name, or undefined for the server.
Returns
readonly string[] | undefined
The matched entities' ids, or undefined for a selector that does not parse.
sendMessage()
sendMessage(
message,player?):void
Defined in: script-host/src/host/world.ts:1213
Puts a line of chat on the screen of every player in the world, or of one.
Parameters
message
string
player?
string
The id of the one player, as ScriptWorld.players lists it.
Returns
void
setAttribute()?
optionalsetAttribute(id,name,value):void
Defined in: script-host/src/host/world.ts:1462
Writes an attribute's value, within its bounds, and tells the clients that see it.
Parameters
id
string
name
string
value
number
Returns
void
setBlock()
setBlock(
dimension,location,permutation):void
Defined in: script-host/src/host/world.ts:1258
Sets one block through the world's setter, which tells clients and neighbors.
Parameters
dimension
string
location
permutation
Returns
void
setBlockInventoryItem()?
optionalsetBlockInventoryItem(dimension,location,slot,item):void
Defined in: script-host/src/host/world.ts:1414
Puts a stack into one slot of a block's container, or empties it.
Parameters
dimension
string
location
slot
number
item
ScriptItem | undefined
Returns
void
setDynamicProperties()
setDynamicProperties(
owner,pack,values):void
Defined in: script-host/src/host/world.ts:1345
Writes some of one pack's dynamic properties of the world or of a live entity through the world's setter: each value replaces the property's, and undefined deletes it.
Parameters
owner
pack
string
The pack's header UUID.
values
ReadonlyMap<string, ScriptPropertyValue | undefined>
Returns
void
setEquipment()?
optionalsetEquipment(id,slot,item):boolean
Defined in: script-host/src/host/world.ts:1454
Puts a stack into one equipment slot, or empties it, and tells the clients that see it.
Parameters
id
string
slot
item
ScriptItem | undefined
Returns
boolean
False when the slot cannot hold the stack, such as an apple on the chest.
setGameMode()?
optionalsetGameMode(id,gameMode):void
Defined in: script-host/src/host/world.ts:1375
Sets a player's game mode, as /gamemode does.
Parameters
id
string
gameMode
Returns
void
setInventoryItem()
setInventoryItem(
id,slot,item):void
Defined in: script-host/src/host/world.ts:1248
Puts a stack into one slot of an entity's inventory, or empties it.
Parameters
id
string
slot
number
item
ScriptItem | undefined
Returns
void
setNameTag()
setNameTag(
id,nameTag):void
Defined in: script-host/src/host/world.ts:1237
Parameters
id
string
nameTag
string
Returns
void
setSelectedSlot()?
optionalsetSelectedSlot(id,slot):void
Defined in: script-host/src/host/world.ts:1473
Moves a player's hand to a hotbar slot, from 0 to 8, and tells their client.
Parameters
id
string
slot
number
Returns
void
setSneaking()?
optionalsetSneaking(id,sneaking):void
Defined in: script-host/src/host/world.ts:1377
Makes an entity sneak or stand, and tells the clients that see it.
Parameters
id
string
sneaking
boolean
Returns
void
settleCustomDimensions()?
optionalsettleCustomDimensions(registered):void
Defined in: script-host/src/host/world.ts:1206
Called after each run's startup, the first and every reload's, with every dimension that run registered. The world may drop a dimension an earlier run registered that this one did not.
Parameters
registered
readonly string[]
Returns
void
setWaterlogged()?
optionalsetWaterlogged(dimension,location,waterlogged):void
Defined in: script-host/src/host/world.ts:1505
Puts water into a loaded block's liquid layer, or takes it out.
Parameters
dimension
string
location
waterlogged
boolean
Returns
void
setWeather()
setWeather(
dimension,weather,duration):void
Defined in: script-host/src/host/world.ts:1307
Changes a dimension's weather through the world's weather action: its guards run, and a change they let through is committed and taken as a weatherChange event later.
Parameters
dimension
string
weather
duration
number
How long, in ticks.
Returns
void
showTitle()?
optionalshowTitle(player,title):void
Defined in: script-host/src/host/world.ts:1379
Sends a player a title instruction, as /title does. A world without it shows no title.
Parameters
player
string
title
Returns
void
spawnEntity()
spawnEntity(
dimension,typeId,location):string
Defined in: script-host/src/host/world.ts:1227
Spawns an entity through the world's own spawn.
Parameters
dimension
string
typeId
string
The type with its namespace.
location
Returns
string
The new entity's id, unknown-type for a type the world has no definition of, or unloaded when the location's chunk is not loaded.
spawnParticle()?
optionalspawnParticle(dimension,effect,location,molangVariables?,player?):void
Defined in: script-host/src/host/world.ts:1387
Spawns a particle effect for the players near a location, as /particle does, or for one player.
Parameters
dimension
string
effect
string
location
molangVariables?
string
The JSON of the effect's MoLang variables, as SpawnParticleEffectPacket carries it.
player?
string
The id of the one player who sees it. Everyone near the location sees it when absent.
Returns
void
takeEvents()
takeEvents(): readonly
ScriptWorldEvent[]
Defined in: script-host/src/host/world.ts:1321
The changes the world committed since the last call, in the order it committed them.
Returns
readonly ScriptWorldEvent[]
teleport()
teleport(
id,dimension,location):void
Defined in: script-host/src/host/world.ts:1229
Moves an entity to a location of a dimension, as /teleport does.
Parameters
id
string
dimension
string
location
Returns
void
transferPlayer()?
optionaltransferPlayer(id,target):void
Defined in: script-host/src/host/world.ts:1359
Sends a player to another server, as /transfer does. A world without it transfers no one.
Parameters
id
string
target
Returns
void
watchPlayerLeave()
watchPlayerLeave(
listener): () =>void
Defined in: script-host/src/host/world.ts:1299
Calls listener with a player's id while they leave, before their entity goes, for world.beforeEvents.playerLeave.
Parameters
listener
(player) => void
Returns
A function that stops it.
() => void
waterlogged()?
optionalwaterlogged(dimension,location):boolean|undefined
Defined in: script-host/src/host/world.ts:1503
Whether a loaded block holds water in its liquid layer.
Parameters
dimension
string
location
Returns
boolean | undefined
weather()
weather(
dimension):ScriptWeather
Defined in: script-host/src/host/world.ts:1301
The weather of a dimension now.
Parameters
dimension
string
Returns
VetoVerdict
Defined in: script-host/src/host/world.ts:45
What a guard of an action no script may change decides: veto it, or let it go on as it is.
Properties
intent?
readonlyoptionalintent?:undefined
Defined in: script-host/src/host/world.ts:48
A guard that can only veto hands back no intent.
veto
readonlyveto:boolean
Defined in: script-host/src/host/world.ts:46
WeatherChangeIntent
Defined in: script-host/src/host/world.ts:20
A weather change a script's before-event sees before the world commits it.
Properties
dimension
readonlydimension:string
Defined in: script-host/src/host/world.ts:22
The dimension, as Bedrock names it, such as minecraft:overworld.
duration
readonlyduration:number
Defined in: script-host/src/host/world.ts:26
How long the new weather lasts, in ticks.
newWeather
readonlynewWeather:ScriptWeather
Defined in: script-host/src/host/world.ts:24
previousWeather
readonlypreviousWeather:ScriptWeather
Defined in: script-host/src/host/world.ts:23
Type Aliases
DataDrivenCloseReason
DataDrivenCloseReason =
"programmaticclose"|"programmaticcloseall"|"clientcanceled"|"userbusy"|"invalidform"
Defined in: script-host/src/host/world.ts:683
Why a client says a data-driven screen closed, as ServerboundDataDrivenScreenClosedPacket spells it.
DataDrivenLeaf
DataDrivenLeaf =
boolean|number|string
Defined in: script-host/src/host/world.ts:657
A value one path of a data store property can take, which a client's write carries too.
DataDrivenResponse
DataDrivenResponse = {
path:string;player:string;property:string;value:DataDrivenLeaf; } | {formId:number;player:string;reason:DataDrivenCloseReason; }
Defined in: script-host/src/host/world.ts:690
What a client sends about a data-driven screen: a write to one path of its property, which is a click when the path is a button's onClick, or the screen closing with a reason.
Union Members
Type Literal
{ path: string; player: string; property: string; value: DataDrivenLeaf; }
path
readonlypath:string
player
readonlyplayer:string
The id of the player who wrote, as ScriptWorld.players lists it.
property
readonlyproperty:string
The data store property written to.
value
readonlyvalue:DataDrivenLeaf
Type Literal
{ formId: number; player: string; reason: DataDrivenCloseReason; }
formId
readonlyformId:number
The id the screen was shown with.
player
readonlyplayer:string
The id of the player whose screen closed, as ScriptWorld.players lists it.
reason
readonlyreason:DataDrivenCloseReason
DataDrivenValue
DataDrivenValue =
null|boolean|number|bigint|string| readonlyDataDrivenValue[] |DataDrivenRecord
Defined in: script-host/src/host/world.ts:649
A value in a data-driven screen's data store property. A record is a map and an array a list; a bigint is a count BDS sends as an int64, such as a layout's length, and every other number travels as a double. Null is a property with no value.
Guard
Guard<
Intent> = (intent) =>GuardVerdict<Intent>
Defined in: script-host/src/host/world.ts:42
A guard in an action's guard stage. It reads the intent and writes nothing.
Type Parameters
Intent
Intent
Parameters
intent
Intent
Returns
GuardVerdict<Intent>
GuardVerdict
GuardVerdict<
Intent> = {veto:true; } | {intent:Intent;veto:false; }
Defined in: script-host/src/host/world.ts:39
What a guard decides: let the action go on, with the intent it may have replaced, or veto it.
Type Parameters
Intent
Intent
ScriptBlockHook
ScriptBlockHook =
ScriptBlockHookEvent["hook"]
Defined in: script-host/src/host/world.ts:1117
The block hooks a custom component can have, as ScriptBlockHookEvent names them.
ScriptBlockHookEvent
ScriptBlockHookEvent =
object& ({hook:"onPlace";previousBlock:ScriptBlockPermutation; } | {brokenBlockPermutation:ScriptBlockPermutation;entitySource?:ScriptEntityRef;hook:"onBreak"; } | {brokenBlockPermutation:ScriptBlockPermutation;hook:"onPlayerBreak";player?:ScriptEntityRef; } | {face:ScriptDirection;faceLocation?:ScriptVector3;hook:"onPlayerInteract";player?:ScriptEntityRef; } | {face:ScriptDirection;hook:"beforeOnPlayerPlace";permutationToPlace:ScriptBlockPermutation;player?:ScriptEntityRef; } | {hook:"onTick"|"onRandomTick"; } | {entity?:ScriptEntityRef;hook:"onStepOn"; } | {entity?:ScriptEntityRef;fallDistance:number;hook:"onEntityFallOn"; } | {blockPermutation:ScriptBlockPermutation;entitySource?:ScriptEntityRef;hook:"onEntity";name:string; } | {firstUpdate:boolean;hook:"onRedstoneUpdate";powerLevel:number;previousPowerLevel:number; } | {hook:"onBlockStateChange";previousPermutation:ScriptBlockPermutation; })
Defined in: script-host/src/host/world.ts:1042
A block hook the world raises for the custom components a block names.
Type Declaration
block
readonlyblock:ScriptBlockLocation
components
readonlycomponents: readonlyScriptComponentUse[]
ScriptBookPage
ScriptBookPage = {
text:string; } | {raw:string; }
Defined in: script-host/src/host/world.ts:148
One page of a book: its text, or the JSON of the RawMessage a script wrote on it.
ScriptCommandArgument
ScriptCommandArgument =
string|number|boolean| {kind:"location";location:ScriptVector3; } | {entities: readonlyScriptEntityRef[];kind:"entities"; } | {id:string;kind:"entityType"|"itemType"|"blockType"; }
Defined in: script-host/src/host/world.ts:983
One argument of a custom command as the world parsed it: a string for String and Enum, a number for Integer and Float, a boolean, or the location, entities or type the others name.
ScriptCommandParamType
ScriptCommandParamType =
"BlockType"|"Boolean"|"EntitySelector"|"EntityType"|"Enum"|"Float"|"Integer"|"ItemType"|"Location"|"PlayerSelector"|"String"
Defined in: script-host/src/host/world.ts:933
A custom command's parameter type, as CustomCommandParamType names it.
ScriptCommandResult
ScriptCommandResult = {
successCount:number; } | {error:string; }
Defined in: script-host/src/host/world.ts:509
What a command a script ran did: how many times it succeeded, or why it failed.
ScriptCommandSource
ScriptCommandSource = {
dimension:string; } | {entity:string; }
Defined in: script-host/src/host/world.ts:512
Who a script's command runs as: a dimension, as the server does, or an entity, as @s.
ScriptDebugShapeKind
ScriptDebugShapeKind =
"DebugArrow"|"DebugBox"|"DebugCircle"|"DebugCone"|"DebugCylinder"|"DebugEllipsoid"|"DebugLine"|"DebugPyramid"|"DebugSphere"|"DebugText"
Defined in: script-host/src/host/world.ts:781
The classes of @minecraft/debug-utilities' shapes, by the name the Script API gives each.
ScriptDirection
ScriptDirection =
"Down"|"East"|"North"|"South"|"Up"|"West"
Defined in: script-host/src/host/world.ts:1020
A face of a block, as the Script API's Direction names it.
ScriptDisplaySlot
ScriptDisplaySlot =
"BelowName"|"List"|"Sidebar"
Defined in: script-host/src/host/world.ts:321
A display slot, as DisplaySlotId names it.
ScriptEquipmentSlot
ScriptEquipmentSlot =
"Body"|"Chest"|"Feet"|"Head"|"Legs"|"Mainhand"|"Offhand"
Defined in: script-host/src/host/world.ts:435
An equipment slot, as EquipmentSlot names it.
ScriptEventSourceType
ScriptEventSourceType =
"Block"|"Entity"|"NPCDialogue"|"Server"
Defined in: script-host/src/host/world.ts:528
How a script's /scriptevent was sent, as ScriptEventSource names it.
ScriptEventValue
ScriptEventValue =
string|number|boolean| {entity:ScriptEntityRef; } | {entities: readonlyScriptEntityRef[]; } | {block:ScriptBlockLocation; } | {blocks: readonlyScriptBlockLocation[]; } | {permutation:ScriptBlockPermutation; } | {item:ScriptItem; } | {items: readonlyScriptItem[]; } | {dimension:string; } | {vector:ScriptVector3; } | {damageSource:ScriptDamageSource; } | {effect:ScriptEffect;holder:string; } | {json:string; } | {at:ScriptBlockLocation;blockComponent:string; }
Defined in: script-host/src/host/world.ts:594
A value an event of world.afterEvents or world.beforeEvents carries, as one of its members reads it: a string, number or boolean as it is, or a wrapper naming what the member makes of it.
Union Members
string
number
boolean
Type Literal
{ entity: ScriptEntityRef; }
Type Literal
{ entities: readonly ScriptEntityRef[]; }
Type Literal
{ block: ScriptBlockLocation; }
Type Literal
{ blocks: readonly ScriptBlockLocation[]; }
Type Literal
{ permutation: ScriptBlockPermutation; }
Type Literal
{ item: ScriptItem; }
Type Literal
{ items: readonly ScriptItem[]; }
Type Literal
{ dimension: string; }
Type Literal
{ vector: ScriptVector3; }
Type Literal
{ damageSource: ScriptDamageSource; }
Type Literal
{ effect: ScriptEffect; holder: string; }
A status effect, and the id of the entity it is on.
Type Literal
{ json: string; }
Plain data, such as a NeighborChange list, as JSON.
Type Literal
{ at: ScriptBlockLocation; blockComponent: string; }
A block's component, by its class, such as BlockPistonComponent, whose object names the block.
ScriptGameEventGuard
ScriptGameEventGuard = (
event) =>ScriptGameEventVerdict
Defined in: script-host/src/host/world.ts:630
A guard of the actions whose before-events ScriptGameEvent describes.
Parameters
event
Returns
ScriptGameEventVerdict
ScriptGameEventVerdict = {
veto:true; } | {fields:Readonly<Record<string,ScriptEventValue>>;veto:false; }
Defined in: script-host/src/host/world.ts:626
What the scripts decide of a before-event: veto it, or let it go on with the fields they may have changed.
ScriptGameMode
ScriptGameMode =
"Adventure"|"Creative"|"Spectator"|"Survival"
Defined in: script-host/src/host/world.ts:876
A game mode as the Script API's GameMode names it.
ScriptHttpMethod
ScriptHttpMethod =
"Delete"|"Get"|"Head"|"Patch"|"Post"|"Put"
Defined in: script-host/src/host/world.ts:729
An HTTP method, as @minecraft/server-net's HttpRequestMethod names it.
ScriptHttpResult
ScriptHttpResult = {
body:string;headers: readonly (readonly [string,string])[];id:number;status:number; } | {errorCode:number;id:number; }
Defined in: script-host/src/host/world.ts:748
How one request ended: the response the server sent, or the error that ended it, by the code BDS's HTTP client reports, such as 111 for a refused connection.
Union Members
Type Literal
{ body: string; headers: readonly (readonly [string, string])[]; id: number; status: number; }
body
readonlybody:string
headers
readonlyheaders: readonly (readonly [string,string])[]
The response headers in the order they arrived, each name in lower case.
id
readonlyid:number
status
readonlystatus:number
Type Literal
{ errorCode: number; id: number; }
ScriptItemHook
ScriptItemHook =
ScriptItemHookEvent["hook"]
Defined in: script-host/src/host/world.ts:1120
The item hooks a custom component can have, as ScriptItemHookEvent names them.
ScriptItemHookEvent
ScriptItemHookEvent =
object& ({hook:"onUse"|"onCompleteUse"|"onConsume"; } | {block:ScriptBlockLocation;blockFace:ScriptDirection;faceLocation:ScriptVector3;hook:"onUseOn";usedOnBlockPermutation:ScriptBlockPermutation; } | {hadEffect:boolean;hitEntity:ScriptEntityRef;hook:"onHitEntity"; } | {block:ScriptBlockLocation;hook:"onMineBlock";minedBlockPermutation:ScriptBlockPermutation; })
Defined in: script-host/src/host/world.ts:1093
An item hook the world raises for the custom components an item names.
Type Declaration
components
readonlycomponents: readonlyScriptComponentUse[]
item
readonlyitem:ScriptItem
The stack the hook is about, as it was when the world raised it.
source
readonlysource:ScriptEntityRef
The entity using the item.
ScriptParticipantRef
ScriptParticipantRef = {
name:string; } | {entity:string; } | {participant:number; }
Defined in: script-host/src/host/world.ts:311
Who a scoreboard call names: a fake player by name, an entity by id, or a participant by its id.
ScriptParticipantType
ScriptParticipantType =
"Entity"|"FakePlayer"|"Player"
Defined in: script-host/src/host/world.ts:297
How a scoreboard participant is known, as ScoreboardIdentityType names it.
ScriptProperties
ScriptProperties =
ReadonlyMap<string,ScriptPropertyValue>
Defined in: script-host/src/host/world.ts:97
One pack's dynamic properties of one owner, by id, in the order they were first set.
ScriptPropertyOwner
ScriptPropertyOwner =
"world"| {entity:string; }
Defined in: script-host/src/host/world.ts:100
Whose dynamic properties a script reads or writes: the world's, or an entity's by its id.
ScriptPropertyValue
ScriptPropertyValue =
number|boolean|string|ScriptVector3
Defined in: script-host/src/host/world.ts:94
A dynamic property's value as BDS keeps it: a number, which is a double, a boolean, a string, or a vector whose parts are 32-bit floats.
ScriptSpawnCause
ScriptSpawnCause =
"Born"|"Event"|"Loaded"|"Spawned"|"Transformed"
Defined in: script-host/src/host/world.ts:515
Why an entity appeared, as EntityInitializationCause names it.
ScriptStateValue
ScriptStateValue =
string|number|boolean
Defined in: script-host/src/host/world.ts:165
A block state's value.
ScriptStructureSaveMode
ScriptStructureSaveMode =
"Memory"|"World"
Defined in: script-host/src/host/world.ts:457
How a structure is kept, as StructureSaveMode names it.
ScriptTitle
ScriptTitle = {
kind:"title"|"subtitle"|"actionbar";text:string; } | {kind:"clear"|"reset"; } | {fadeIn:number;fadeOut:number;kind:"times";stay:number; }
Defined in: script-host/src/host/world.ts:393
One title instruction, as /title sends it to a player.
Union Members
Type Literal
{ kind: "title" | "subtitle" | "actionbar"; text: string; }
Type Literal
{ kind: "clear" | "reset"; }
Type Literal
{ fadeIn: number; fadeOut: number; kind: "times"; stay: number; }
fadeIn
readonlyfadeIn:number
Ticks the title takes to appear.
fadeOut
readonlyfadeOut:number
Ticks the title takes to go.
kind
readonlykind:"times"
stay
readonlystay:number
Ticks the title stays.
ScriptTransferTarget
ScriptTransferTarget = {
hostname:string;port:number; } | {netherNetId:string; }
Defined in: script-host/src/host/world.ts:777
Where @minecraft/server-admin's transferPlayer sends a player.
ScriptWeather
ScriptWeather =
"Clear"|"Rain"|"Thunder"
Defined in: script-host/src/host/world.ts:17
The weather as the Script API's WeatherType names it.
ScriptWorldEvent
ScriptWorldEvent =
object&Omit<WeatherChangeIntent,"duration"> | {playerId:string;playerName:string;type:"playerJoin"; } | {initialSpawn:boolean;playerId:string;type:"playerSpawn"; } | {playerId:string;playerName:string;type:"playerLeave"; } | {message:string;sender:string;type:"chatSend"; } | {id:string;message:string;sourceEntity?:string;sourceType:ScriptEventSourceType;type:"scriptEvent"; } | {cause:ScriptSpawnCause;entity:ScriptEntityRef;type:"entitySpawn"; } | {damage:number;entity:ScriptEntityRef;source:ScriptDamageSource;type:"entityHurt"; } | {entity:ScriptEntityRef;source:ScriptDamageSource;type:"entityDie"; } | {block:ScriptBlockLocation;brokenBlockPermutation:ScriptBlockPermutation;itemAfter?:ScriptItem;itemBefore?:ScriptItem;player:string;type:"playerBreakBlock"; } | {item:ScriptItem;player:string;type:"itemUse"; } |object&BlockInteractIntent|object&EntityInteractIntent|object&ScriptGameEvent
Defined in: script-host/src/host/world.ts:531
A change the world committed, for an after-event.
Union Members
object & Omit<WeatherChangeIntent, "duration">
Type Literal
{ playerId: string; playerName: string; type: "playerJoin"; }
A player joined and their client finished loading into the world.
Type Literal
{ initialSpawn: boolean; playerId: string; type: "playerSpawn"; }
A player appeared in the world, on joining or on respawning.
Type Literal
{ playerId: string; playerName: string; type: "playerLeave"; }
A player left; their entity is already gone.
Type Literal
{ message: string; sender: string; type: "chatSend"; }
A player's chat line went past the guards, and the players it reaches got it.
Type Literal
{ id: string; message: string; sourceEntity?: string; sourceType: ScriptEventSourceType; type: "scriptEvent"; }
A /scriptevent ran.
id
readonlyid:string
message
readonlymessage:string
sourceEntity?
readonlyoptionalsourceEntity?:string
The entity that ran it, when an entity did.
sourceType
readonlysourceType:ScriptEventSourceType
type
readonlytype:"scriptEvent"
Type Literal
{ cause: ScriptSpawnCause; entity: ScriptEntityRef; type: "entitySpawn"; }
An entity appeared in the world.
Type Literal
{ damage: number; entity: ScriptEntityRef; source: ScriptDamageSource; type: "entityHurt"; }
A blow took health off an entity.
damage
readonlydamage:number
The health the blow took.
entity
readonlyentity:ScriptEntityRef
source
readonlysource:ScriptDamageSource
type
readonlytype:"entityHurt"
Type Literal
{ entity: ScriptEntityRef; source: ScriptDamageSource; type: "entityDie"; }
An entity died.
Type Literal
{ block: ScriptBlockLocation; brokenBlockPermutation: ScriptBlockPermutation; itemAfter?: ScriptItem; itemBefore?: ScriptItem; player: string; type: "playerBreakBlock"; }
A player broke a block.
block
readonlyblock:ScriptBlockLocation
brokenBlockPermutation
readonlybrokenBlockPermutation:ScriptBlockPermutation
itemAfter?
readonlyoptionalitemAfter?:ScriptItem
The stack in the player's hand after the break. Absent for an empty hand.
itemBefore?
readonlyoptionalitemBefore?:ScriptItem
The stack in the player's hand before the break. Absent for an empty hand.
player
readonlyplayer:string
type
readonlytype:"playerBreakBlock"
Type Literal
{ item: ScriptItem; player: string; type: "itemUse"; }
A player used an item that the before-event let through.
object & BlockInteractIntent
A player's click on a block went past the before-event and did something.
object & EntityInteractIntent
A player's click on an entity went past the before-event and did something.
object & ScriptGameEvent
One of the other events of world.afterEvents, which ScriptGameEvent describes.
SimulatedPlayerAction
SimulatedPlayerAction = {
kind:"chat";message:string; } | {kind:"jump"; } | {kind:"move";relative:boolean;speed:number;x:number;z:number; } | {kind:"stopMoving"; } | {kind:"lookAt";location:ScriptVector3; } | {kind:"attack"; } | {entity:string;kind:"attackEntity"; } | {item:ScriptItem;kind:"useItem"; } | {kind:"breakBlock";location:ScriptVector3; }
Defined in: script-host/src/host/world.ts:882
What a script tells a GameTest simulated player to do. Each is what a client's input would do for a real player, and a move or a look lasts until another replaces it.
Union Members
Type Literal
{ kind: "chat"; message: string; }
Types a line of chat, which goes past the chat guards as a client's line does.
Type Literal
{ kind: "jump"; }
Jumps, when the player stands on the ground.
Type Literal
{ kind: "move"; relative: boolean; speed: number; x: number; z: number; }
Walks in a direction until told to stop: x toward the east and z toward the south, or, when relative, x to the player's left and z forward from where they face.
Type Literal
{ kind: "stopMoving"; }
Type Literal
{ kind: "lookAt"; location: ScriptVector3; }
Turns the player's head and body to face a location.
Type Literal
{ kind: "attack"; }
Swings at the entity the player faces within reach.
Type Literal
{ entity: string; kind: "attackEntity"; }
Swings at one entity, when it is within reach.
Type Literal
{ item: ScriptItem; kind: "useItem"; }
Uses an item in the air, as a client's right click does.
Type Literal
{ kind: "breakBlock"; location: ScriptVector3; }
Breaks a block, through the guards a client's break goes through, retrying each tick while one vetoes it.
VetoGuard
VetoGuard<
Intent> = (intent) =>VetoVerdict
Defined in: script-host/src/host/world.ts:52
A guard that can veto an action but not change it.
Type Parameters
Intent
Intent
Parameters
intent
Intent
Returns
Functions
shapeVisibleTo()
shapeVisibleTo(
shape,player):boolean
Defined in: script-host/src/host/world.ts:859
Whether a player sees a debug shape, as its visibleTo, hiddenFrom and defaultVisibleToAll say.
Parameters
shape
player
string
Returns
boolean