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

Score vectors ​

A ScoreVec3 is three Scores used as one vector; each method runs on all three axes.

ts
const vel = new ScoreVec3(m.score(ScoreTarget("vx")), m.score(ScoreTarget("vy")), m.score(ScoreTarget("vz")));
MethodDoes
.assign .add .sub .scale .divide .clampper axis, chainable
.dot(o, out)dot product into out
.lengthSquared(out)|v|^2 into out

It holds references only; you choose where the three scores live (per-entity or scratch).

Add vectors ​

ts
import { Datapack, v26_2, ScoreTarget, ScoreVec3 } from "helix";

const dp = new Datapack("physics", v26_2);
const motion = dp.objective("motion");
const vec = (p) =>
  new ScoreVec3(
    motion.score(ScoreTarget(p + "x")),
    motion.score(ScoreTarget(p + "y")),
    motion.score(ScoreTarget(p + "z")),
  );

dp.createFunction("step").build(() => {
  vec("p").add(vec("v"));
});

Open in playground

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

txt
scoreboard players operation px motion += vx motion
scoreboard players operation py motion += vy motion
scoreboard players operation pz motion += vz motion
txt
{
  "pack": {
    "description": "physics\nCreated using Helix",
    "min_format": [
      107,
      1
    ],
    "max_format": [
      107,
      1
    ]
  }
}

TIP

Each chained call is its own commands. For a formula, use math`...`, which takes ScoreVec3 holes.

Measure length ​

Compare squared lengths against squared thresholds. For the real length on 26.3+, use math`len(${v}) * 100`.into(out) (scaled to keep two decimals).

WARNING

divide and scale are integer ops; divide floors toward -infinity. For fractions, use Fixed-scaled scores.

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.