[PR #6361] [MERGED] Tags: a primed TNT can be tagged #6826

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6361
Author: @CocofireHD
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: fix/tnt-tags


📝 Commits (1)

  • ae5d7c7 Tags: a primed TNT can be tagged

📊 Changes

1 file changed (+3 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/game/commands/data.rs (+3 -0)

📄 Description

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

Fixes #6353.

What was wrong

tags_of (game/scoreboard.rs:209) reads a target's Tags out of persist.raw for eight kinds; raw_mut (game/commands/data.rs:280), the only writer and reached from set_entity_tags, spelled seven of them. Target::Tnt fell through to _ => None, so set_entity_tags returned without touching anything while /tag still reported success:

// tags_of, before — reads a primed TNT's compound
Target::Mob(id) | … | Target::Cart(id) | Target::Tnt(id) | Target::Other(id)
    => self.persist.raw.get(&id),

// raw_mut, before — no Tnt arm, so `_ => None`
Target::Mob(id) | … | Target::Cart(id) | Target::Other(id)
    => Some(self.persist.raw.entry(id).or_insert_with(empty)),
_ => None,

Vanilla has no such split — TagCommand writes through the entity itself, whichever type the selector produced:

91:  private static int addTag(CommandSourceStack, Collection<? extends Entity>, String)
109:   40: invokevirtual Entity.addTag:(Ljava/lang/String;)Z
120: private static int removeTag(CommandSourceStack, Collection<? extends Entity>, String)
138:   40: invokevirtual Entity.removeTag:(Ljava/lang/String;)Z

(javap -p -c net.minecraft.server.commands.TagCommand, pinned 26.3 jar.)

What changes

Target::Tnt(id) joins raw_mut's persist.raw arm, so a primed TNT reads and writes the same compound. Three lines, one of them the arm.

Verification

Same world and build, before and after (cargo build --profile fast -p horizon-client, horizon-ctl):

command before after
summon minecraft:tnt ~ ~2 ~ {Tags:["seeded"],fuse:1200s} Summoned new Primed TNT same
tag @e[type=minecraft:tnt,limit=1] list Primed TNT has 1 tag(s): seeded same
tag … add boom Added tag 'boom' to Primed TNT same
tag … list after the add 1 tag(s): seeded 2 tag(s): boom, seeded
tag … remove seeded Removed tag 'seeded' from Primed TNT same
tag … list after the remove 1 tag(s): seeded 1 tag(s): boom
execute if entity @e[type=minecraft:tnt,tag=boom] — Test passed. Count: 1

cargo fmt --all -- --check clean; cargo clippy -p horizon-client --all-targets -- -D warnings and the same with --no-default-features both report nothing.

Not done

No automated case. raw_mut is &mut self on Game and the tag path needs a live server player or a tracked entity, so there is no fixture to call it from a unit test; the command harness (game/command_harness.rs) is where a summon tnt + tag … add + tag … list case belongs, and I did not add one here. Say the word and I will do it in this PR rather than a follow-up.

One more of the same shape is left and is not in this diff: Target::Falling has a tags_of arm (self.falling) but no raw_mut arm. /tag on a falling block did not even resolve a target in my run (tag @e[type=minecraft:falling_block,limit=1] list answered "There are no tags on the 0 entities" while execute if entity @e[type=minecraft:falling_block] said Count: 1), so I did not touch it blind.

🤖 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/6361 **Author:** [@CocofireHD](https://github.com/CocofireHD) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/tnt-tags` --- ### 📝 Commits (1) - [`ae5d7c7`](https://github.com/horizon-rust/horizon/commit/ae5d7c78aed722f876f9c313479419930c3286a8) Tags: a primed TNT can be tagged ### 📊 Changes **1 file changed** (+3 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/commands/data.rs` (+3 -0) </details> ### 📄 Description > 🤖 Opened by CocofireHD's AI agent (Hermes Agent, deepseek-v4.1-flash), not by CocofireHD personally. Fixes #6353. ## What was wrong `tags_of` (`game/scoreboard.rs:209`) reads a target's `Tags` out of `persist.raw` for eight kinds; `raw_mut` (`game/commands/data.rs:280`), the only writer and reached from `set_entity_tags`, spelled seven of them. `Target::Tnt` fell through to `_ => None`, so `set_entity_tags` returned without touching anything while `/tag` still reported success: ```rust // tags_of, before — reads a primed TNT's compound Target::Mob(id) | … | Target::Cart(id) | Target::Tnt(id) | Target::Other(id) => self.persist.raw.get(&id), // raw_mut, before — no Tnt arm, so `_ => None` Target::Mob(id) | … | Target::Cart(id) | Target::Other(id) => Some(self.persist.raw.entry(id).or_insert_with(empty)), _ => None, ``` Vanilla has no such split — `TagCommand` writes through the entity itself, whichever type the selector produced: ``` 91: private static int addTag(CommandSourceStack, Collection<? extends Entity>, String) 109: 40: invokevirtual Entity.addTag:(Ljava/lang/String;)Z 120: private static int removeTag(CommandSourceStack, Collection<? extends Entity>, String) 138: 40: invokevirtual Entity.removeTag:(Ljava/lang/String;)Z ``` (`javap -p -c net.minecraft.server.commands.TagCommand`, pinned 26.3 jar.) ## What changes `Target::Tnt(id)` joins `raw_mut`'s `persist.raw` arm, so a primed TNT reads and writes the same compound. Three lines, one of them the arm. ## Verification Same world and build, before and after (`cargo build --profile fast -p horizon-client`, `horizon-ctl`): | command | before | after | |---|---|---| | `summon minecraft:tnt ~ ~2 ~ {Tags:["seeded"],fuse:1200s}` | `Summoned new Primed TNT` | same | | `tag @e[type=minecraft:tnt,limit=1] list` | `Primed TNT has 1 tag(s): seeded` | same | | `tag … add boom` | `Added tag 'boom' to Primed TNT` | same | | `tag … list` after the add | `1 tag(s): seeded` | `2 tag(s): boom, seeded` | | `tag … remove seeded` | `Removed tag 'seeded' from Primed TNT` | same | | `tag … list` after the remove | `1 tag(s): seeded` | `1 tag(s): boom` | | `execute if entity @e[type=minecraft:tnt,tag=boom]` | — | `Test passed. Count: 1` | `cargo fmt --all -- --check` clean; `cargo clippy -p horizon-client --all-targets -- -D warnings` and the same with `--no-default-features` both report nothing. ## Not done No automated case. `raw_mut` is `&mut self` on `Game` and the tag path needs a live server player or a tracked entity, so there is no fixture to call it from a unit test; the command harness (`game/command_harness.rs`) is where a `summon tnt` + `tag … add` + `tag … list` case belongs, and I did not add one here. Say the word and I will do it in this PR rather than a follow-up. One more of the same shape is left and is *not* in this diff: `Target::Falling` has a `tags_of` arm (`self.falling`) but no `raw_mut` arm. `/tag` on a falling block did not even resolve a target in my run (`tag @e[type=minecraft:falling_block,limit=1] list` answered "There are no tags on the 0 entities" while `execute if entity @e[type=minecraft:falling_block]` said `Count: 1`), so I did not touch it blind. 🤖 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:35 +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#6826
No description provided.