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

Entity data ​

Each entity has a typed factory (Tnt, Villager, Pillager...) with camelCase fields. helix picks the vanilla key and suffix, and drops fields the target version doesn't have.

ts
Tnt({ fuse: 40, blockState: Block.SAND }).render(v1_20_1); // {Fuse:40s}

Summon with data ​

The factory names the entity, so ctx.summon(data, pos) needs no entity type.

ts
import { Datapack, v26_2, Pos, Pillager, Item, Enchantment } from "helix";

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

dp.createFunction("battery").build((ctx) => {
  ctx.summon(
    Pillager({
      persistenceRequired: true,
      tags: ["artillery"],
      equipment: {
        mainhand: Item.CROSSBOW.enchant(Enchantment.QUICK_CHARGE, 3),
        head: Item.IRON_HELMET,
      },
    }),
    Pos.rel(0, 0, 12),
  );
});

Open in playground

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

txt
summon minecraft:pillager ~ ~ ~12 {PersistenceRequired:1b,Tags:["artillery"],equipment:{mainhand:{id:"minecraft:crossbow",count:1,components:{"minecraft:enchantments":{"minecraft:quick_charge":3}}},head:{id:"minecraft:iron_helmet",count:1}}}
txt
{
  "pack": {
    "description": "mobs\nCreated using Helix",
    "min_format": [
      107,
      1
    ],
    "max_format": [
      107,
      1
    ]
  }
}

Fields take value objects: an equipment slot takes an Item, blockState takes a Block.

Run commands on the new entity ​

Pass a body as the third argument; it runs as and at the new entity.

ts
ctx.summon(Interaction({ tags: ["box"] }), Pos.rel(0, 1, 0), (c) => c.say("spawned"));

Missing fields or entities ​

A missing field belongs in helix/scripts/gen-entity-nbt.mjs. For an unmodelled entity use defineEntityNbt.

See also ​

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