Skip to content

API reference / @jsprismarine/mcfunction / FunctionExecutor

Class: FunctionExecutor<TSource> ​

Defined in: executor.ts:160

Runs functions against a command runner.

One executor is reusable: it holds no run state, so a server builds it once at load and calls FunctionExecutor.runTick every tick.

function <id> and function #tag are the only lines the executor reads itself, because a call is control flow rather than a command: handling it here is what keeps nesting on the queue instead of on the JavaScript stack. Every other line goes to the runner untouched.

/return is the other half of that split. It is a command, so the runner implements it, but only the executor can act on it: a runner that reports CommandOutcome.returned ends the function the line came from and the loop carries on with its caller.

Type Parameters ​

TSource ​

TSource = unknown

Constructors ​

Constructor ​

new FunctionExecutor<TSource>(options): FunctionExecutor<TSource>

Defined in: executor.ts:165

Parameters ​

options ​

FunctionExecutorOptions<TSource>

Returns ​

FunctionExecutor<TSource>

Methods ​

run() ​

run(reference, options): ExecutionReport

Defined in: executor.ts:190

Runs one function or every function in one tag.

Everything a call reaches shares one budget, so the report covers the whole tree below the entry point. A limit stops the run and is reported as a diagnostic; nothing here throws, and a command that throws is reported and skipped.

Parameters ​

reference ​

string

A function id, or a tag id written #namespace:tag.

options ​

ExecutionOptions<TSource>

Returns ​

ExecutionReport


runLoad() ​

runLoad(options): ExecutionReport

Defined in: executor.ts:171

Runs minecraft:load, which a server does once after its packs load.

Parameters ​

options ​

ExecutionOptions<TSource>

Returns ​

ExecutionReport


runTick() ​

runTick(options): ExecutionReport

Defined in: executor.ts:176

Runs minecraft:tick, which a server does once per server tick.

Parameters ​

options ​

ExecutionOptions<TSource>

Returns ​

ExecutionReport