Appearance
Execute chains
ctx.execute() builds a raw execute ... run ... chain, one clause per method in call order.
TIP
Prefer ctx.if, sel.forEach and the other helpers. Use ctx.execute() for ported packs or store maths.
| Context | Clause |
|---|---|
.as(sel) / .at(sel) | as / at |
.positioned(pos) / .positionedAs(sel) | positioned / positioned as |
.rotatedAs(sel) | rotated as |
.facing(pos) / .facingEntity(sel, anchor) | facing / facing entity |
.anchored(EntityAnchor.EYES) | anchored |
.in(dim) / .align(axes) | in / align |
Guard (each has an unless... twin) | Clause |
|---|---|
.ifEntity(sel) | if entity |
.ifBlock(pos, block) | if block |
.ifScoreMatches(score, range) | if score ... matches |
.ifScore(a, op, b) | if score ... <op> ... |
.ifPredicate(ref) | if predicate |
.ifItems(sel, slot, item) | if items entity |
| Store | Clause |
|---|---|
.storeResultScore(score) / .storeSuccessScore(score) | store result|success score |
.storeResultStorage(id, path, type, scale) | store result storage |
Chain clauses
A one-command body inlines into run; a longer one becomes its own function.
ts
import { Datapack, v26_2, Selector, Pos, Block, Range } from "helix";
const dp = new Datapack("gameplay", v26_2);
const game = dp.objective("game");
dp.createFunction("standing_on_gold").build((ctx) => {
ctx
.execute()
.as(Selector.allPlayers())
.at(Selector.self())
.ifBlock(Pos.rel(0, -1, 0), Block.GOLD_BLOCK)
.ifScoreMatches(game.score(Selector.self()), new Range(1, undefined))
.run((c) => c.say("standing on gold"));
});Compiled output - the real files helix emits for the code above:
txt
execute as @a at @s if block ~ ~-1 ~ minecraft:gold_block if score @s game matches 1.. run say standing on goldtxt
{
"pack": {
"description": "gameplay\nCreated using Helix",
"min_format": [
107,
1
],
"max_format": [
107,
1
]
}
}Store a result
ts
import { Datapack, v26_2, Selector, ScoreTarget } from "helix";
const dp = new Datapack("gameplay", v26_2);
const game = dp.objective("game");
dp.createFunction("count").build((ctx) => {
ctx
.execute()
.storeResultScore(game.score(ScoreTarget("#players")))
.run((c) => c.say("counting"));
});Compiled output - the real files helix emits for the code above:
txt
execute store result score #players game run say countingtxt
{
"pack": {
"description": "gameplay\nCreated using Helix",
"min_format": [
107,
1
],
"max_format": [
107,
1
]
}
}