[PR #2068] [MERGED] Model item_name component on items and tooltips #3979

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2068
Author: @lazy-importer
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/26/2026
Merged by: @ludovic111

Base: main ← Head: fix/2039-custom-item-name-tooltip


📝 Commits (2)

  • ad7203f Model item_name component on items and tooltips
  • d983ef8 Keep item_name as its component: translate it when drawn

📊 Changes

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

View changed files

📝 crates/horizon-client/src/game/stations.rs (+5 -1)
📝 crates/horizon-client/src/item_data.rs (+8 -0)
📝 crates/horizon-client/src/item_sync.rs (+6 -0)
📝 crates/horizon-client/src/item_tooltip.rs (+11 -0)
📝 crates/horizon-client/src/lan/guest.rs (+7 -0)
📝 crates/horizon-client/src/stations.rs (+3 -1)

📄 Description

🤖 Opened by lazy-importer's AI agent (Claude), not by lazy-importer himself.

Fixes #2039.

What changed

In modern Minecraft (1.20.5+), servers and datapacks customize base item names using the minecraft:item_name data component rather than minecraft:custom_name (which is styled in italics and reserved for anvil renames).

Vanilla's name resolution in ItemStack.getHoverName() works as:

public Component getHoverName() {
    Component customName = getCustomName();
    if (customName != null) {
        return customName;
    }
    return getItemName();
}

where getItemName() retrieves DataComponents.ITEM_NAME if present, falling back to the item prototype / translation.

Previously, Horizon did not model item_name in StackData (item_data.rs), causing items configured with custom base names by servers or resource packs to fall back to their internal/default names.

This change:

  1. Adds item_name: Option<String> to StackData and accesseur ItemStack::item_name().
  2. Decodes minecraft:item_name in decode_components and encodes it in components_tag and network stack_to_network.
  3. Checks item_name() in item_tooltip::name_line, stations::hover_name, and container / inventory tooltips in accordance with vanilla's getHoverName().
  4. Adds tests for round-tripping and tooltip formatting with item_name.

Self-check

  • Code formatted with cargo fmt
  • Clippy clean (cargo clippy -p horizon-client --lib -- -D warnings)
  • Unit tests pass (cargo test -p horizon-client --lib item_data, item_sync, item_tooltip)
  • Tested with isolated temp homes (HORIZON_HOME, HORIZON_LAUNCHER_HOME)

🤖 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/2068 **Author:** [@lazy-importer](https://github.com/lazy-importer) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/2039-custom-item-name-tooltip` --- ### 📝 Commits (2) - [`ad7203f`](https://github.com/horizon-rust/horizon/commit/ad7203fc8ad8386fbe7b0bc29e73880b360e4174) Model item_name component on items and tooltips - [`d983ef8`](https://github.com/horizon-rust/horizon/commit/d983ef89b4ebdf9b92c38be6e940118445377a62) Keep item_name as its component: translate it when drawn ### 📊 Changes **6 files changed** (+40 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/stations.rs` (+5 -1) 📝 `crates/horizon-client/src/item_data.rs` (+8 -0) 📝 `crates/horizon-client/src/item_sync.rs` (+6 -0) 📝 `crates/horizon-client/src/item_tooltip.rs` (+11 -0) 📝 `crates/horizon-client/src/lan/guest.rs` (+7 -0) 📝 `crates/horizon-client/src/stations.rs` (+3 -1) </details> ### 📄 Description > 🤖 Opened by lazy-importer's AI agent (Claude), not by lazy-importer himself. Fixes #2039. ### What changed In modern Minecraft (1.20.5+), servers and datapacks customize base item names using the `minecraft:item_name` data component rather than `minecraft:custom_name` (which is styled in italics and reserved for anvil renames). Vanilla's name resolution in `ItemStack.getHoverName()` works as: ```java public Component getHoverName() { Component customName = getCustomName(); if (customName != null) { return customName; } return getItemName(); } ``` where `getItemName()` retrieves `DataComponents.ITEM_NAME` if present, falling back to the item prototype / translation. Previously, Horizon did not model `item_name` in `StackData` (`item_data.rs`), causing items configured with custom base names by servers or resource packs to fall back to their internal/default names. This change: 1. Adds `item_name: Option<String>` to `StackData` and accesseur `ItemStack::item_name()`. 2. Decodes `minecraft:item_name` in `decode_components` and encodes it in `components_tag` and network `stack_to_network`. 3. Checks `item_name()` in `item_tooltip::name_line`, `stations::hover_name`, and container / inventory tooltips in accordance with vanilla's `getHoverName()`. 4. Adds tests for round-tripping and tooltip formatting with `item_name`. ### Self-check - [x] Code formatted with `cargo fmt` - [x] Clippy clean (`cargo clippy -p horizon-client --lib -- -D warnings`) - [x] Unit tests pass (`cargo test -p horizon-client --lib item_data`, `item_sync`, `item_tooltip`) - [x] Tested with isolated temp homes (`HORIZON_HOME`, `HORIZON_LAUNCHER_HOME`) 🤖 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 04:13:44 +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#3979
No description provided.