Files
horizon-airdef/crates/horizon-mod-sdk/examples/welcome/tests/commands.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

47 lines
1019 B
TOML

# /online lists the players and their dimension; /mined [player] counts a player's blocks.
[[step]]
join = "Alex"
expect.commands = ["online", "mined"]
[[step]]
join = "Steve"
as = "Steve"
player = { dimension = "minecraft:the_nether" }
command = "online"
expect.feedback = "Alex (overworld), Steve (the_nether)"
[[step]]
as = "Alex"
break = { x = 1, y = 63, z = 0, state = "minecraft:stone" }
[[step]]
as = "Alex"
break = { x = 2, y = 63, z = 0, state = "minecraft:dirt" }
# A step's command comes before its break and place.
[[step]]
as = "Alex"
command = "mined"
expect.feedback = "You broke 2 block(s)"
[[step]]
as = "Steve"
command = "mined"
expect.feedback = "You broke 0 block(s)"
[[step]]
as = "Steve"
command = "mined alex"
expect.feedback = "Alex broke 2 block(s)"
# The server parses the arguments before the mod: vanilla's errors.
[[step]]
as = "Steve"
command = "mined Herobrine"
expect.error = "No player was found"
[[step]]
command = "online now"
expect.error = "Incorrect argument for command"