[PR #463] [MERGED] Mod commands: coloured and Tab-completed in the chat like vanilla's (#456) #2581

Closed
opened 2026-11-02 15:57:22 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/463
Author: @ludovic111
Created: 10/16/2026
Status: ✅ Merged
Merged: 10/16/2026
Merged by: @ludovic111

Base: main ← Head: fix/mod-commands-in-chat


📝 Commits (1)

  • 3cfb7b8 Mods' commands in the chat's command tree (#456)

📊 Changes

6 files changed (+109 additions, -8 deletions)

View changed files

📝 crates/horizon-client/src/chat_tests.rs (+38 -0)
📝 crates/horizon-client/src/command/mod.rs (+16 -0)
📝 crates/horizon-client/src/command/tests.rs (+22 -0)
📝 crates/horizon-client/src/game/chat.rs (+7 -7)
📝 crates/horizon-client/src/game/mods.rs (+23 -1)
📝 docs/mods.md (+3 -0)

📄 Description

Fixes #456 (thanks @Online5277).

What

Commands a mod registers (the coords HUD example's /where and /coords) ran, but the chat box parsed against vanilla's tree only, so they showed red as unknown and never Tab-completed.

Why

Mods::commands() existed "for suggestions" but nothing used it: every chat call (open_chat, keys, typing, clicks, draw) passed vanilla::game_dispatcher(). #407's permission filter isn't involved, since it only drops nodes that are in the tree, and these weren't.

How

  • Dispatcher::with_mod_commands(names): a clone of the tree plus, per mod command, a root literal (permission 0, like the runtime, which runs mod commands whatever the level) that executes alone or with an optional greedy args. Mods' own args are free text, so /where north 12 isn't red.
  • ModsState keeps that tree while a running mod owns commands (else vanilla's static one), rebuilt when mods start, a dev mod reloads, or a mod stops. The chat's six call sites use self.mods.dispatcher().
  • /help, command execution and LAN guests' suggestions are unchanged (mod commands are this client's and still run before the vanilla parse).
  • Arguments: mod API 0.1's registration only carries names (commands: list<string>), so there are no declared argument types to complete. Declaring them needs a WIT 0.2 field; noted in docs/mods.md.

Tested

  • Unit: command::tests::mod_commands_join_the_tree_for_every_player (parse executable at permission 0 with and without args, client_suggestions lists it, the static tree is untouched); chat::tests::mod_commands_are_coloured_and_complete_like_vanilla_ones (vanilla's tree colours /coords red, the modded one doesn't for /coords, /where, /where me and you; /coo + Tab → /coords, with Allow Commands off).
  • In game (Mac mini, --offscreen, --dev-mod coords_hud.hmod, horizon-ctl): /coo suggests coords; Tab → /coords in normal grey; /coords anything here shows [<args>] with the args in aqua; /where + Enter prints [Coordinates HUD] -36, 70, 2 in minecraft:overworld.
cargo fmt --all -- --check                                   ok
cargo clippy --workspace --all-targets -- -D warnings        ok
cargo test -p horizon-client                                 ok (729 lib + integration)
tools/parity.py --changed origin/main (82 harnesses)         ok (83 passed, 0 failed, on the rebased tip)

Needs Ludovic: nothing.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/463 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/mod-commands-in-chat` --- ### 📝 Commits (1) - [`3cfb7b8`](https://github.com/horizon-rust/horizon/commit/3cfb7b80533b648558bed6d637f3c46c2323be29) Mods' commands in the chat's command tree (#456) ### 📊 Changes **6 files changed** (+109 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/chat_tests.rs` (+38 -0) 📝 `crates/horizon-client/src/command/mod.rs` (+16 -0) 📝 `crates/horizon-client/src/command/tests.rs` (+22 -0) 📝 `crates/horizon-client/src/game/chat.rs` (+7 -7) 📝 `crates/horizon-client/src/game/mods.rs` (+23 -1) 📝 `docs/mods.md` (+3 -0) </details> ### 📄 Description Fixes #456 (thanks @Online5277). ## What Commands a mod registers (the coords HUD example's `/where` and `/coords`) ran, but the chat box parsed against vanilla's tree only, so they showed red as unknown and never Tab-completed. ## Why `Mods::commands()` existed "for suggestions" but nothing used it: every chat call (`open_chat`, keys, typing, clicks, draw) passed `vanilla::game_dispatcher()`. #407's permission filter isn't involved, since it only drops nodes that are in the tree, and these weren't. ## How - `Dispatcher::with_mod_commands(names)`: a clone of the tree plus, per mod command, a root literal (permission 0, like the runtime, which runs mod commands whatever the level) that executes alone or with an optional greedy `args`. Mods' own args are free text, so `/where north 12` isn't red. - `ModsState` keeps that tree while a running mod owns commands (else vanilla's static one), rebuilt when mods start, a dev mod reloads, or a mod stops. The chat's six call sites use `self.mods.dispatcher()`. - `/help`, command execution and LAN guests' suggestions are unchanged (mod commands are this client's and still run before the vanilla parse). - Arguments: mod API 0.1's `registration` only carries names (`commands: list<string>`), so there are no declared argument types to complete. Declaring them needs a WIT 0.2 field; noted in `docs/mods.md`. ## Tested - Unit: `command::tests::mod_commands_join_the_tree_for_every_player` (parse executable at permission 0 with and without args, `client_suggestions` lists it, the static tree is untouched); `chat::tests::mod_commands_are_coloured_and_complete_like_vanilla_ones` (vanilla's tree colours `/coords` red, the modded one doesn't for `/coords`, `/where`, `/where me and you`; `/coo` + Tab → `/coords`, with Allow Commands off). - In game (Mac mini, `--offscreen`, `--dev-mod coords_hud.hmod`, horizon-ctl): `/coo` suggests `coords`; Tab → `/coords` in normal grey; `/coords anything here` shows `[<args>]` with the args in aqua; `/where` + Enter prints `[Coordinates HUD] -36, 70, 2 in minecraft:overworld`. ``` cargo fmt --all -- --check ok cargo clippy --workspace --all-targets -- -D warnings ok cargo test -p horizon-client ok (729 lib + integration) tools/parity.py --changed origin/main (82 harnesses) ok (83 passed, 0 failed, on the rebased tip) ``` Needs Ludovic: nothing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:57:22 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#2581
No description provided.