Appearance
Positions & blocks
A Pos is a coordinate and a Block is a block id with optional state and data. Pass them to any command that takes one.
| Position | Renders |
|---|---|
Pos(10, 4, 5) | 10 4 5 |
Pos.rel(0, 1, 0) | ~ ~1 ~ |
Pos.local(0, 0, 2) | ^ ^ ^2 |
Pos.here() | ~ ~ ~ |
| Block | Renders |
|---|---|
Block.FURNACE.state({ ... }) | minecraft:furnace[facing=north] |
Block.CHEST.data(nbt) | minecraft:chest{...} |
Block.tag(BLOCK_TAGS.LOGS) | #minecraft:logs |
Place blocks
.offset(dx, dy, dz) shifts a position; .center() adds 0.5 on each axis.
ts
import { Datapack, v26_2, Pos, Block } from "helix";
const dp = new Datapack("world", v26_2);
dp.createFunction("place").build((ctx) => {
ctx.setblock(Pos(0, 64, 0), Block.STONE);
ctx.setblock(Pos.rel(0, 1, 0), Block.GLOWSTONE);
ctx.setblock(Pos(0, 64, 0).offset(0, 2, 0), Block.DIAMOND_BLOCK);
});Compiled output - the real files helix emits for the code above:
txt
setblock 0 64 0 minecraft:stone
setblock ~ ~1 ~ minecraft:glowstone
setblock 0 66 0 minecraft:diamond_blocktxt
{
"pack": {
"description": "world\nCreated using Helix",
"min_format": [
107,
1
],
"max_format": [
107,
1
]
}
}Fill an area
ctx.fill(from, to, block) fills solid; ctx.fill().<mode>(...) picks a mode.
ts
import { Datapack, v26_2, Pos, Block, BLOCK_TAGS, Furnace, text } from "helix";
const dp = new Datapack("world", v26_2);
dp.createFunction("build_room").build((ctx) => {
ctx.fill().hollow(Pos(0, 64, 0), Pos(6, 68, 6), Block.STONE_BRICKS);
ctx.setblock(
Pos(3, 65, 0),
Block.FURNACE.state({ facing: "north" }).data(Furnace({ customName: text("Forge") })),
);
ctx.fill().replace(Pos(1, 65, 1), Pos(5, 67, 5), Block.TORCH, Block.tag(BLOCK_TAGS.AIR));
});Compiled output - the real files helix emits for the code above:
txt
fill 0 64 0 6 68 6 minecraft:stone_bricks hollow
setblock 3 65 0 minecraft:furnace[facing=north]{CustomName:{text:"Forge"}}
fill 1 65 1 5 67 5 minecraft:torch replace #minecraft:airtxt
{
"pack": {
"description": "world\nCreated using Helix",
"min_format": [
107,
1
],
"max_format": [
107,
1
]
}
}TIP
Use BLOCK_TAGS constants, not "#minecraft:..." strings.
See also
- Execute chains:
.positioned,.ifBlock - Items