API reference / @jsprismarine/prismarine / scripting/LevelScriptWorld
scripting/LevelScriptWorld
Classes
Interfaces
ScriptWorldPlayer
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:141
A player of the level, as the scripts reach one.
Properties
id
readonlyid:string
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:143
The player's entity id, as the Script API writes it.
name?
readonlyoptionalname?:string
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:145
The player's name.
screens?
readonlyoptionalscreens?:Pick<DataDrivenScreens,"close"|"show"|"update">
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:156
The player's data-driven @minecraft/server-ui screens, as DataDrivenScreens sends them. A player without them is shown none, and show() settles as UserBusy.
spawned?
readonlyoptionalspawned?:boolean
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:166
Whether the player's entity is in the level yet. A player who joined is told to the scripts at once, and their first playerSpawn waits for this, since a script reads the player through the entity. A player without it counts as spawned.
Methods
closeForms()?
optionalcloseForms():void
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:151
Closes every form the player has open, as a ClientboundCloseFormPacket.
Returns
void
drawDebugShapes()?
optionaldrawDebugShapes(changes):void
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:160
Draws, redraws or removes debug shapes, as a PrimitiveShapesPacket. A player without it sees none.
Parameters
changes
readonly ScriptDebugShapeChange[]
Returns
void
sendMessage()
sendMessage(
message):void
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:147
Puts a line of chat on the player's screen.
Parameters
message
string
Returns
void
showForm()?
optionalshowForm(formId,json):void
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:149
Sends the player a form, as a ModalFormRequestPacket. A player without it is sent none.
Parameters
formId
number
json
string
Returns
void
transfer()?
optionaltransfer(target):void
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:158
Sends the player to another server, as a TransferPacket. A player without it stays.
Parameters
target
Returns
void
ScriptWorldSources
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:170
What LevelScriptWorld reads of its level.
Properties
access?
readonlyoptionalaccess?:ScriptLevelAccess
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:198
The level's entities, blocks, items and commands. NO_LEVEL_ACCESS when absent.
chat
readonlychat:Pick<ChatManager,"addGuard"> &Partial<Pick<ChatManager,"onSent">>
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:188
The server's chat, whose guard stage a player's line goes past, and which tells who listens of each line that went out.
entitySystems?
readonlyoptionalentitySystems?:ScriptEntitySystems
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:209
The level's entity and player systems, which the entity members reach.
http?
readonlyoptionalhttp?:ScriptHttpChannel
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:207
The channel the scripts' HTTP requests travel over. Without one, each request fails.
packDirectories?
readonlyoptionalpackDirectories?: readonlystring[]
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:203
The level's behavior packs, whose structures/ the structure manager reads. The level has no pack structures when absent.
playerActions?
readonlyoptionalplayerActions?:ScriptPlayerActions
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:232
The item use and block breaking of the level's players. Without them, the scripts see neither.
warn?
readonlyoptionalwarn?: (message) =>void
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:205
Where the level reports a pack file it cannot read, such as a broken structure.
Parameters
message
string
Returns
void
weather
readonlyweather:WorldWeather
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:183
The level's weather.
worldEvents?
readonlyoptionalworldEvents?:ScriptWorldEvents
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:234
The other world events of the level, which scripting/events raises. Without them, the scripts see none.
Methods
clock()
clock():
number
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:190
The wall clock the input step admitted for the current tick, in milliseconds since the epoch.
Returns
number
commands()?
optionalcommands(commands): () =>void
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:219
Puts the scripts' custom commands into the server's command tree.
Parameters
commands
Returns
A function that takes them out.
() => void
components()?
optionalcomponents(sink): () =>void
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:224
Sends the custom component hooks of the level's blocks and items to sink.
Parameters
sink
Returns
A function that stops it.
() => void
dimensions()
dimensions(): readonly
string[]
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:172
The level's dimensions, as Bedrock names them, in stem order.
Returns
readonly string[]
entityEvents()?
optionalentityEvents(listener): () =>void
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:230
Calls listener with each entity that appears in the level, each blow that lands and each death, once the world has kept it.
Parameters
listener
(event) => void
Returns
A function that stops it.
() => void
jobSlice()?
optionaljobSlice():object
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:196
How long a tick should take and how long the last one took, as the input step admitted them, which size the time the scripts' jobs get this tick. Without it, jobs get a fixed number of steps.
Returns
object
lastTickMs
readonlylastTickMs:number
periodMs
readonlyperiodMs:number
onPlayerLeaving()?
optionalonPlayerLeaving(listener): () =>void
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:214
Calls listener with a player's id as they leave, before their entity goes.
Parameters
listener
(player) => void
Returns
A function that stops it.
() => void
players()
players(): readonly
ScriptWorldPlayer[]
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:181
The players in the level, in the order they joined.
Returns
readonly ScriptWorldPlayer[]
registerCustomDimension()?
optionalregisterCustomDimension(typeId):"registered"|"new-after-reload"
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:177
Adds a void dimension a script registered in startup; see ScriptWorld.registerCustomDimension. Left out, the level takes no new dimension.
Parameters
typeId
string
Returns
"registered" | "new-after-reload"
settleCustomDimensions()?
optionalsettleCustomDimensions(registered):void
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:179
Ends a run's registrations; see ScriptWorld.settleCustomDimensions.
Parameters
registered
readonly string[]
Returns
void
Type Aliases
ScriptLevelAccess
ScriptLevelAccess =
Pick<ScriptWorld,"entity"|"entities"|"spawnEntity"|"teleport"|"kill"|"remove"|"setNameTag"|"addTag"|"removeTag"|"inventory"|"setInventoryItem"|"heightRange"|"block"|"setBlock"|"resolveBlock"|"itemType"|"runCommand"|"selectEntities"|"simulatedPlayers"|"placeStructure"|"setGameMode"|"setSelectedSlot"|"applyDamage"|"setSneaking"|"showTitle"|"playSound"|"spawnParticle"|"isEffectType"|"effects"|"addEffect"|"removeEffect"|"blockInventory"|"setBlockInventoryItem"|"equipment"|"setEquipment"|"attribute"|"setAttribute"|"effectTypes"|"dimensionTypes"|"dynamicProperties"|"setDynamicProperties"|"clearDynamicProperties"|"scoreboard"|"catalog"|"blockLight"|"waterlogged"|"setWaterlogged"|"worldSystem">
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:55
What the scripts read and write of a level's entities, blocks, items and commands.
Variables
NO_LEVEL_ACCESS
constNO_LEVEL_ACCESS:ScriptLevelAccess
Defined in: packages/prismarine/src/scripting/LevelScriptWorld.ts:108
A level the scripts reach nothing of: no entities, no loaded blocks, no types and no commands.