[PR #3447] [MERGED] Item names: translate items outside the minecraft namespace #4986

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

📋 Pull Request Information

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

Base: main ← Head: fix-3396


📝 Commits (1)

  • 01f3d91 Item names: translate items outside the minecraft namespace

📊 Changes

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

View changed files

📝 crates/horizon-client/src/item_tooltip.rs (+28 -3)

📄 Description

🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves.

What and why

Fixes #3396

A content mod's item showed its raw id above the hotbar: ruby:ruby instead of "Ruby".

item_tooltip::name_line stripped only a minecraft: prefix, then looked up item.minecraft.<path> and block.minecraft.<path>. For ruby:ruby the path stayed ruby:ruby, no key matched, and the fallback (the path with spaces) gave ruby:ruby. The same function names stacks for the recipe book and creative searches, so those matched the raw id too. Tooltips and chat already showed the right name because stack_hover_name and stack_display_name split the namespace.

The keys are now those of Util.makeDescriptionId, in the item's own namespace, with / turned into .: item.<namespace>.<path>, then the block's key for a block item. Without a translation the name falls back to the path with spaces, as creative::Names::item does. Names of minecraft: items are unchanged.

Vanilla reference

  • Item.getDescriptionId returns the descriptionId that Item.Properties sets from ITEM_DESCRIPTION_ID, or from BLOCK_DESCRIPTION_ID for a block item (useBlockDescriptionPrefix).
  • Util.makeDescriptionId(String, Identifier): type + "." + id.getNamespace() + "." + id.getPath().replace('/', '.').

Read with javap -c on the 26.3 client jar. The tooltip harnesses that cover item_tooltip.rs (tooltip_display, lore_tooltip, firework_tooltip) use vanilla items only, so this change does not alter what they compare. They didn't run here: there is no prepared .local/horizon-client on this machine, and tools/parity.py stops on Windows at signal.SIGHUP. The new unit test item_tooltip::tests::name_line_translates_items_of_any_namespace fails on main (left: "example:ruby", right: "Ruby") and passes here.

Self-check

Run on Windows 11 (tools/pr_ready.py stops on Windows at signal.SIGHUP, so the steps were run by hand):

cargo fmt --all -- --check                                                      ok
cargo clippy -p horizon-client --features mods --all-targets -- -D warnings     ok
cargo test -p horizon-client --lib -- --skip gfx::                              1016 passed, 1 failed, 26 ignored
cargo test -p horizon-client --bin horizon-client spill                          1 passed
python tools/check_public_tree.py                                               passed

The one failure is save::tests::session_lock_is_exclusive, which also fails on main on Windows. gfx:: was skipped: its GPU tests hang or crash on this machine, and this change doesn't touch gfx.

Screenshots

A folder content mod loaded with --dev-mod: ruby:ruby ({"template": "minecraft:diamond"}, the emerald model, "item.ruby.ruby": "Ruby" in assets/ruby/lang/en_us.json), given with /give @s ruby:ruby and selected.

Before (main, 142388e1c): "ruby:ruby" above the hotbar.

name 3396 before

After: "Ruby".

name 3396 after

🤖 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/3447 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix-3396` --- ### 📝 Commits (1) - [`01f3d91`](https://github.com/horizon-rust/horizon/commit/01f3d91d04b9affb481bd106c0458279e0348153) Item names: translate items outside the minecraft namespace ### 📊 Changes **1 file changed** (+28 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/item_tooltip.rs` (+28 -3) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why Fixes #3396 A content mod's item showed its raw id above the hotbar: `ruby:ruby` instead of "Ruby". `item_tooltip::name_line` stripped only a `minecraft:` prefix, then looked up `item.minecraft.<path>` and `block.minecraft.<path>`. For `ruby:ruby` the path stayed `ruby:ruby`, no key matched, and the fallback (the path with spaces) gave `ruby:ruby`. The same function names stacks for the recipe book and creative searches, so those matched the raw id too. Tooltips and chat already showed the right name because `stack_hover_name` and `stack_display_name` split the namespace. The keys are now those of `Util.makeDescriptionId`, in the item's own namespace, with `/` turned into `.`: `item.<namespace>.<path>`, then the block's key for a block item. Without a translation the name falls back to the path with spaces, as `creative::Names::item` does. Names of `minecraft:` items are unchanged. ## Vanilla reference - `Item.getDescriptionId` returns the `descriptionId` that `Item.Properties` sets from `ITEM_DESCRIPTION_ID`, or from `BLOCK_DESCRIPTION_ID` for a block item (`useBlockDescriptionPrefix`). - `Util.makeDescriptionId(String, Identifier)`: `type + "." + id.getNamespace() + "." + id.getPath().replace('/', '.')`. Read with `javap -c` on the 26.3 client jar. The tooltip harnesses that cover `item_tooltip.rs` (`tooltip_display`, `lore_tooltip`, `firework_tooltip`) use vanilla items only, so this change does not alter what they compare. They didn't run here: there is no prepared `.local/horizon-client` on this machine, and `tools/parity.py` stops on Windows at `signal.SIGHUP`. The new unit test `item_tooltip::tests::name_line_translates_items_of_any_namespace` fails on main (`left: "example:ruby"`, `right: "Ruby"`) and passes here. ## Self-check Run on Windows 11 (`tools/pr_ready.py` stops on Windows at `signal.SIGHUP`, so the steps were run by hand): ``` cargo fmt --all -- --check ok cargo clippy -p horizon-client --features mods --all-targets -- -D warnings ok cargo test -p horizon-client --lib -- --skip gfx:: 1016 passed, 1 failed, 26 ignored cargo test -p horizon-client --bin horizon-client spill 1 passed python tools/check_public_tree.py passed ``` The one failure is `save::tests::session_lock_is_exclusive`, which also fails on main on Windows. `gfx::` was skipped: its GPU tests hang or crash on this machine, and this change doesn't touch `gfx`. ## Screenshots A folder content mod loaded with `--dev-mod`: `ruby:ruby` (`{"template": "minecraft:diamond"}`, the emerald model, `"item.ruby.ruby": "Ruby"` in `assets/ruby/lang/en_us.json`), given with `/give @s ruby:ruby` and selected. Before (main, 142388e1c): "ruby:ruby" above the hotbar. ![name 3396 before](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/name-3396-before.png) After: "Ruby". ![name 3396 after](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/name-3396-after.png) 🤖 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-03 05:09:24 +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#4986
No description provided.