[PR #481] [MERGED] Item tooltips for container contents, spawner data and op-only data #2596

Closed
opened 2026-11-02 15:57:30 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/block-entity-data-tooltips


📝 Commits (2)

  • bd42496 Ctrl + Pick Block copies the block entity's data in creative
  • ac4ed86 Item tooltips for container contents, spawner data and op-only data

📊 Changes

16 files changed (+1132 additions, -74 deletions)

View changed files

➕ crates/horizon-client/examples/pick_block_data_fixture.rs (+96 -0)
➕ crates/horizon-client/src/block_entity_item.rs (+485 -0)
📝 crates/horizon-client/src/block_entity_nbt.rs (+1 -1)
📝 crates/horizon-client/src/command/item.rs (+50 -0)
📝 crates/horizon-client/src/game.rs (+20 -23)
📝 crates/horizon-client/src/game/banners.rs (+0 -14)
➕ crates/horizon-client/src/game/block_items.rs (+117 -0)
📝 crates/horizon-client/src/game/command_blocks.rs (+5 -4)
📝 crates/horizon-client/src/game/dispenser.rs (+1 -2)
📝 crates/horizon-client/src/game/remote.rs (+1 -1)
📝 crates/horizon-client/src/game/stations.rs (+47 -1)
📝 crates/horizon-client/src/game/storage.rs (+0 -28)
📝 crates/horizon-client/src/item_tooltip.rs (+64 -0)
📝 crates/horizon-client/src/lib.rs (+1 -0)
➕ mods/horizon/src/test/java/dev/horizonlab/parity/VanillaPickBlockDataOracle.java (+91 -0)
➕ tools/test_pick_block_data_parity.py (+153 -0)

📄 Description

Part of #386. Stacked on #479; merge that one first.

What

These are the tooltip lines vanilla 26.3 shows for the components Ctrl + Pick Block (and /give) put on items:

  • Container contents (ItemContainerContents.addToTooltip): the first five stacks as 5 x Diamond, then and N more.... Shulker boxes now list their contents too, as in vanilla.
  • Spawners and trial spawners (Spawner.appendHoverText, called from ItemStack.addDetailsToTooltip): the entity named by block_entity_data.SpawnData.entity.id (gray). Without one: a blank line, then "Interact with Spawn Egg:" (gray) and " Sets Mob Type" (blue).
  • Op warning (BlockItem.shouldPrintOpWarning, ItemStack.OP_NBT_WARNING): with game master permission, an item holding data of an op-only type (command blocks, lecterns, signs, hanging signs, spawners, trial spawners) gets the three red item.op_warning lines.
  • Item argument: block_entity_data without an id, or with an unknown block entity type, is malformed, with TypedEntityData.codec's messages: Expected 'id' field in {...} and Unknown registry key in ResourceKey[minecraft:root / minecraft:block_entity_type]: ....

The lang keys are the 26.3 ones (item.container.item_count, item.container.more_items, item.op_warning.line1-3). Horizon's lang loader maps them from the old keys through deprecated.json.

Proof

  • Unit tests:
    • item_tooltip::container_lines (five lines, then the remainder)
    • block_entity_item::spawner_entity / op_warning
    • command::item block_entity_data validation (both messages)
  • In game (Mac mini): /give @s minecraft:command_block[block_entity_data={Command:"say"}] replies Malformed 'minecraft:block_entity_data' component: 'Expected 'id' field in {Command:"say"}', and a spawner with zombie data is given fine.
  • I couldn't screenshot the tooltip: horizon-ctl can't hover a slot (the tooltip follows the real cursor).

Self-check:

  • cargo fmt --all: clean
  • cargo clippy --workspace --all-targets -- -D warnings: clean
  • cargo test -p horizon-client: 748 + 46 + 15 + 2 + 2 + 2 passed

Not covered

Horizon's tooltip draws colour only, so line 1 of the op warning isn't bold and the "more" line isn't italic.

PARITY_LOCAL_JOBS=3 tools/parity.py --changed origin/main on fix/block-entity-data-tooltips (#479 + #481 together): 84/84 harnesses pass (12 in a first run, 72 after a restart), pick_block_data included.

🤖 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/481 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/block-entity-data-tooltips` --- ### 📝 Commits (2) - [`bd42496`](https://github.com/horizon-rust/horizon/commit/bd42496af0941483477d733821655fcd87252643) Ctrl + Pick Block copies the block entity's data in creative - [`ac4ed86`](https://github.com/horizon-rust/horizon/commit/ac4ed869252277be020eec06ff3776fc37fddaba) Item tooltips for container contents, spawner data and op-only data ### 📊 Changes **16 files changed** (+1132 additions, -74 deletions) <details> <summary>View changed files</summary> ➕ `crates/horizon-client/examples/pick_block_data_fixture.rs` (+96 -0) ➕ `crates/horizon-client/src/block_entity_item.rs` (+485 -0) 📝 `crates/horizon-client/src/block_entity_nbt.rs` (+1 -1) 📝 `crates/horizon-client/src/command/item.rs` (+50 -0) 📝 `crates/horizon-client/src/game.rs` (+20 -23) 📝 `crates/horizon-client/src/game/banners.rs` (+0 -14) ➕ `crates/horizon-client/src/game/block_items.rs` (+117 -0) 📝 `crates/horizon-client/src/game/command_blocks.rs` (+5 -4) 📝 `crates/horizon-client/src/game/dispenser.rs` (+1 -2) 📝 `crates/horizon-client/src/game/remote.rs` (+1 -1) 📝 `crates/horizon-client/src/game/stations.rs` (+47 -1) 📝 `crates/horizon-client/src/game/storage.rs` (+0 -28) 📝 `crates/horizon-client/src/item_tooltip.rs` (+64 -0) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) ➕ `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaPickBlockDataOracle.java` (+91 -0) ➕ `tools/test_pick_block_data_parity.py` (+153 -0) </details> ### 📄 Description Part of #386. Stacked on #479; merge that one first. ## What These are the tooltip lines vanilla 26.3 shows for the components Ctrl + Pick Block (and `/give`) put on items: - **Container contents** (`ItemContainerContents.addToTooltip`): the first five stacks as `5 x Diamond`, then `and N more...`. Shulker boxes now list their contents too, as in vanilla. - **Spawners and trial spawners** (`Spawner.appendHoverText`, called from `ItemStack.addDetailsToTooltip`): the entity named by `block_entity_data.SpawnData.entity.id` (gray). Without one: a blank line, then "Interact with Spawn Egg:" (gray) and " Sets Mob Type" (blue). - **Op warning** (`BlockItem.shouldPrintOpWarning`, `ItemStack.OP_NBT_WARNING`): with game master permission, an item holding data of an op-only type (command blocks, lecterns, signs, hanging signs, spawners, trial spawners) gets the three red `item.op_warning` lines. - **Item argument**: `block_entity_data` without an `id`, or with an unknown block entity type, is malformed, with `TypedEntityData.codec`'s messages: `Expected 'id' field in {...}` and `Unknown registry key in ResourceKey[minecraft:root / minecraft:block_entity_type]: ...`. The lang keys are the 26.3 ones (`item.container.item_count`, `item.container.more_items`, `item.op_warning.line1-3`). Horizon's lang loader maps them from the old keys through `deprecated.json`. ## Proof - Unit tests: - `item_tooltip::container_lines` (five lines, then the remainder) - `block_entity_item::spawner_entity` / `op_warning` - `command::item` block_entity_data validation (both messages) - In game (Mac mini): `/give @s minecraft:command_block[block_entity_data={Command:"say"}]` replies `Malformed 'minecraft:block_entity_data' component: 'Expected 'id' field in {Command:"say"}'`, and a spawner with zombie data is given fine. - I couldn't screenshot the tooltip: horizon-ctl can't hover a slot (the tooltip follows the real cursor). Self-check: - `cargo fmt --all`: clean - `cargo clippy --workspace --all-targets -- -D warnings`: clean - `cargo test -p horizon-client`: 748 + 46 + 15 + 2 + 2 + 2 passed ## Not covered Horizon's tooltip draws colour only, so line 1 of the op warning isn't bold and the "more" line isn't italic. `PARITY_LOCAL_JOBS=3 tools/parity.py --changed origin/main` on fix/block-entity-data-tooltips (#479 + #481 together): **84/84 harnesses pass** (12 in a first run, 72 after a restart), `pick_block_data` included. 🤖 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-02 15:57:30 +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#2596
No description provided.