Alpha: this compiler is under active development and updates will break your projects. Not recommended for real use yet.
Skip to content

API Reference โ€‹

Helix exports ~200 symbols, but you only reach for a couple of dozen when authoring a pack. The rest are the compiler's internals - IR nodes, command handlers, codegen infrastructure - public so the upper layers can build on them, but not something you use to write gameplay.

This page is the curated authoring surface: the classes and factories you actually build packs with, grouped by task. Each links into its full generated page. If you want the exhaustive, every-symbol listing, jump to the full generated reference at the bottom.

Building a pack โ€‹

Everything hangs off one Datapack. You create functions on it and fill them in against a FunctionContext, where every ctx.<command>() lives.

SymbolWhat it's for
DatapackThe pack itself: createFunction, objective, writeDatapack, resource files, report().
FunctionContextThe ctx inside .build() - every command (say, tellraw, if, fill, score ops...) is a method here.
FunctionRefWhat createFunction returns; call .build(ctx => ...) on it.
version profilesv1_20_1, v1_20_4, v1_21_4, v26_2 - pass one to new Datapack.
ts
import { Datapack, v26_2 } from "helix";

const dp = new Datapack("demo", v26_2);

const load = dp.createFunction("load");
load.build((ctx) => {
  ctx.say("hello from helix");
});

Open in playground

Compiled output - the real files helix emits for the code above:

txt
say hello from helix
json
{
  "values": [
    "demo:load"
  ]
}
txt
{
  "pack": {
    "description": "demo\nCreated using Helix",
    "min_format": [
      107,
      1
    ],
    "max_format": [
      107,
      1
    ]
  }
}

Naming a function load (or tick) auto-registers it in the matching minecraft:load / minecraft:tick tag - that's why the tag JSON appears alongside the .mcfunction above.

Targeting entities โ€‹

SymbolWhat it's for
Selector@a/@e/@p/@s/@r plus a fluent, version-aware filter chain (.tag, .limit, .distance, .gamemode, .nbt, .score...).
ScoreTargetA score holder - a fake player name or a selector - for objective.score(...).
ts
import { Datapack, v26_2, Selector, text, Color } from "helix";

const dp = new Datapack("demo", v26_2);

const greet = dp.createFunction("greet");
greet.build((ctx) => {
  const admins = Selector.allPlayers().tag("admin").limit(1);
  ctx.tellraw(admins, [
    text("Welcome back, ").color(Color.GRAY),
    text("operator").color(Color.AQUA),
  ]);
});

Open in playground

Compiled output - the real files helix emits for the code above:

txt
tellraw @a[tag=admin,limit=1] [{"text":"Welcome back, ","color":"gray"},{"text":"operator","color":"aqua"}]
txt
{
  "pack": {
    "description": "demo\nCreated using Helix",
    "min_format": [
      107,
      1
    ],
    "max_format": [
      107,
      1
    ]
  }
}

Typed values โ€‹

Domain concepts are built with their own classes and render version-aware at codegen - never string-interpolated. If a value can't express something yet, the fix is to extend the value's API, not to hand-build a fragment.

SymbolWhat it's for
PosCoordinates: Pos(x,y,z), Pos.rel(...), Pos.local(...), Pos.here(), .offset, .center.
BlockBlock.STONE, Block(id, states), Block.tag(...).
ItemItem stacks with components; renders differently as a give-stack vs predicate JSON.
NbtTyped NBT compounds/lists/numbers (Byte/Short/Float/Double/Long).
IdNamespaced resource ids.
ts
import { Datapack, v26_2, Pos, Block } from "helix";

const dp = new Datapack("demo", v26_2);

const platform = dp.createFunction("platform");
platform.build((ctx) => {
  ctx.fill(Pos.rel(-2, 0, -2), Pos.rel(2, 0, 2), Block.STONE);
  ctx.setblock(Pos.here().offset(0, 1, 0), Block.AIR);
});

Open in playground

Compiled output - the real files helix emits for the code above:

txt
fill ~-2 ~ ~-2 ~2 ~ ~2 minecraft:stone
setblock ~ ~1 ~ minecraft:air
txt
{
  "pack": {
    "description": "demo\nCreated using Helix",
    "min_format": [
      107,
      1
    ],
    "max_format": [
      107,
      1
    ]
  }
}

Scores & math โ€‹

SymbolWhat it's for
ObjectiveA scoreboard objective (dp.objective(name, kind?)); .score(target) gives a Score.
ScoreA live score cell: .set/.add/.remove/.copy and comparisons (.equal, .greaterThan, .lessThan) that become if conditions.
FixedScale-tracked fixed-point scalar for precision-safe runtime math.
ScoreVec3A 3-vector of scores for runtime vector math.
ts
import { Datapack, v26_2, ScoreTarget } from "helix";

const dp = new Datapack("demo", v26_2);
const score = dp.objective("score");

const reward = dp.createFunction("reward");
reward.build((ctx) => {
  const points = score.score(ScoreTarget("total"));
  ctx.if(points.greaterThan(9), (ctx) => {
    ctx.say("high score!");
    points.set(0, ctx);
  });
});

Open in playground

Compiled output - the real files helix emits for the code above:

txt
say high score!
scoreboard players set total score 0
txt
execute if score total score matches 10.. run function demo:zzzprivate/reward/if_0
txt
{
  "pack": {
    "description": "demo\nCreated using Helix",
    "min_format": [
      107,
      1
    ],
    "max_format": [
      107,
      1
    ]
  }
}

The if body compiles to its own child function - that's why a second .mcfunction appears in the output above.

Text & chat โ€‹

SymbolWhat it's for
textBuild a single styled text span (.color(Color.X), bold/italic, click/hover).
TellrawTextA named, reusable sequence of parts for ctx.tellraw/ctx.title.
ClickEvent / HoverEventInteractivity attached to a Text.

Data resources โ€‹

Loot tables, recipes, predicates, item modifiers, advancements and models are typed builders on the Datapack - the emitted JSON is derived from the same value objects you author commands with.

SymbolWhat it's for
PredicateReferenceable predicate JSON; feeds Selector.predicate.
LootTableDef / ItemModifierLoot & item-modifier resources.
RecipeDefRecipe resources.
AdvancementDef / TriggerTyped advancements.
Model / ItemModel / BlockStateResource-pack outputs (dp.writeResourcePack).

Build, cost & validation โ€‹

SymbolWhat it's for
buildDatapackRun codegen in-memory -> Map<path, contents> (the disk form is dp.writeDatapack).
dp.report() / CostReportWorst-case commands/tick and unbounded-@e detection.
validateDatapackCheck emitted JSON against the vanilla schema for the target version (optional Spyglass deps).

Full generated reference โ€‹

Every exported symbol, generated from source with npm run gen:api (build helix first). Reach for these when you need the internals, not just the authoring surface:

  • helix - the core compiler (all ~200 exports).
  • spool - opt-in conveniences: KitPlugin, installKit, the plugin catalog.
  • twine - the opinionated framework: module / area / lifecycle composition, defineItem, StateMachine.

For narrative introductions, start with the Guide; for the authoring concepts in depth, see the helix guide.

Released under the MIT License ยท Credits
These docs were written with AI; the layout and every page have been reviewed by a human.