[PR #1874] [MERGED] Creative: a stack keeps its components when it crosses the wire #3833

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

📋 Pull Request Information

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

Base: main ← Head: fix/creative-item-components


📝 Commits (4)

  • 9fe77c7 Creative: a stack keeps its components when it crosses the wire
  • f9d85d2 Merge remote-tracking branch 'origin/main' into cg14/pr1874
  • f969415 Creative stacks: reuse the wire codec both sides already had
  • bc09558 Merge origin/main into fix/creative-item-components

📊 Changes

6 files changed (+361 additions, -224 deletions)

View changed files

📝 crates/horizon-client/src/game/lan_actions.rs (+2 -21)
📝 crates/horizon-client/src/game/remote.rs (+23 -203)
➕ crates/horizon-client/src/item_sync.rs (+324 -0)
📝 crates/horizon-client/src/lan/hub.rs (+5 -0)
📝 crates/horizon-client/src/lib.rs (+1 -0)
📝 crates/horizon-protocol/src/registry.rs (+6 -0)

📄 Description

🤖 Opened by Alexander's AI agent (Hermes), not by Alexander himself.

Refs #1832. This fixes the class; the potion half needs a protocol component, see the end.

A creative stack lost everything but its count once it reached the server. Game::to_network (game/remote.rs) wrote only the damage component into SetCreativeModeSlot, and item_from_network (game/lan_actions.rs) read back damage and enchantments alone. The inventory the server echoed then replaced a named sword with a plain one, trimmed armour with untrimmed, an enchanted book with a blank book, and a potion with an uncraftable one.

item_sync is now the pair that converts a stack to the packet's component patch and back:

  • encode writes the components StackData models and the packet can carry: damage, enchantments, stored_enchantments, repair_cost, custom_name and trim. Registry names resolve to the synced registries' ids, and a name the registry does not know is left out rather than sent as id 0, which is a different entry rather than a missing one.
  • apply reads them into the same StackData fields that item_data::decode_components fills from the equivalent NBT, so the saved, command and packet paths agree.

Not carried yet, and named in the commit: potion_contents has no component id or codec in horizon-protocol, so the potion case in #1832 stays open until that exists; container, charged_projectiles, written books and map_id are modelled by the packet but not written here.

How tested:

  • cargo check -p horizon-client --all-targets
  • cargo clippy -p horizon-client --all-targets -- -D warnings
  • item_sync::tests::a_stack_keeps_its_components_across_the_wire — a stack carrying damage, two kinds of enchantments, a custom name, a repair cost and a trim survives encode then apply unchanged.
  • item_sync::tests::an_unknown_enchantment_is_left_out_rather_than_sent_as_zero — the id-0 trap.

Not observed in the running client: no creative session was opened, so this is proven at the codec level. The pr_ready block follows as a comment.


🔄 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/1874 **Author:** [@Domanffe](https://github.com/Domanffe) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/creative-item-components` --- ### 📝 Commits (4) - [`9fe77c7`](https://github.com/horizon-rust/horizon/commit/9fe77c7a56042ceb82ee634f0abc1610ede4f767) Creative: a stack keeps its components when it crosses the wire - [`f9d85d2`](https://github.com/horizon-rust/horizon/commit/f9d85d2e38796991e30e0814022361373f654001) Merge remote-tracking branch 'origin/main' into cg14/pr1874 - [`f969415`](https://github.com/horizon-rust/horizon/commit/f969415c7a91ab19c83c6b3d98d1d6c9950eca6c) Creative stacks: reuse the wire codec both sides already had - [`bc09558`](https://github.com/horizon-rust/horizon/commit/bc09558dfa71d4687d9d7e739b4a0205e9079514) Merge origin/main into fix/creative-item-components ### 📊 Changes **6 files changed** (+361 additions, -224 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan_actions.rs` (+2 -21) 📝 `crates/horizon-client/src/game/remote.rs` (+23 -203) ➕ `crates/horizon-client/src/item_sync.rs` (+324 -0) 📝 `crates/horizon-client/src/lan/hub.rs` (+5 -0) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) 📝 `crates/horizon-protocol/src/registry.rs` (+6 -0) </details> ### 📄 Description > 🤖 Opened by Alexander's AI agent (Hermes), not by Alexander himself. Refs #1832. This fixes the class; the potion half needs a protocol component, see the end. A creative stack lost everything but its count once it reached the server. `Game::to_network` (`game/remote.rs`) wrote only the damage component into `SetCreativeModeSlot`, and `item_from_network` (`game/lan_actions.rs`) read back damage and enchantments alone. The inventory the server echoed then replaced a named sword with a plain one, trimmed armour with untrimmed, an enchanted book with a blank book, and a potion with an uncraftable one. `item_sync` is now the pair that converts a stack to the packet's component patch and back: - `encode` writes the components `StackData` models and the packet can carry: damage, `enchantments`, `stored_enchantments`, `repair_cost`, `custom_name` and `trim`. Registry names resolve to the synced registries' ids, and a name the registry does not know is left out rather than sent as id 0, which is a different entry rather than a missing one. - `apply` reads them into the same `StackData` fields that `item_data::decode_components` fills from the equivalent NBT, so the saved, command and packet paths agree. Not carried yet, and named in the commit: `potion_contents` has no component id or codec in `horizon-protocol`, so the potion case in #1832 stays open until that exists; `container`, `charged_projectiles`, written books and `map_id` are modelled by the packet but not written here. How tested: - `cargo check -p horizon-client --all-targets` - `cargo clippy -p horizon-client --all-targets -- -D warnings` - `item_sync::tests::a_stack_keeps_its_components_across_the_wire` — a stack carrying damage, two kinds of enchantments, a custom name, a repair cost and a trim survives encode then apply unchanged. - `item_sync::tests::an_unknown_enchantment_is_left_out_rather_than_sent_as_zero` — the id-0 trap. Not observed in the running client: no creative session was opened, so this is proven at the codec level. The `pr_ready` block follows as a comment. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:12:38 +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#3833
No description provided.