[PR #3594] [MERGED] Paintings: the item's variant is placed and named in its tooltip #5081

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

📋 Pull Request Information

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

Base: main ← Head: fix-3503


📝 Commits (3)

  • daa5415 Paintings: the item's variant is placed and named in its tooltip
  • 8168d96 Merge origin/main into fix-3503
  • 52a380c Merge origin/main into fix-3503

📊 Changes

6 files changed (+196 additions, -11 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+10 -2)
📝 crates/horizon-client/src/game/paintings.rs (+22 -2)
📝 crates/horizon-client/src/game/stations.rs (+32 -7)
📝 crates/horizon-client/src/item_sync.rs (+70 -0)
📝 crates/horizon-client/src/lan/guest.rs (+12 -0)
📝 crates/horizon-protocol/src/item.rs (+50 -0)

📄 Description

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

What and why

Fixes #3503

Every painting in the creative tab but the first carries a painting/variant component. Horizon ignored it: placing one ran only Painting.create's random pick (so all of them placed the same random painting), and the tooltip showed only "Painting".

  • Placement (game/paintings.rs): after the random pick, the stack's variant replaces it, and the painting still has to survive where it goes (otherwise the use does nothing, as vanilla's CONSUME).
  • Tooltip (game/stations.rs): the variant's title (yellow), author (gray) and size (painting.dimensions). A painting without the component shows "Random variant" (painting.random, gray) in a creative tab's own slots only (TooltipFlag.isCreative): the creative screen now sets that flag for its item grid.
  • Wire (horizon-protocol item.rs, item_sync.rs, lan/guest.rs): component 109 is a painting_variant holder. A reference is now decoded (Component::PaintingVariant) and mapped to/from the synced registry, as trims are. Without that, on the default server thread the creative client's pick reached the server as a plain painting, and the server's stacks lost their variant on the client (no tooltip in the hotbar).

Vanilla reference

  • HangingEntityItem.useOn: Painting.create (random largest placeable), then EntityType.createDefaultStackConfig(...).apply(entity) → Painting.applyImplicitComponents → setVariant, then HangingEntity.survives() or CONSUME.
  • HangingEntityItem.appendHoverText: PaintingVariant.title(), author(), Component.translatable("painting.dimensions", width, height); without the component and with TooltipFlag.isCreative(), TOOLTIP_RANDOM_VARIANT (painting.random, GRAY). It is the first part of ItemStack.addDetailsToTooltip (Item.appendHoverText before the components).
  • CreativeModeInventoryScreen.getTooltipFromContainerItem: asCreative() only for a CustomCreativeSlot.
  • Harness: tools/test_item_wire_parity.py (has a painting variant fixture) passes: Item wire parity passed: 374 stacks, all 122 component types.

Self-check

tools/pr_ready.py / tools/parity.py stop on Windows (signal.SIGHUP), so these ran by hand (Windows 11):

cargo fmt --all -- --check                                              # ok
cargo clippy -p horizon-protocol --all-targets -- -D warnings           # ok
cargo clippy -p horizon-client --features mods --all-targets -- -D warnings   # ok
cargo test -p horizon-protocol --lib item::                             # 12 passed
cargo test -p horizon-client --lib item_sync::tests                     # 4 passed
python tools/test_item_wire_parity.py                                   # passed, 374 stacks, all 122 component types

New test item_sync::tests::a_painting_keeps_its_variant_across_the_wire, with the fix reverted (protocol, item_sync, guest back to main):

test item_sync::tests::a_painting_keeps_its_variant_across_the_wire ... FAILED
assertion `left == right` failed
  left: None
 right: Some(String(JavaString([109, 105, 110, 101, 99, 114, 97, 102, 116, 58, 107, 101, 98, 97, 98])))

With the fix: test result: ok. 4 passed. Plus item::tests::painting_variants_decode_by_reference (a reference decodes, a direct variant is read past, both encode back to the same bytes).

Screenshots

Checked in game (screenshots taken locally, described here). Server-thread single player, creative, a 15x9 stone wall:

Before (main) After
/give @s painting[painting/variant="alban"] placed Skull and Roses (4x4, random) Albanian (1x1)
Creative search, Albanian slot "Painting" only Painting / Albanian / Kristoffer Zetterstrand / 1x1
Creative search, first (plain) slot "Painting" only Painting / Random variant
Hotbar stack (from the server) "Painting" only the same four lines
Graham taken from the creative tab and placed — Graham (1x2)

🤖 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/3594 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3503` --- ### 📝 Commits (3) - [`daa5415`](https://github.com/horizon-rust/horizon/commit/daa54157242d4159b1ccc08a37ec61ea001079f1) Paintings: the item's variant is placed and named in its tooltip - [`8168d96`](https://github.com/horizon-rust/horizon/commit/8168d96082857672fb7a9a9e9a20c23e393de3e5) Merge origin/main into fix-3503 - [`52a380c`](https://github.com/horizon-rust/horizon/commit/52a380cd2f81133dcace773487ab139c5aa5c529) Merge origin/main into fix-3503 ### 📊 Changes **6 files changed** (+196 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+10 -2) 📝 `crates/horizon-client/src/game/paintings.rs` (+22 -2) 📝 `crates/horizon-client/src/game/stations.rs` (+32 -7) 📝 `crates/horizon-client/src/item_sync.rs` (+70 -0) 📝 `crates/horizon-client/src/lan/guest.rs` (+12 -0) 📝 `crates/horizon-protocol/src/item.rs` (+50 -0) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why Fixes #3503 Every painting in the creative tab but the first carries a `painting/variant` component. Horizon ignored it: placing one ran only `Painting.create`'s random pick (so all of them placed the same random painting), and the tooltip showed only "Painting". - **Placement** (`game/paintings.rs`): after the random pick, the stack's variant replaces it, and the painting still has to survive where it goes (otherwise the use does nothing, as vanilla's `CONSUME`). - **Tooltip** (`game/stations.rs`): the variant's title (yellow), author (gray) and size (`painting.dimensions`). A painting without the component shows "Random variant" (`painting.random`, gray) in a creative tab's own slots only (`TooltipFlag.isCreative`): the creative screen now sets that flag for its item grid. - **Wire** (`horizon-protocol` `item.rs`, `item_sync.rs`, `lan/guest.rs`): component 109 is a `painting_variant` holder. A reference is now decoded (`Component::PaintingVariant`) and mapped to/from the synced registry, as trims are. Without that, on the default server thread the creative client's pick reached the server as a plain painting, and the server's stacks lost their variant on the client (no tooltip in the hotbar). ## Vanilla reference - `HangingEntityItem.useOn`: `Painting.create` (random largest placeable), then `EntityType.createDefaultStackConfig(...).apply(entity)` → `Painting.applyImplicitComponents` → `setVariant`, then `HangingEntity.survives()` or `CONSUME`. - `HangingEntityItem.appendHoverText`: `PaintingVariant.title()`, `author()`, `Component.translatable("painting.dimensions", width, height)`; without the component and with `TooltipFlag.isCreative()`, `TOOLTIP_RANDOM_VARIANT` (`painting.random`, GRAY). It is the first part of `ItemStack.addDetailsToTooltip` (`Item.appendHoverText` before the components). - `CreativeModeInventoryScreen.getTooltipFromContainerItem`: `asCreative()` only for a `CustomCreativeSlot`. - Harness: `tools/test_item_wire_parity.py` (has a `painting variant` fixture) passes: `Item wire parity passed: 374 stacks, all 122 component types`. ## Self-check `tools/pr_ready.py` / `tools/parity.py` stop on Windows (`signal.SIGHUP`), so these ran by hand (Windows 11): ``` cargo fmt --all -- --check # ok cargo clippy -p horizon-protocol --all-targets -- -D warnings # ok cargo clippy -p horizon-client --features mods --all-targets -- -D warnings # ok cargo test -p horizon-protocol --lib item:: # 12 passed cargo test -p horizon-client --lib item_sync::tests # 4 passed python tools/test_item_wire_parity.py # passed, 374 stacks, all 122 component types ``` New test `item_sync::tests::a_painting_keeps_its_variant_across_the_wire`, with the fix reverted (protocol, `item_sync`, `guest` back to main): ``` test item_sync::tests::a_painting_keeps_its_variant_across_the_wire ... FAILED assertion `left == right` failed left: None right: Some(String(JavaString([109, 105, 110, 101, 99, 114, 97, 102, 116, 58, 107, 101, 98, 97, 98]))) ``` With the fix: `test result: ok. 4 passed`. Plus `item::tests::painting_variants_decode_by_reference` (a reference decodes, a direct variant is read past, both encode back to the same bytes). ## Screenshots Checked in game (screenshots taken locally, described here). Server-thread single player, creative, a 15x9 stone wall: | | Before (main) | After | |---|---|---| | `/give @s painting[painting/variant="alban"]` placed | Skull and Roses (4x4, random) | Albanian (1x1) | | Creative search, Albanian slot | "Painting" only | Painting / Albanian / Kristoffer Zetterstrand / 1x1 | | Creative search, first (plain) slot | "Painting" only | Painting / Random variant | | Hotbar stack (from the server) | "Painting" only | the same four lines | | Graham taken from the creative tab and placed | — | Graham (1x2) | 🤖 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:10:06 +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#5081
No description provided.