[PR #4353] [MERGED] Shulker boxes show their contents to the player who holds them #5579

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

📋 Pull Request Information

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

Base: main ← Head: fix/shulker-container-sync


📝 Commits (1)

  • da4db61 Shulker boxes show their contents to the player who holds them

📊 Changes

1 file changed (+72 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/lan/guest.rs (+72 -0)

📄 Description

🤖 Opened by CocofireHD's AI agent (Hermes Agent), not by CocofireHD personally.

What and why

A shulker box that holds items shows only its name in the tooltip:

Shulker Box            ← Horizon before, for a box with 2 diamonds in slot 0
Shulker Box
2 x Gold bit           ← vanilla, and Horizon after

The client side is already there: from_network decodes minecraft:container into the stack (ItemContainerContents), and item_tooltip::container_lines turns it into the "count x name" lines. What was missing is the other direction — network_stack in lan/guest.rs, the encoder every stack goes through on its way from the integrated (single-player) or LAN server to a player, had no case for the component. The contents were dropped in transit, so the tooltip had nothing to list. give @s minecraft:shulker_box[minecraft:container=[…]] reproduces it, and so does any box a server hands over.

This is the remaining half of #2979: #2945 fixed the kick on moving such stacks in the creative inventory and kept a server stack's patch, but a box that the server itself hands out still arrives empty. It does not close that issue's open question about survival container clicks.

Kind

  • parity: Horizon now does what vanilla 26.3 does

Vanilla reference

ItemContainerContents.STREAM_CODEC (the slot count, then one optional ItemStack.OPTIONAL_STREAM_CODEC per slot) and ItemContainerContents.addToTooltip (the "count x hover name" lines, five of them, then "and N more...").

The encoder writes the component as Component::Raw, which the protocol layer writes back verbatim, so the bytes on the wire are exactly the vanilla codec — a vanilla client reads the same component, and the count is taken from the last filled slot (the saved container list only names the slots that hold something).

Self-check

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

| Check | Result |
| --- | --- |
| Scope | ✅ 1 file, +72 −0 |
| Cargo.lock | ✅ unchanged |
| Public tree | ✅ |
| Python tests | ✅ 480 passed (51 s) |
| rustfmt | ✅ (7 s) |
| clippy | ✅ (41 s) |
| tests: horizon-client | ❌ 732 passed, 1 failed (2 min 29 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.

Testing

A unit test (shulker_contents_survive_inventory_sync) sends a box holding a named diamond through stack_to_network → Slot write/read and back through the wire form, and checks the inner template's item id, count and custom_name. It fails without the change.

In the running client (single player, creative): give @s minecraft:shulker_box[minecraft:container=[{slot:0,item:{id:"minecraft:diamond",count:2,components:{"minecraft:custom_name":{text:"Gold bit",color:"gold"}}}}]], inventory open, hover the box — before: one line, Shulker Box; after: Shulker Box and 2 x Gold bit.


🔄 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/4353 **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/shulker-container-sync` --- ### 📝 Commits (1) - [`da4db61`](https://github.com/horizon-rust/horizon/commit/da4db61ba95292b6d78d0ef324f8c16f8ead8078) Shulker boxes show their contents to the player who holds them ### 📊 Changes **1 file changed** (+72 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/lan/guest.rs` (+72 -0) </details> ### 📄 Description > 🤖 Opened by CocofireHD's AI agent (Hermes Agent), not by CocofireHD personally. ## What and why A shulker box that holds items shows only its name in the tooltip: ``` Shulker Box ← Horizon before, for a box with 2 diamonds in slot 0 Shulker Box 2 x Gold bit ← vanilla, and Horizon after ``` The client side is already there: `from_network` decodes `minecraft:container` into the stack (`ItemContainerContents`), and `item_tooltip::container_lines` turns it into the "count x name" lines. What was missing is the other direction — `network_stack` in `lan/guest.rs`, the encoder every stack goes through on its way from the integrated (single-player) or LAN server to a player, had no case for the component. The contents were dropped in transit, so the tooltip had nothing to list. `give @s minecraft:shulker_box[minecraft:container=[…]]` reproduces it, and so does any box a server hands over. This is the remaining half of #2979: #2945 fixed the kick on moving such stacks in the creative inventory and kept a server stack's patch, but a box that the server itself hands out still arrives empty. It does not close that issue's open question about survival container clicks. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does ## Vanilla reference `ItemContainerContents.STREAM_CODEC` (the slot count, then one optional `ItemStack.OPTIONAL_STREAM_CODEC` per slot) and `ItemContainerContents.addToTooltip` (the "count x hover name" lines, five of them, then "and N more..."). The encoder writes the component as `Component::Raw`, which the protocol layer writes back verbatim, so the bytes on the wire are exactly the vanilla codec — a vanilla client reads the same component, and the count is taken from the last filled slot (the saved `container` list only names the slots that hold something). ## Self-check ``` **pr_ready** (`tools/pr_ready.py --quick` on DESKTOP-9IR5DCN, against origin/main, 4 min 4 s) | Check | Result | | --- | --- | | Scope | ✅ 1 file, +72 −0 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 480 passed (51 s) | | rustfmt | ✅ (7 s) | | clippy | ✅ (41 s) | | tests: horizon-client | ❌ 732 passed, 1 failed (2 min 29 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. ## Testing A unit test (`shulker_contents_survive_inventory_sync`) sends a box holding a named diamond through `stack_to_network` → `Slot` write/read and back through the wire form, and checks the inner template's item id, count and `custom_name`. It fails without the change. In the running client (single player, creative): `give @s minecraft:shulker_box[minecraft:container=[{slot:0,item:{id:"minecraft:diamond",count:2,components:{"minecraft:custom_name":{text:"Gold bit",color:"gold"}}}}]]`, inventory open, hover the box — before: one line, `Shulker Box`; after: `Shulker Box` and `2 x Gold bit`. --- <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:32 +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#5579
No description provided.