Appearance
Helix - the core compiler
helix compiles TypeScript into a datapack for a chosen Minecraft version. It provides typed values and commands only; conventions live in spool and twine.
Every example's Compiled output panel is real helix output.
Create a pack
dp.createFunction(name).build(ctx => ...) writes a function; ctx has a method per command. Functions named load or tick join the matching tag.
ts
import { Datapack, v26_2 } from "helix";
const dp = new Datapack("mypack", v26_2);
dp.createFunction("load").build((ctx) => {
ctx.say("loaded");
});Compiled output - the real files helix emits for the code above:
txt
say loadedjson
{
"values": [
"mypack:load"
]
}txt
{
"pack": {
"description": "mypack\nCreated using Helix",
"min_format": [
107,
1
],
"max_format": [
107,
1
]
}
}dp.writeDatapack(dir) writes to disk; buildDatapack(dp) returns the files in memory.
Target entities
ts
import { Datapack, v26_2, Selector, text, Color } from "helix";
const dp = new Datapack("mypack", v26_2);
dp.createFunction("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),
]);
});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": "mypack\nCreated using Helix",
"min_format": [
107,
1
],
"max_format": [
107,
1
]
}
}Use typed values
Build positions, blocks, items and NBT with their classes, never strings.
ts
import { Datapack, v26_2, Pos, Block } from "helix";
const dp = new Datapack("mypack", v26_2);
dp.createFunction("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);
});Compiled output - the real files helix emits for the code above:
txt
fill ~-2 ~ ~-2 ~2 ~ ~2 minecraft:stone
setblock ~ ~1 ~ minecraft:airtxt
{
"pack": {
"description": "mypack\nCreated using Helix",
"min_format": [
107,
1
],
"max_format": [
107,
1
]
}
}See Positions & blocks and Items.
Keep score and branch
ts
import { Datapack, v26_2, ScoreTarget } from "helix";
const dp = new Datapack("mypack", v26_2);
const score = dp.objective("score");
dp.createFunction("reward").build((ctx) => {
const points = score.score(ScoreTarget("total"));
ctx.if(points.greaterThan(9), (c) => {
c.say("high score!");
points.set(0);
});
});Compiled output - the real files helix emits for the code above:
txt
say high score!
scoreboard players set total score 0txt
execute if score total score matches 10.. run function mypack:zzzprivate/reward/if_0txt
{
"pack": {
"description": "mypack\nCreated using Helix",
"min_format": [
107,
1
],
"max_format": [
107,
1
]
}
}See Scores, Math and Conditions.
Add data files
Biomes, loot tables, recipes, predicates and advancements each have a builder that writes the right JSON shape for the target version.
ts
import { Datapack, v26_2, BiomeDef, SoundEvent, SpawnCategory, EntityType } from "helix";
const dp = new Datapack("mypack", v26_2);
dp.biome(
"minecraft:plains",
new BiomeDef()
.temperature(0.8)
.downfall(0.4)
.precipitation(true)
.effects((e) => e.skyColor("#78a7ff").ambientSound(SoundEvent.AMBIENT_CAVE))
.spawn(SpawnCategory.CREATURE, EntityType.SHEEP, { weight: 12, min: 4, max: 4 }),
);Compiled output - the real files helix emits for the code above:
json
{
"has_precipitation": true,
"temperature": 0.8,
"downfall": 0.4,
"effects": {},
"attributes": {
"minecraft:visual/sky_color": 7907327,
"minecraft:audio/ambient_sounds": {
"loop": "minecraft:ambient.cave"
}
},
"spawners": {
"creature": [
{
"type": "minecraft:sheep",
"weight": 12,
"minCount": 4,
"maxCount": 4
}
]
},
"spawn_costs": {},
"carvers": [],
"features": [
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[]
]
}txt
{
"pack": {
"description": "mypack\nCreated using Helix",
"min_format": [
107,
1
],
"max_format": [
107,
1
]
}
}See Data resources. For a registry with no builder, use dp.registryFile(folder, name, json).
Change version
Swap v26_2 for another profile, like v1_20_1, and the same source emits that version's folders, pack format and command syntax. Features the version lacks fail the build.
Check the output
| Tool | Does |
|---|---|
helix report | worst-case commands per tick and @e scans |
validateDatapack(dp) | checks JSON against the vanilla schema |
dp.writeResourcePack | writes the resource pack |