[PR #5815] [MERGED] Native mods: a registered command typed on the dedicated server's console (part of #5682) #6501

Closed
opened 2026-11-03 06:21:41 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5815
Author: @Detimes
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @levzzz5154

Base: main ← Head: feat-5682-console-native-commands


📝 Commits (5)

  • 7176677 Native mods: a registered command typed on the dedicated server's console (#5682)
  • 678eecf Hook catalog fragment: name without the native_ prefix (#5682)
  • 2b7549c Merge remote-tracking branch 'hr/main' into pr-5815
  • 723299c Console mod commands: look the line up trimmed, as the console reads it
  • 02197e6 Merge remote-tracking branch 'hr/main' into pr-5815

📊 Changes

5 files changed (+51 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game/dedicated.rs (+5 -1)
📝 crates/horizon-client/src/game/native_hooks.rs (+11 -0)
📝 crates/horizon-client/src/game/native_server.rs (+24 -0)
📝 docs/native-mods.md (+4 -0)
➕ tools/native-hook-fragments/native_perform_console_command.json (+7 -0)

📄 Description

🤖 Opened by Detimes' AI agent (Claude Code, Claude Sonnet 5.5), not by Detimes personally.

What and why

Part of #5682 (the dedicated server's console half; the single player owner's console is left as it is: that console is a player, whose chat commands already reach mods). A command a native mod registers with native_register_commands could be typed in chat but not on the dedicated server's console: console_command sent every line it did not own to the game's dispatcher, which answers "unknown command".

  • New hook point native_perform_console_command(command, ran), next to native_perform_command, with a fragment (tools/native-hook-fragments/native_perform_console_command.json) for the API number and a paragraph in docs/native-mods.md.
  • Game::perform_native_console_command (in native_server.rs) offers a line to it only when a mod registered that name; the console is level 4, so every registered usage is allowed. A registered name no mod takes answers as vanilla's unknown command, as a player's does.
  • dedicated.rs calls it before the game's dispatcher. Everything else (stop, say, vanilla commands, a name no mod registered) goes where it went.
  • No player is swapped in, so native_acting_player is None and native_feedback writes to the console, through the capture that the dispatcher path already uses.

Kind

  • feature (a new native hook point, API number assigned by the stamp tool from the fragment)

Vanilla reference

DedicatedServer.handleConsoleInputs runs a console line through Commands.performCommand with the server's command source (level 4). Horizon's console path (dedicated.rs, console_command) is the port; this adds the mods' step in front of its dispatcher.

Other projects' code

none. (Tested with a throwaway bundle built with horizon-mixins, not part of this PR.)

Proof on a real dedicated server

Engine built from this branch with a throwaway horizon-mixins bundle that registers corehello (native_register_commands) and answers it from native_perform_command (player) and native_perform_console_command (console). Fresh world, offline mode, commands typed on the console with screen -X stuff:

corehello            -> System chat: Hello console from a native mod
corehello extra      -> System chat: Unknown or incomplete command. See below for error   (registered, the mod did not take it)
nosuchcmd            -> System chat: Unknown or incomplete command ... nosuchcmd<--[HERE]  (vanilla, as before)
list                 -> System chat: There are 0 of a max of 5 players online:             (vanilla, as before)

A protocol client that types /corehello in chat still gets Hello <name> from a native mod on the server (the player path is unchanged). On main without the hook, the same console line answers "Unknown or incomplete command".

Not covered: the single player owner's console (that console is a player, whose chat commands already reach mods). No unit test for the routing itself: it needs a running dedicated game; the real-server run above is the regression check, and native_hooks::tests (catalog and hook points) pass.

Self-check

pr_ready --quick --base upstream/main before the last commit: rustfmt, clippy, Python tests, doc tests pass; horizon-client tests 1608 passed, 1 failed, catalog_matches_hook_points, because my fragment named the hook native_perform_console_command (the tool adds the native_ prefix). Fixed in the last commit; cargo test -p horizon-client --bin horizon-client native_hooks::tests now passes (16 tests). The full suite was not re-run after that one-word fix.


🔄 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/5815 **Author:** [@Detimes](https://github.com/Detimes) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `feat-5682-console-native-commands` --- ### 📝 Commits (5) - [`7176677`](https://github.com/horizon-rust/horizon/commit/7176677496adab19732aa90843866ed8cde050da) Native mods: a registered command typed on the dedicated server's console (#5682) - [`678eecf`](https://github.com/horizon-rust/horizon/commit/678eecf01c01df33e84e841b95c61e148a0754e3) Hook catalog fragment: name without the native_ prefix (#5682) - [`2b7549c`](https://github.com/horizon-rust/horizon/commit/2b7549c556d4d438fc39aa8f7cb9dde7524c30ec) Merge remote-tracking branch 'hr/main' into pr-5815 - [`723299c`](https://github.com/horizon-rust/horizon/commit/723299c6aba915ae43377cd7599d8683413ea17d) Console mod commands: look the line up trimmed, as the console reads it - [`02197e6`](https://github.com/horizon-rust/horizon/commit/02197e6053d6528d98757f86b90ee033b5356e07) Merge remote-tracking branch 'hr/main' into pr-5815 ### 📊 Changes **5 files changed** (+51 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/dedicated.rs` (+5 -1) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+11 -0) 📝 `crates/horizon-client/src/game/native_server.rs` (+24 -0) 📝 `docs/native-mods.md` (+4 -0) ➕ `tools/native-hook-fragments/native_perform_console_command.json` (+7 -0) </details> ### 📄 Description > 🤖 Opened by Detimes' AI agent (Claude Code, Claude Sonnet 5.5), not by Detimes personally. ## What and why Part of #5682 (the dedicated server's console half; the single player owner's console is left as it is: that console is a player, whose chat commands already reach mods). A command a native mod registers with `native_register_commands` could be typed in chat but not on the dedicated server's console: `console_command` sent every line it did not own to the game's dispatcher, which answers "unknown command". - New hook point `native_perform_console_command(command, ran)`, next to `native_perform_command`, with a fragment (`tools/native-hook-fragments/native_perform_console_command.json`) for the API number and a paragraph in `docs/native-mods.md`. - `Game::perform_native_console_command` (in `native_server.rs`) offers a line to it only when a mod registered that name; the console is level 4, so every registered usage is allowed. A registered name no mod takes answers as vanilla's unknown command, as a player's does. - `dedicated.rs` calls it before the game's dispatcher. Everything else (`stop`, `say`, vanilla commands, a name no mod registered) goes where it went. - No player is swapped in, so `native_acting_player` is None and `native_feedback` writes to the console, through the capture that the dispatcher path already uses. ## Kind - [x] feature (a new native hook point, API number assigned by the stamp tool from the fragment) ## Vanilla reference `DedicatedServer.handleConsoleInputs` runs a console line through `Commands.performCommand` with the server's command source (level 4). Horizon's console path (`dedicated.rs`, `console_command`) is the port; this adds the mods' step in front of its dispatcher. ## Other projects' code none. (Tested with a throwaway bundle built with horizon-mixins, not part of this PR.) ## Proof on a real dedicated server Engine built from this branch with a throwaway horizon-mixins bundle that registers `corehello` (`native_register_commands`) and answers it from `native_perform_command` (player) and `native_perform_console_command` (console). Fresh world, offline mode, commands typed on the console with `screen -X stuff`: ``` corehello -> System chat: Hello console from a native mod corehello extra -> System chat: Unknown or incomplete command. See below for error (registered, the mod did not take it) nosuchcmd -> System chat: Unknown or incomplete command ... nosuchcmd<--[HERE] (vanilla, as before) list -> System chat: There are 0 of a max of 5 players online: (vanilla, as before) ``` A protocol client that types `/corehello` in chat still gets `Hello <name> from a native mod on the server` (the player path is unchanged). On `main` without the hook, the same console line answers "Unknown or incomplete command". Not covered: the single player owner's console (that console is a player, whose chat commands already reach mods). No unit test for the routing itself: it needs a running dedicated game; the real-server run above is the regression check, and `native_hooks::tests` (catalog and hook points) pass. ## Self-check `pr_ready --quick --base upstream/main` before the last commit: rustfmt, clippy, Python tests, doc tests pass; `horizon-client` tests 1608 passed, 1 failed, `catalog_matches_hook_points`, because my fragment named the hook `native_perform_console_command` (the tool adds the `native_` prefix). Fixed in the last commit; `cargo test -p horizon-client --bin horizon-client native_hooks::tests` now passes (16 tests). The full suite was not re-run after that one-word fix. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:21:41 +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#6501
No description provided.