[PR #6333] [CLOSED] Guests: read and write /tag tags on the guest's player record #6804

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6333
Author: @CocofireHD
Created: 11/1/2026
Status: ❌ Closed

Base: main ← Head: fix/guest-tags


📝 Commits (1)

  • cec07b8 Guests: read and write /tag tags on the guest's player record

📊 Changes

2 files changed (+10 additions, -5 deletions)

View changed files

📝 crates/horizon-client/src/game/commands/data.rs (+8 -0)
📝 crates/horizon-client/src/game/scoreboard.rs (+2 -5)

📄 Description

🤖 Opened by CocofireHD's AI agent (Hermes Agent, deepseek-v4.1-flash), not by CocofireHD personally.

Fixes #6255.

What was wrong

Two helpers decide what a target's Tags list is, and neither had a guest arm:

  • game/scoreboard.rs tags_of: Target::Guest(_) => None — every tag= test in selector_extra_filter therefore saw an empty list, so @a[tag=…] matched nobody.
  • game/commands/data.rs raw_mut: no Target::Guest arm, so set_entity_tags wrote nothing while /tag <guest> add still reported Added tag 'casino' to Bee.

It is the same asymmetry as Target::Player, which reads level.player_extra instead of entity NBT: vanilla's ServerPlayer.getTags is the player's own record (Entity.getTags is the Tags list of the saved entity, and players save it in their player file, not as a world entity).

What changes

  • raw_mut gains Target::Guest(conn) => … guest_mut(conn).map(|g| g.saved.get_or_insert_with(empty)). Guest.saved is documented as "the compound this player was loaded from, for fields Horizon does not model", and playerdata::store writes it back as player_extra, so a tag added there is saved with the player file.
  • tags_of gains the matching read arm: Target::Guest(conn) => command_guest(conn).and_then(|g| g.saved.as_ref()).
  • set_entity_tags needs no special case any more; it goes through raw_mut like a mob.

Two lines of real logic; the rest is the arm that was missing.

Verification

LAN pair, one host (--creative, name HostX) and one guest started with --server 127.0.0.1:25599 (name Bee), commands run on the host through horizon-ctl command:

command before after
tag Bee add casino Added tag 'casino' to Bee Added tag 'casino' to Bee
tag Bee list There are no tags on the 0 entities Bee has 1 tag(s): casino
execute if entity @a[tag=casino] Test failed Test passed. Count: 1
execute as @a[tag=casino] run say i-am-tagged nothing [Bee] i-am-tagged
tag Bee remove casino Target does not have this tag Removed tag 'casino' from Bee
execute if entity @a[tag=casino] after remove Test failed Test failed

Rejoin: after tag Bee add casino, the guest quits and rejoins — execute if entity @a[tag=casino] → Test passed. Count: 1 and tag Bee list → Bee has 1 tag(s): casino, i.e. the tag rides in the player file as it does in vanilla.

cargo check -p horizon-client --all-targets clean; cargo fmt/clippy -D warnings for the crate will be confirmed by CI (verify), which I cannot trigger with the parity workflows on a fork.

Not covered: no automated test. tests/lan_bot.rs starts a host and connects bots but has no command helper for selectors, and there is no Game fixture that builds a guest — happy to add a lan_bot case for @a[tag=…] if you prefer that in the same PR rather than the manual run above.

🤖 Generated with Hermes Agent


🔄 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/6333 **Author:** [@CocofireHD](https://github.com/CocofireHD) **Created:** 11/1/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/guest-tags` --- ### 📝 Commits (1) - [`cec07b8`](https://github.com/horizon-rust/horizon/commit/cec07b897ab3c2430452dd21f5e55590577f73e1) Guests: read and write /tag tags on the guest's player record ### 📊 Changes **2 files changed** (+10 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/commands/data.rs` (+8 -0) 📝 `crates/horizon-client/src/game/scoreboard.rs` (+2 -5) </details> ### 📄 Description > 🤖 Opened by CocofireHD's AI agent (Hermes Agent, deepseek-v4.1-flash), not by CocofireHD personally. Fixes #6255. ## What was wrong Two helpers decide what a target's `Tags` list is, and neither had a guest arm: - `game/scoreboard.rs` `tags_of`: `Target::Guest(_) => None` — every `tag=` test in `selector_extra_filter` therefore saw an empty list, so `@a[tag=…]` matched nobody. - `game/commands/data.rs` `raw_mut`: no `Target::Guest` arm, so `set_entity_tags` wrote nothing while `/tag <guest> add` still reported `Added tag 'casino' to Bee`. It is the same asymmetry as `Target::Player`, which reads `level.player_extra` instead of entity NBT: vanilla's `ServerPlayer.getTags` is the player's own record (`Entity.getTags` is the `Tags` list of the saved entity, and players save it in their player file, not as a world entity). ## What changes - `raw_mut` gains `Target::Guest(conn) => … guest_mut(conn).map(|g| g.saved.get_or_insert_with(empty))`. `Guest.saved` is documented as "the compound this player was loaded from, for fields Horizon does not model", and `playerdata::store` writes it back as `player_extra`, so a tag added there is saved with the player file. - `tags_of` gains the matching read arm: `Target::Guest(conn) => command_guest(conn).and_then(|g| g.saved.as_ref())`. - `set_entity_tags` needs no special case any more; it goes through `raw_mut` like a mob. Two lines of real logic; the rest is the arm that was missing. ## Verification LAN pair, one host (`--creative`, name `HostX`) and one guest started with `--server 127.0.0.1:25599` (name `Bee`), commands run on the host through `horizon-ctl command`: | command | before | after | |---|---|---| | `tag Bee add casino` | `Added tag 'casino' to Bee` | `Added tag 'casino' to Bee` | | `tag Bee list` | `There are no tags on the 0 entities` | `Bee has 1 tag(s): casino` | | `execute if entity @a[tag=casino]` | `Test failed` | `Test passed. Count: 1` | | `execute as @a[tag=casino] run say i-am-tagged` | nothing | `[Bee] i-am-tagged` | | `tag Bee remove casino` | `Target does not have this tag` | `Removed tag 'casino' from Bee` | | `execute if entity @a[tag=casino]` after remove | `Test failed` | `Test failed` | Rejoin: after `tag Bee add casino`, the guest quits and rejoins — `execute if entity @a[tag=casino]` → `Test passed. Count: 1` and `tag Bee list` → `Bee has 1 tag(s): casino`, i.e. the tag rides in the player file as it does in vanilla. `cargo check -p horizon-client --all-targets` clean; `cargo fmt`/`clippy -D warnings` for the crate will be confirmed by CI (`verify`), which I cannot trigger with the parity workflows on a fork. Not covered: no automated test. `tests/lan_bot.rs` starts a host and connects bots but has no command helper for selectors, and there is no `Game` fixture that builds a guest — happy to add a `lan_bot` case for `@a[tag=…]` if you prefer that in the same PR rather than the manual run above. 🤖 Generated with [Hermes Agent](https://hermes-agent.nousresearch.com) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:27:14 +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#6804
No description provided.