API reference / @jsprismarine/prismarine / command/function/runtime / FunctionRuntime
Class: FunctionRuntime
Defined in: packages/prismarine/src/command/function/runtime.ts:82
Runs functions, and remembers the ones /schedule put off until later.
Built once per content build, because the compiled functions it runs are. A reload replaces it rather than mutating it, which also drops whatever was scheduled against the functions that no longer exist.
Constructors
Constructor
new FunctionRuntime(
options):FunctionRuntime
Defined in: packages/prismarine/src/command/function/runtime.ts:104
Parameters
options
Returns
FunctionRuntime
Accessors
queued
Get Signature
get queued():
number
Defined in: packages/prismarine/src/command/function/runtime.ts:225
How many calls are waiting on the schedule.
Returns
number
size
Get Signature
get size():
number
Defined in: packages/prismarine/src/command/function/runtime.ts:134
How many functions the stack registered.
Returns
number
Methods
clearQueue()
clearQueue(
reference):number
Defined in: packages/prismarine/src/command/function/runtime.ts:220
Drops every pending call of one reference.
Parameters
reference
string
Returns
number
How many were dropped.
has()
has(
reference):boolean
Defined in: packages/prismarine/src/command/function/runtime.ts:149
Whether a reference names something that exists: a function, or a declared tag.
Parameters
reference
string
Returns
boolean
ids()
ids(): readonly
string[]
Defined in: packages/prismarine/src/command/function/runtime.ts:139
Every function id the stack registered.
Returns
readonly string[]
queue()
queue(
reference,delayTicks,mode):boolean
Defined in: packages/prismarine/src/command/function/runtime.ts:210
Queues a function for later.
Parameters
reference
string
delayTicks
number
mode
Returns
boolean
True always, matching Java: a /schedule of a function that does not exist yet is legal, because a later pack reload may provide it before the call comes due.
requestReturn()
requestReturn(
value):number
Defined in: packages/prismarine/src/command/function/runtime.ts:240
Records a /return, which ends the function the running line belongs to.
Parameters
value
number | undefined
What the function returns, or undefined for the two forms that end it without a value.
Returns
number
What the /return line itself reports.
Throws
When no function is running. Java refuses a /return typed at a console the same way, and the dispatcher turns this into the message the sender sees.
run()
run(
reference,source,argumentText?,stored?):FunctionRunOutcome
Defined in: packages/prismarine/src/command/function/runtime.ts:167
Runs one function or one function tag.
Parameters
reference
string
A function id, or a tag written #namespace:tag.
source
What /function was typed with. Every line runs with it made silent, as Java runs a function's output.
argumentText?
string
The macro argument compound, as SNBT.
stored?
boolean = false
Whether the compound is a stored one printed back, as /function … with passes it, so a printed non-finite number reads back as one.
Returns
What /function reports and whether execute if function matches. A function that does not exist ran nothing and matched nothing.
runLoad()
runLoad(
source):number
Defined in: packages/prismarine/src/command/function/runtime.ts:252
Runs #minecraft:load, which a server does once after its packs load.
Parameters
source
Returns
number
How many command lines ran.
tagIds()
tagIds(): readonly
string[]
Defined in: packages/prismarine/src/command/function/runtime.ts:144
Every function tag id the stack declares.
Returns
readonly string[]
tick()
tick(
source):number
Defined in: packages/prismarine/src/command/function/runtime.ts:267
One server tick: whatever /schedule put on this tick, then #minecraft:tick.
Schedules first, which is Java's order. Both are skipped outright when nothing is waiting and no pack declared the tag, so a server with no datapack pays a map lookup per tick and nothing else.
Parameters
source
Returns
number
How many command lines ran across everything this tick.