[PR #2945] [MERGED] Fix creative inventory kick and lost item data on servers #4700

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2945
Author: @kacpherek
Created: 10/27/2026
Status: ✅ Merged
Merged: 10/28/2026
Merged by: @ludovic111

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


📝 Commits (4)

  • 6790913 Send creative slot stacks with length-prefixed components
  • e21957e Send a server's own components back for unedited creative stacks
  • af41d03 Read a server item's container contents for its tooltip
  • 9c9ce0b Keep a server item's block entity data for the op warning

📊 Changes

6 files changed (+201 additions, -35 deletions)

View changed files

📝 crates/horizon-client/src/game/remote.rs (+7 -0)
📝 crates/horizon-client/src/item_sync.rs (+68 -14)
📝 crates/horizon-items/src/item_data.rs (+30 -1)
📝 crates/horizon-protocol/src/entity_data.rs (+1 -0)
📝 crates/horizon-protocol/src/item.rs (+92 -18)
📝 crates/horizon-protocol/src/packets/play.rs (+3 -2)

📄 Description

What and why

Players on a vanilla server were kicked with DecoderException: Failed to decode packet 'serverbound/minecraft:set_creative_mode_slot' when they moved items that carry components (renamed, Unbreakable, prefilled shulker boxes) in the creative inventory. Four separate fixes, one commit each:

  • Kick: the creative slot packet uses the untrusted item codec, which writes every component value behind its byte length. Horizon wrote the plain codec, so the server read the first byte of each component as a length. The packet now uses a length-prefixed codec (DelimitedSlot); Horizon's own server reads it the same way.
  • Lost data: the packet rebuilt each stack from the few components Horizon models, so a server got a stack without its container, unbreakable, lore and every other kept component. A stack read from a server now keeps its component patch, and it is sent back as it came while nothing but the count changed. An edited stack is still rebuilt from the modelled components, now in the correct format.
  • Shulker tooltip: minecraft:container stayed raw after the item sync, so a shulker box from a server showed no contents. It is now read as ItemContainerContents.
  • Op warning: minecraft:block_entity_data stayed raw too, so a command block or spawner item from a server had no data for the op warning (permission 2 or higher) or the spawner tooltip. It is now read as TypedEntityData.

Vanilla reference

  • ServerboundSetCreativeModeSlotPacket.java:14, ItemStack.java:129 (OPTIONAL_UNTRUSTED_STREAM_CODEC)
  • DataComponentPatch.java:54 (DELIMITED_STREAM_CODEC, registryFriendlyLengthPrefixed)
  • ItemContainerContents.java:31 (STREAM_CODEC), TypedEntityData.java:73 (streamCodec)

Self-check

clippy (--all-targets -D warnings) and fmt pass for horizon-protocol, horizon-items and horizon-client. Not run in game.


🔄 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/2945 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 10/28/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/creative-slot-item-components` --- ### 📝 Commits (4) - [`6790913`](https://github.com/horizon-rust/horizon/commit/6790913e0b4fa474e64a0a4beef42d1f994ca255) Send creative slot stacks with length-prefixed components - [`e21957e`](https://github.com/horizon-rust/horizon/commit/e21957efd771fa712966277d094a96ea11ed545e) Send a server's own components back for unedited creative stacks - [`af41d03`](https://github.com/horizon-rust/horizon/commit/af41d0325c0ce729d1845691bae772e1b7b8513a) Read a server item's container contents for its tooltip - [`9c9ce0b`](https://github.com/horizon-rust/horizon/commit/9c9ce0b435e5e1975e4660050c69c3fa2b8ba03d) Keep a server item's block entity data for the op warning ### 📊 Changes **6 files changed** (+201 additions, -35 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/remote.rs` (+7 -0) 📝 `crates/horizon-client/src/item_sync.rs` (+68 -14) 📝 `crates/horizon-items/src/item_data.rs` (+30 -1) 📝 `crates/horizon-protocol/src/entity_data.rs` (+1 -0) 📝 `crates/horizon-protocol/src/item.rs` (+92 -18) 📝 `crates/horizon-protocol/src/packets/play.rs` (+3 -2) </details> ### 📄 Description ## What and why Players on a vanilla server were kicked with `DecoderException: Failed to decode packet 'serverbound/minecraft:set_creative_mode_slot'` when they moved items that carry components (renamed, Unbreakable, prefilled shulker boxes) in the creative inventory. Four separate fixes, one commit each: - **Kick:** the creative slot packet uses the untrusted item codec, which writes every component value behind its byte length. Horizon wrote the plain codec, so the server read the first byte of each component as a length. The packet now uses a length-prefixed codec (`DelimitedSlot`); Horizon's own server reads it the same way. - **Lost data:** the packet rebuilt each stack from the few components Horizon models, so a server got a stack without its container, unbreakable, lore and every other kept component. A stack read from a server now keeps its component patch, and it is sent back as it came while nothing but the count changed. An edited stack is still rebuilt from the modelled components, now in the correct format. - **Shulker tooltip:** `minecraft:container` stayed raw after the item sync, so a shulker box from a server showed no contents. It is now read as `ItemContainerContents`. - **Op warning:** `minecraft:block_entity_data` stayed raw too, so a command block or spawner item from a server had no data for the op warning (permission 2 or higher) or the spawner tooltip. It is now read as `TypedEntityData`. ## Vanilla reference - `ServerboundSetCreativeModeSlotPacket.java:14`, `ItemStack.java:129` (`OPTIONAL_UNTRUSTED_STREAM_CODEC`) - `DataComponentPatch.java:54` (`DELIMITED_STREAM_CODEC`, `registryFriendlyLengthPrefixed`) - `ItemContainerContents.java:31` (`STREAM_CODEC`), `TypedEntityData.java:73` (`streamCodec`) ## Self-check clippy (`--all-targets -D warnings`) and fmt pass for horizon-protocol, horizon-items and horizon-client. Not run in game. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:07:18 +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#4700
No description provided.