Files
horizon-airdef/crates/horizon-mod-sdk/examples/beacons/tests/beacons.toml
T
Ludovic Marie c5bb51bb05 Mod API 0.3: typed server commands, in players' command trees
A server mod's registration now lists each command's arguments: a name, a
kind (word, text, integer with bounds, number, boolean, player, block-pos)
and whether it is optional. The server adds them to the command tree every
player receives, after vanilla's commands, so a player's chat box completes
and colours them as vanilla's. When a player sends one, the server parses
the line as vanilla's parsers do (horizon-mods' commands.rs: ~ coordinates
from the player, @s/@p, integer bounds) and calls the mod's command hook
with the values by name, or answers with vanilla's error without calling
the mod.

The hub keeps the server mods' commands as a root in the commands report's
format and resends players' trees when they change (CommandTree::
packet_with); the game sets it when its mods start, stop or reload, or a
hub opens. In-frame, the window's own chat box lists them by name.

SDK: Registration::command_with(name, [Argument::...]), Argument builders,
Args (text(), integer(), player(), block_pos() ...); command(name) is free
text, an optional text argument. Examples: welcome's /mined [player],
beacons' /beacon [height] and /ground [pos], with scripts for values and
errors.

Docs: docs/mods.md (typed commands, kinds table), docs/api/mods.md and
the regenerated reference.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 19:35:09 +01:00

40 lines
1.2 KiB
TOML

# /ground [pos] reads the block under the player (or at pos) and the biome; /beacon [height] sets glowstone two to the east.
[[step]]
join = "Alex"
blocks = [{ x = 0, y = 63, z = 0, state = "minecraft:grass_block[snowy=false]" }]
command = "ground"
expect.feedback = "You are standing on minecraft:grass_block[snowy=false] in minecraft:plains"
[[step]]
command = "beacon"
expect.broadcast = ["Alex lit a beacon at 2 64 0"]
expect.blocks = [
{ x = 2, y = 64, z = 0, state = "minecraft:glowstone" },
{ x = 2, y = 67, z = 0, state = "minecraft:glowstone" },
{ x = 2, y = 68, z = 0, state = "minecraft:air" },
]
# Anywhere the script set nothing is air.
[[step]]
player = { x = 10.5, z = 10.5 }
command = "ground"
expect.feedback = "You are standing on minecraft:air in minecraft:plains"
# Typed arguments: a height, a position relative to the player.
[[step]]
player = { x = 5.5, y = 64.0, z = 5.5 }
command = "beacon 2"
expect.blocks = [
{ x = 7, y = 65, z = 5, state = "minecraft:glowstone" },
{ x = 7, y = 66, z = 5, state = "minecraft:air" },
]
[[step]]
command = "beacon 65"
expect.error = "Integer must not be more than 64, found 65"
[[step]]
command = "ground ~2 ~1 ~"
expect.feedback = "7 65 5 is minecraft:glowstone in minecraft:plains"