Skip to content

API reference / @jsprismarine/prismarine / scripting/scriptComponents

scripting/scriptComponents ​

Classes ​

Interfaces ​

BoundScriptLevel ​

Defined in: packages/prismarine/src/scripting/scriptComponents.ts:122

One level's scripts, which the bridge sends that level's hooks to.

Properties ​

isDefault ​

readonly isDefault: boolean

Defined in: packages/prismarine/src/scripting/scriptComponents.ts:126

Whether it is the default level, which a hook that names no level is in.

name ​

readonly name: string

Defined in: packages/prismarine/src/scripting/scriptComponents.ts:124

The level's name, as a hook's block names it.

ownsEntity ​

readonly ownsEntity: (runtimeId) => boolean

Defined in: packages/prismarine/src/scripting/scriptComponents.ts:128

Whether an entity is in the level, by runtime id: an item hook goes to its user's level.

Parameters ​
runtimeId ​

string

Returns ​

boolean

scheduler? ​

readonly optional scheduler?: TickScheduler

Defined in: packages/prismarine/src/scripting/scriptComponents.ts:130

How a block with minecraft:tick in the level schedules its ticks.


ScriptComponentType ​

Defined in: packages/prismarine/src/scripting/scriptComponents.ts:55

What a type that names custom components carries: the components, and its tick when it has one.

Properties ​

tick? ​

readonly optional tick?: TickInterval

Defined in: packages/prismarine/src/scripting/scriptComponents.ts:57

uses ​

readonly uses: readonly ScriptComponentUse[]

Defined in: packages/prismarine/src/scripting/scriptComponents.ts:56


TickInterval ​

Defined in: packages/prismarine/src/scripting/scriptComponents.ts:48

When a block with minecraft:tick ticks: its interval, in ticks, and whether it keeps ticking.

Properties ​

looping ​

readonly looping: boolean

Defined in: packages/prismarine/src/scripting/scriptComponents.ts:51

max ​

readonly max: number

Defined in: packages/prismarine/src/scripting/scriptComponents.ts:50

min ​

readonly min: number

Defined in: packages/prismarine/src/scripting/scriptComponents.ts:49

Type Aliases ​

TickScheduler ​

TickScheduler = (block, min, max) => void

Defined in: packages/prismarine/src/scripting/scriptComponents.ts:119

Schedules a block's next tick somewhere from min to max ticks away, which the server does through its own scheduled ticks and random, so a replay ticks the block on the same ticks.

Parameters ​

block ​

ScriptBlockLocation

min ​

number

max ​

number

Returns ​

void

Variables ​

SCRIPT_COMPONENTS_BEHAVIOR ​

const SCRIPT_COMPONENTS_BEHAVIOR: "jsprismarine:script_components" = 'jsprismarine:script_components'

Defined in: packages/prismarine/src/scripting/scriptComponents.ts:33

The behavior name the adapter registers under in both registries.

Functions ​

registerScriptComponentBehaviors() ​

registerScriptComponentBehaviors(registries, bridge): void

Defined in: packages/prismarine/src/scripting/scriptComponents.ts:256

Registers the adapter behavior in both registries, before the content resolves.

Parameters ​

registries ​
blocks ​

BehaviorRegistry<BlockHooks>

items ​

BehaviorRegistry<ItemHooks>

bridge ​

ScriptComponentBridge

Returns ​

void


scriptComponentType() ​

scriptComponentType(definition, root): ScriptComponentType | undefined

Defined in: packages/prismarine/src/scripting/scriptComponents.ts:85

Reads the custom components a block or item definition names, and its tick.

A block's permutations add theirs to its own, so a component one permutation names runs for every state of the block.

Parameters ​

definition ​

Definition

root ​

string

The definition's top-level key, minecraft:block or minecraft:item.

Returns ​

ScriptComponentType | undefined

Undefined for a definition that names none.