[PR #845] [MERGED] Server: commands act on other players (names, UUIDs, @a/@p/@r, execute as/at) #2854

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

📋 Pull Request Information

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

Base: main ← Head: feat/server-player-targets


📝 Commits (1)

  • 54bae61 feat(server): commands act on other players (names, UUIDs, @a/@p/@r/@s)

📊 Changes

14 files changed (+995 additions, -188 deletions)

View changed files

📝 crates/horizon-client/src/game/advancements.rs (+21 -11)
📝 crates/horizon-client/src/game/commands.rs (+187 -92)
📝 crates/horizon-client/src/game/commands/data.rs (+5 -0)
📝 crates/horizon-client/src/game/commands/effects.rs (+20 -15)
📝 crates/horizon-client/src/game/commands/execute.rs (+8 -3)
➕ crates/horizon-client/src/game/commands/players.rs (+210 -0)
📝 crates/horizon-client/src/game/dedicated.rs (+1 -0)
📝 crates/horizon-client/src/game/lan.rs (+14 -1)
📝 crates/horizon-client/src/game/lan_actions.rs (+272 -64)
📝 crates/horizon-client/src/game/scoreboard.rs (+2 -1)
📝 crates/horizon-client/src/lan/hub.rs (+10 -0)
📝 crates/horizon-client/src/text.rs (+6 -0)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/LocatorBarClient.java (+40 -1)
➕ tools/test_server_player_targets_parity.py (+199 -0)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

What

Commands on a dedicated server (and a hosted world) can now target the other players, from the console, an operator or a command block, as vanilla's EntitySelector.findPlayers / EntityArgument do:

  • Targets: names (any case), UUIDs, @a, @p, @r, @e/@n (skipping the dead), @s under execute as, in join order, limited to the source's level when the selector names a place (x/y/z, distance, dx…), with level= and gamemode= read from each player.
  • Commands: give (drops and pickup sound at the receiving player), gamemode (the target is told gameMode.changed), tp (to a place, to a player with their rotation, with a rotation; into another level by execute in, the console's Overworld or a destination in another level), kill (vanilla's death message to everyone), effect give / effect clear, and data/nbt= on a player. execute as|at|positioned as|rotated as|facing entity read the other player's position, rotation and eye height.
  • How: every guest other than the one in place is Target::Guest(conn) (new game/commands/players.rs). What a command does to them runs with their state swapped in (for_player), in their level, as their own turn, and what it tells them goes to their chat. For that, as_guest splits into enter_guest / leave_guest (same behaviour, and turns can nest), and a guest's commands are queued per packet and run with the hub back in self.lan so they reach the other players. Side effect: an operator's /kick now works (it failed with commands.kick.singleplayer.failed).
  • Vanilla's feedback shape: player names are Player.getDisplayName (hover, click, insertion), item names ItemStack.getDisplayName (translated name, rarity colour, show_item hover), advancement names Advancement.decorateName; the console's source has no entity ([Server: …]) and sits at the corner of the spawn block; effects an operator gives leave with the command (600 ticks, not 599).

Contributor PR #800 (single-player execute in dimension switch, draft) is untouched: this builds on main's server-side execute in path, not on the single-player one.

Not in this PR

  • The locator bar across levels: filed as #843 (main's waypoints ignore levels); the new harness leaves waypoint lines out, like the dimension harness.
  • What a guest's death does besides its messages (drops, the body leaving the others' view, inventory cleared): the harness compares only the messages at /kill.
  • A guest's command can't target the LAN host's own player (swapped out during the guest's turn), and tags (tag=) of other players aren't read yet.

How tested

New harness tools/test_server_player_targets_parity.py: vanilla and Horizon dedicated servers, LocatorBarClient (now also recording game mode events, teleports, inventory slots, effects and deaths with state on) as Alice and Bob, 27 steps from the console and an operator. Each player's lines per step compared exactly (sorted within a step).

cargo fmt --all -- --check                                  ok
cargo clippy --workspace --all-targets -- -D warnings       ok (after rebase on 4b43242a)
cargo test -p horizon-client                                ok (860 + 67 + … passed)
test_server_player_targets_parity      server player targets: 109 lines identical
test_server_ops_feedback_parity        17 chat lines identical
test_server_dimension_players_parity   22 lines identical
test_secure_chat_parity                transcripts and chat log lines identical
test_lan_parity                        462 cases match
test_dedicated_server_parity           591 transcript lines identical
test_command_exec_parity               ok
test_command_parse_parity              ok

tools/parity.py --changed was skipped (it selects nearly all 299 harnesses since almost everything links horizon-client); CI parity covers the rest.

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/845 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/18/2026 **Status:** ✅ Merged **Merged:** 10/18/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/server-player-targets` --- ### 📝 Commits (1) - [`54bae61`](https://github.com/horizon-rust/horizon/commit/54bae6131bab839a702ca3fce0e66dbe6700f2ed) feat(server): commands act on other players (names, UUIDs, @a/@p/@r/@s) ### 📊 Changes **14 files changed** (+995 additions, -188 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/advancements.rs` (+21 -11) 📝 `crates/horizon-client/src/game/commands.rs` (+187 -92) 📝 `crates/horizon-client/src/game/commands/data.rs` (+5 -0) 📝 `crates/horizon-client/src/game/commands/effects.rs` (+20 -15) 📝 `crates/horizon-client/src/game/commands/execute.rs` (+8 -3) ➕ `crates/horizon-client/src/game/commands/players.rs` (+210 -0) 📝 `crates/horizon-client/src/game/dedicated.rs` (+1 -0) 📝 `crates/horizon-client/src/game/lan.rs` (+14 -1) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+272 -64) 📝 `crates/horizon-client/src/game/scoreboard.rs` (+2 -1) 📝 `crates/horizon-client/src/lan/hub.rs` (+10 -0) 📝 `crates/horizon-client/src/text.rs` (+6 -0) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/LocatorBarClient.java` (+40 -1) ➕ `tools/test_server_player_targets_parity.py` (+199 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What Commands on a dedicated server (and a hosted world) can now target the other players, from the console, an operator or a command block, as vanilla's `EntitySelector.findPlayers` / `EntityArgument` do: - **Targets:** names (any case), UUIDs, `@a`, `@p`, `@r`, `@e`/`@n` (skipping the dead), `@s` under `execute as`, in join order, limited to the source's level when the selector names a place (`x/y/z`, `distance`, `dx…`), with `level=` and `gamemode=` read from each player. - **Commands:** `give` (drops and pickup sound at the receiving player), `gamemode` (the target is told `gameMode.changed`), `tp` (to a place, to a player with their rotation, with a rotation; into another level by `execute in`, the console's Overworld or a destination in another level), `kill` (vanilla's death message to everyone), `effect give` / `effect clear`, and `data`/`nbt=` on a player. `execute as|at|positioned as|rotated as|facing entity` read the other player's position, rotation and eye height. - **How:** every guest other than the one in place is `Target::Guest(conn)` (new `game/commands/players.rs`). What a command does to them runs with their state swapped in (`for_player`), in their level, as their own turn, and what it tells them goes to their chat. For that, `as_guest` splits into `enter_guest` / `leave_guest` (same behaviour, and turns can nest), and a guest's commands are queued per packet and run with the hub back in `self.lan` so they reach the other players. Side effect: an operator's `/kick` now works (it failed with `commands.kick.singleplayer.failed`). - **Vanilla's feedback shape:** player names are `Player.getDisplayName` (hover, click, insertion), item names `ItemStack.getDisplayName` (translated name, rarity colour, `show_item` hover), advancement names `Advancement.decorateName`; the console's source has no entity (`[Server: …]`) and sits at the corner of the spawn block; effects an operator gives leave with the command (600 ticks, not 599). Contributor PR #800 (single-player `execute in` dimension switch, draft) is untouched: this builds on main's server-side `execute in` path, not on the single-player one. ## Not in this PR - The locator bar across levels: filed as #843 (main's waypoints ignore levels); the new harness leaves waypoint lines out, like the dimension harness. - What a guest's death does besides its messages (drops, the body leaving the others' view, inventory cleared): the harness compares only the messages at `/kill`. - A guest's command can't target the LAN host's own player (swapped out during the guest's turn), and tags (`tag=`) of other players aren't read yet. ## How tested New harness `tools/test_server_player_targets_parity.py`: vanilla and Horizon dedicated servers, LocatorBarClient (now also recording game mode events, teleports, inventory slots, effects and deaths with `state on`) as Alice and Bob, 27 steps from the console and an operator. Each player's lines per step compared exactly (sorted within a step). ``` cargo fmt --all -- --check ok cargo clippy --workspace --all-targets -- -D warnings ok (after rebase on 4b43242a) cargo test -p horizon-client ok (860 + 67 + … passed) test_server_player_targets_parity server player targets: 109 lines identical test_server_ops_feedback_parity 17 chat lines identical test_server_dimension_players_parity 22 lines identical test_secure_chat_parity transcripts and chat log lines identical test_lan_parity 462 cases match test_dedicated_server_parity 591 transcript lines identical test_command_exec_parity ok test_command_parse_parity ok ``` `tools/parity.py --changed` was skipped (it selects nearly all 299 harnesses since almost everything links horizon-client); CI parity covers the rest. ## 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:59:36 +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#2854
No description provided.