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

Parkour checkpoints ​

A parkour course with two checkpoints, falling back to the last one reached, a tick timer, a personal best and a clickable "run again".

TechniqueWhere
enter_block eventmain.ts: one Trigger.enterBlock event for every plate, then position checks pick which plate
Ordered progressmain.ts: a checkpoint only counts if the one before it is set, so you can't skip ahead
Trigger objectivefinish.ts: the chat button runs trigger pk_restart, which non-ops can use; tick reacts to it
Unset scoresfinish.ts: the best-time check uses atLeast(1) because an unset score fails every test
ts
import { Selector, Range, Trigger, Detect, Block, Pos, text, Color, Component, and } from "helix";
import { START, CHECKPOINT_1, CHECKPOINT_2, FINISH } from "./course";
import { dp, checkpointObj, restartObj, checkpoint, timer, restart } from "./pack";
import { start, respawn } from "./runs";
import { finish } from "./finish";

/** True when the player stands within a block and a half of `pos`. */
function standingOn(pos: Pos) {
  return Detect.entity(Selector.self().near(pos.coords(), Range.atMost(1.5)));
}

// Every plate fires this; check which one it was and stop at the first match.
dp.event("plate", Trigger.enterBlock(Block.HEAVY_WEIGHTED_PRESSURE_PLATE), (ctx) => {
  ctx
    .if(standingOn(START), (c) => c.call(start))
    .elif(and(standingOn(CHECKPOINT_1), checkpoint.equal(0)), (c) => {
      checkpoint.set(1);
      c.title().actionbar(Selector.self(), Component(text("Checkpoint 1").color(Color.YELLOW)));
    })
    .elif(and(standingOn(CHECKPOINT_2), checkpoint.equal(1)), (c) => {
      checkpoint.set(2);
      c.title().actionbar(Selector.self(), Component(text("Checkpoint 2").color(Color.YELLOW)));
    })
    .elif(and(standingOn(FINISH), checkpoint.equal(2)), (c) => c.call(finish));
});

// Players on the course: count up the timer, and respawn anyone who fell.
dp.tick(() => {
  Selector.allPlayers().score(checkpointObj, Range.atLeast(0)).forEach((p) => {
    timer.add(1);
    // y=-64 up to y=58 counts as fallen.
    p.if(Detect.entity(Selector.self().yBand(-64, 122)), (c) => c.call(respawn));
  });
});

// Players who clicked "Run again".
dp.tick(() => {
  Selector.allPlayers().score(restartObj, Range.atLeast(1)).forEach((p) => {
    restart.set(0);
    p.teleport(Selector.self(), START);
    p.call(start);
  });
});
ts
import { Pos } from "helix";

export const START = Pos(0, 64, 0);
export const CHECKPOINT_1 = Pos(12, 70, 4);
export const CHECKPOINT_2 = Pos(20, 78, -6);
export const FINISH = Pos(31, 85, 0);
ts
import { Datapack, v26_3, Selector } from "helix";

export const dp = new Datapack("parkour", v26_3);

export const checkpointObj = dp.objective("pk_checkpoint");
export const restartObj = dp.objective("pk_restart", "trigger");
export const checkpoint = checkpointObj.score(Selector.self());
export const restart = restartObj.score(Selector.self());
export const timer = dp.objective("pk_ticks").score(Selector.self());
export const best = dp.objective("pk_best").score(Selector.self());
ts
import { Selector } from "helix";
import { START, CHECKPOINT_1, CHECKPOINT_2 } from "./course";
import { dp, checkpoint, timer, restart } from "./pack";

// Starts a run: back to checkpoint 0 and the timer at 0.
export const start = dp.createFunction("start").build(() => {
  checkpoint.set(0);
  timer.set(0);
  restart.enable();
});

// Teleports the player back to the last checkpoint they reached.
export const respawn = dp.createFunction("respawn").build((ctx) => {
  ctx
    .if(checkpoint.equal(0), (c) => c.teleport(Selector.self(), START))
    .elif(checkpoint.equal(1), (c) => c.teleport(Selector.self(), CHECKPOINT_1))
    .elif(checkpoint.equal(2), (c) => c.teleport(Selector.self(), CHECKPOINT_2));
});
ts
import { Selector, triggerCmd, text, Color, click, hover } from "helix";
import { dp, restartObj, checkpoint, timer, best } from "./pack";

export const finish = dp.createFunction("finish").build((ctx) => {
  // First run: no best yet, so take this time.
  ctx.if(best.atLeast(1), () => best.min(timer)).else(() => best.assign(timer));

  ctx.tellraw(Selector.self(), [
    text("Finished in ").color(Color.GREEN),
    timer,
    text(" ticks (best "),
    best,
    text(") "),
    text("[ Run again ]")
      .color(Color.AQUA)
      .onClick(click.command(triggerCmd(restartObj, 1)))
      .onHover(hover.text(text("Back to the start").color(Color.GRAY))),
  ]);

  // Off the course until the next start.
  checkpoint.set(-1);
});

Open in playground

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

txt
scoreboard players set @s pk_checkpoint 0
scoreboard players set @s pk_ticks 0
scoreboard players enable @s pk_restart
txt
execute if score @s pk_checkpoint matches 0 run return run teleport @s 0 64 0
execute if score @s pk_checkpoint matches 1 run return run teleport @s 12 70 4
execute if score @s pk_checkpoint matches 2 run return run teleport @s 20 78 -6
txt
execute if score @s pk_best matches 1.. run return run scoreboard players operation @s pk_best < @s pk_ticks
scoreboard players operation @s pk_best = @s pk_ticks
txt
function parkour:zzzprivate/finish/if_0_chain
tellraw @s [{"text":"Finished in ","color":"green"},{"score":{"name":"@s","objective":"pk_ticks"}},{"text":" ticks (best "},{"score":{"name":"@s","objective":"pk_best"}},{"text":") "},{"text":"[ Run again ]","color":"aqua","click_event":{"action":"run_command","command":"trigger pk_restart set 1"},"hover_event":{"action":"show_text","value":[{"text":"Back to the start","color":"gray"}]}}]
scoreboard players set @s pk_checkpoint -1
txt
scoreboard players set @s pk_checkpoint 1
title @s actionbar {"text":"Checkpoint 1","color":"yellow"}
txt
scoreboard players set @s pk_checkpoint 2
title @s actionbar {"text":"Checkpoint 2","color":"yellow"}
txt
advancement revoke @s only parkour:zzzprivate/plate
execute if entity @s[x=0,y=64,z=0,distance=..1.5] run return run function parkour:zzzprivate/start
execute if entity @s[x=12,y=70,z=4,distance=..1.5] if score @s pk_checkpoint matches 0 run return run function parkour:zzzprivate/plate/elif_0
execute if entity @s[x=20,y=78,z=-6,distance=..1.5] if score @s pk_checkpoint matches 1 run return run function parkour:zzzprivate/plate/elif_1
execute if entity @s[x=31,y=85,z=0,distance=..1.5] if score @s pk_checkpoint matches 2 run return run function parkour:zzzprivate/finish
txt
scoreboard players add @s pk_ticks 1
execute if entity @s[y=-64,dy=122] run function parkour:zzzprivate/respawn
txt
scoreboard players set @s pk_restart 0
teleport @s 0 64 0
function parkour:zzzprivate/start
txt
execute as @a[scores={pk_checkpoint=0..}] at @s run function parkour:zzzprivate/tick/exec_0
execute as @a[scores={pk_restart=1..}] at @s run function parkour:zzzprivate/tick/exec_1
json
{
  "values": [
    "parkour:tick"
  ]
}
json
{
  "criteria": {
    "trigger": {
      "trigger": "minecraft:enter_block",
      "conditions": {
        "blocks": "minecraft:heavy_weighted_pressure_plate"
      }
    }
  },
  "rewards": {
    "function": "parkour:zzzprivate/plate"
  }
}
txt
{
  "pack": {
    "description": "parkour\nCreated using Helix",
    "min_format": [
      121,
      0
    ],
    "max_format": [
      121,
      0
    ]
  }
}

Try it

Place heavy weighted pressure plates at the positions in course.ts and step on the first one.

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