[PR #6434] [CLOSED] Read the rarity component for an item's name colour #6869

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

📋 Pull Request Information

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

Base: main ← Head: fix/item-rarity-component


📝 Commits (1)

  • de26874 Read the rarity component for an item's name colour

📊 Changes

3 files changed (+67 additions, -11 deletions)

View changed files

📝 crates/horizon-client/src/game/stations.rs (+1 -1)
📝 crates/horizon-client/src/game/titles.rs (+1 -1)
📝 crates/horizon-client/src/item_tooltip.rs (+65 -9)

📄 Description

ItemStack.getRarity starts from the stack's own component:

// javap -p -c on ItemStack
 1: getstatic   DataComponents.RARITY
 4: getstatic   Rarity.COMMON
 7: invokevirtual getOrDefault        // the item's own rarity is its default component
14: invokevirtual isEnchanted
18: ifne 23 ... areturn               // not enchanted: the rarity as it is
23-69: COMMON/UNCOMMON -> RARE, RARE -> EPIC, else unchanged

Horizon's item_tooltip::rarity took the item type's default rarity and applied the
enchantment bump, but never looked at the stack's minecraft:rarity component, which the
component decoder does keep (commands::cmd_give -> decode_components puts it in
components.other). A stick given with rarity=epic,enchantments={aqua_affinity:1} therefore
came out rare - the aqua name instead of the light purple one the report shows.

Proven: on the build VM, cargo test -q -p horizon-client-lib --lib item_tooltip
-> 17 passed; 1 ignored, including the new a_stack_rarity_component_sets_the_name_rarity:
epic from the component, epic stays epic when enchanted, common is raised to rare by
enchantments, the component beats the item default, and no component falls back to the item's
own rarity.

Not proven: not checked in game; the check is the report's own /give and looking at the
name colour (light purple for epic).

About the other half of the report: the lore component already works on current main. A probe
decoding the report's exact component string keeps minecraft:lore in components.other,
item_tooltip::lore_texts returns "Simple Custom Lore" with the dark purple italic base, and
stations.rs::stack_tooltip_lines pushes it under display.shows("minecraft:lore"). The
nightly in the report is from before that path existed, so nothing is changed for lore here.


🔄 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/6434 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/1/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/item-rarity-component` --- ### 📝 Commits (1) - [`de26874`](https://github.com/horizon-rust/horizon/commit/de2687496ae5a88d6ba257ab066ac7810947d0f9) Read the rarity component for an item's name colour ### 📊 Changes **3 files changed** (+67 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/stations.rs` (+1 -1) 📝 `crates/horizon-client/src/game/titles.rs` (+1 -1) 📝 `crates/horizon-client/src/item_tooltip.rs` (+65 -9) </details> ### 📄 Description `ItemStack.getRarity` starts from the stack's own component: ```java // javap -p -c on ItemStack 1: getstatic DataComponents.RARITY 4: getstatic Rarity.COMMON 7: invokevirtual getOrDefault // the item's own rarity is its default component 14: invokevirtual isEnchanted 18: ifne 23 ... areturn // not enchanted: the rarity as it is 23-69: COMMON/UNCOMMON -> RARE, RARE -> EPIC, else unchanged ``` Horizon's `item_tooltip::rarity` took the item type's default rarity and applied the enchantment bump, but never looked at the stack's `minecraft:rarity` component, which the component decoder does keep (`commands::cmd_give` -> `decode_components` puts it in `components.other`). A stick given with `rarity=epic,enchantments={aqua_affinity:1}` therefore came out `rare` - the aqua name instead of the light purple one the report shows. **Proven:** on the build VM, `cargo test -q -p horizon-client-lib --lib item_tooltip` -> `17 passed; 1 ignored`, including the new `a_stack_rarity_component_sets_the_name_rarity`: `epic` from the component, `epic` stays `epic` when enchanted, `common` is raised to `rare` by enchantments, the component beats the item default, and no component falls back to the item's own rarity. **Not proven:** not checked in game; the check is the report's own `/give` and looking at the name colour (light purple for epic). About the other half of the report: the `lore` component already works on current main. A probe decoding the report's exact component string keeps `minecraft:lore` in `components.other`, `item_tooltip::lore_texts` returns "Simple Custom Lore" with the dark purple italic base, and `stations.rs::stack_tooltip_lines` pushes it under `display.shows("minecraft:lore")`. The nightly in the report is from before that path existed, so nothing is changed for lore here. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:28: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#6869
No description provided.