[PR #4252] [MERGED] Item names in command feedback follow the item_name component #5518

Closed
opened 2026-11-03 05:13:08 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4252
Author: @CocofireHD
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @levzzz5154

Base: main ← Head: fix/item-name-display-name


📝 Commits (1)

  • 03c8dd0 Item names in command feedback follow the item_name component

📊 Changes

2 files changed (+6 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/game/commands.rs (+5 -0)
📝 tools/command_exec_corpus.py (+1 -0)

📄 Description

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

What and why

/give — and every command that names a stack — reported a renamed item under its plain item name when the rename is the minecraft:item_name component:

/give @s minecraft:diamond[minecraft:item_name={text:"ItemName",color:"red"}]
Horizon:  Gave 1 [Diamond] to …
vanilla:  Gave 1 [ItemName] to Coco

The tooltip of that same stack already shows "ItemName" in red in Horizon, so the item is right and only its name in command feedback is wrong.

ItemStack.getDisplayName appends getHoverName, which is the custom_name component or getItemName; getItemName prefers the minecraft:item_name component over Item.getName. Game::stack_display_name read only custom_name, so the component never reached the feedback text (nor the chat item links and death messages built from that name). This reads it first, in vanilla's order, and keeps the component's styles: the message now carries {"extra":[{"color":"red","text":"ItemName"}],"text":""} inside the brackets, which stay in the rarity colour as before.

This turned up while verifying #3770. That report (styled custom_name in tooltips) is already fixed on main by #3341 — checked in a running build, single player and against a real 26.3 server: custom_name in gold/bold/italic, legacy § codes, colours inherited from the root into extra, hex colours and item_name all render correctly. This PR is the one gap the same check found, so it does not close that issue.

Kind

  • parity: Horizon now does what vanilla 26.3 does

Vanilla reference

ItemStack.getDisplayName, ItemStack.getHoverName, ItemStack.getItemName and Item.getName; GiveCommand's commands.give.success.single message. Harness: tools/test_command_exec_parity.py, with one case added to tools/command_exec_corpus.py. The expected text is what vanilla 26.3's own server prints for that command (Gave 1 [ItemName] to Coco).

Self-check

**pr_ready** (`tools/pr_ready.py --quick` on DESKTOP-9IR5DCN, against origin/main at 68f036059, 4 min 37 s)

| Check | Result |
| --- | --- |
| Scope | ✅ 2 files, +6 −0 |
| Cargo.lock | ✅ unchanged |
| Public tree | ✅ |
| Python tests | ✅ 480 passed (1 min 4 s) |
| rustfmt | ✅ (7 s) |
| clippy | ✅ (47 s) |
| tests: horizon-client | ❌ 726 passed, 1 failed (2 min 34 s) |
| doc tests | ✅ 0 passed (2 s) |
| content root tests | ➖ content root untouched |
| tokens.css up to date | ➖ theme untouched |
| launcher rustfmt / clippy / tests | ➖ launcher untouched |
| Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses |

The one failure is title::tests::each_world_preset_writes_its_own_generator, which fails the same way on unmodified origin/main on this Windows machine (checked by stashing this change), so it is not from this PR.

Screenshots

Nothing visual: before Gave 1 [Diamond] to …, after Gave 1 [ItemName] to …, with the component's red kept on the name inside the brackets.


🔄 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/4252 **Author:** [@CocofireHD](https://github.com/CocofireHD) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix/item-name-display-name` --- ### 📝 Commits (1) - [`03c8dd0`](https://github.com/horizon-rust/horizon/commit/03c8dd0d9871399da255a334e7cdaebe6586e32e) Item names in command feedback follow the item_name component ### 📊 Changes **2 files changed** (+6 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/commands.rs` (+5 -0) 📝 `tools/command_exec_corpus.py` (+1 -0) </details> ### 📄 Description > 🤖 Opened by CocofireHD's AI agent (Hermes Agent, deepseek-v4.1-flash), not by CocofireHD personally. ## What and why `/give` — and every command that names a stack — reported a renamed item under its plain item name when the rename is the `minecraft:item_name` component: ``` /give @s minecraft:diamond[minecraft:item_name={text:"ItemName",color:"red"}] Horizon: Gave 1 [Diamond] to … vanilla: Gave 1 [ItemName] to Coco ``` The tooltip of that same stack already shows "ItemName" in red in Horizon, so the item is right and only its name in command feedback is wrong. `ItemStack.getDisplayName` appends `getHoverName`, which is the `custom_name` component or `getItemName`; `getItemName` prefers the `minecraft:item_name` component over `Item.getName`. `Game::stack_display_name` read only `custom_name`, so the component never reached the feedback text (nor the chat item links and death messages built from that name). This reads it first, in vanilla's order, and keeps the component's styles: the message now carries `{"extra":[{"color":"red","text":"ItemName"}],"text":""}` inside the brackets, which stay in the rarity colour as before. This turned up while verifying #3770. That report (styled `custom_name` in tooltips) is already fixed on main by #3341 — checked in a running build, single player and against a real 26.3 server: `custom_name` in gold/bold/italic, legacy `§` codes, colours inherited from the root into `extra`, hex colours and `item_name` all render correctly. This PR is the one gap the same check found, so it does not close that issue. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does ## Vanilla reference `ItemStack.getDisplayName`, `ItemStack.getHoverName`, `ItemStack.getItemName` and `Item.getName`; `GiveCommand`'s `commands.give.success.single` message. Harness: `tools/test_command_exec_parity.py`, with one case added to `tools/command_exec_corpus.py`. The expected text is what vanilla 26.3's own server prints for that command (`Gave 1 [ItemName] to Coco`). ## Self-check ``` **pr_ready** (`tools/pr_ready.py --quick` on DESKTOP-9IR5DCN, against origin/main at 68f036059, 4 min 37 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +6 −0 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 480 passed (1 min 4 s) | | rustfmt | ✅ (7 s) | | clippy | ✅ (47 s) | | tests: horizon-client | ❌ 726 passed, 1 failed (2 min 34 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt / clippy / tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | ``` The one failure is `title::tests::each_world_preset_writes_its_own_generator`, which fails the same way on unmodified `origin/main` on this Windows machine (checked by stashing this change), so it is not from this PR. ## Screenshots Nothing visual: before `Gave 1 [Diamond] to …`, after `Gave 1 [ItemName] to …`, with the component's red kept on the name inside the brackets. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:13:08 +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#5518
No description provided.