[PR #4742] [MERGED] Hash item components in container clicks like the vanilla client #5822

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

📋 Pull Request Information

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

Base: main ← Head: parity/K-component-hash


📝 Commits (2)

  • 8e40d11 Hash item components in HashedStack like the vanilla client
  • 424dc91 Merge hr/main into parity/K-component-hash

📊 Changes

4 files changed (+869 additions, -12 deletions)

View changed files

📝 crates/horizon-client/src/game/remote.rs (+13 -3)
📝 crates/horizon-protocol/src/item.rs (+27 -9)
➕ crates/horizon-protocol/src/item/hash.rs (+813 -0)
📝 crates/horizon-protocol/src/registry.rs (+16 -0)

📄 Description

🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally.

Part of #3518

Second of two PRs (after #4738, HashOps): the container-click packets now carry the component hashes a vanilla server compares.

Rows

  • HashedPatchMap.create: Hashed::create hashes every added component as its codec form (TypedDataComponent.encodeValue(hashOps).asInt()) and sends the removed ones. A stack kept as the server sent it (Stack::wire, patch bytes only) is decoded first (WirePatch::decode); before, such a stack sent no components and no removals at all.
  • HashedStack.create: the client's send_clicks / remote_throw build the hashed stack with the connection's registry names (SyncedNames, built-in registries first, then the synced ones), as the client's decoratedHashOpsGenerator does.

Codec forms ported (horizon-protocol/src/item/hash.rs): ints (damage, max_stack_size, max_damage, repair_cost, map_id, dyed_color, ominous_bottle_amplifier), rarity / base_color as enum names, unbreakable, enchantment_glint_override, item_model, custom_data, custom_name / item_name / lore (text with Codec.BOOL styles as booleans), enchantments / stored_enchantments, attack_range, custom_model_data, tooltip_display, potion_contents (no custom effects/name), suspicious_stew_effects, writable_book_content, written_book_content, charged_projectiles / bundle_contents (item stack templates with their nested patch), fireworks (UNSIGNED_BYTE hashes as a byte), firework_explosion, lodestone_tracker, trim, instrument, banner_patterns, painting/variant.

Not hashed (partial)

These keep the old behaviour (left out of added, so a vanilla server resyncs a slot holding them): profile (ResolvableProfile.CODEC), potion_contents with custom effects or a custom name (Horizon keeps those as encoded bytes), every component Horizon reads past as Component::Raw (container, block_entity_data, food, attribute_modifiers, equippable, ...), books with filtered text (the filtered variants are dropped on read), and an id with no registry name. creative_slot_lock and map_post_processing have no persistent codec in vanilla (vanilla's client would throw), so they are never hashed. lan/containers.rs::hashed_matches (the server comparing hashes) is unchanged.

Vanilla followed

HashedPatchMap.create, HashedStack.create, ClientPacketListener.decoratedHashOpsGenerator, TypedDataComponent.encodeValue, DataComponentPatch.CODEC, and the CODEC of each component listed above.

Tests

cargo test -p horizon-protocol --lib item::. component_hashes_match_vanilla pins 45 hashes printed by vanilla 26.3 itself (a throwaway Java driver ran encodeValue through VanillaRegistries.createWorldLookup().createSerializationContext(HashOps.CRC32C_INSTANCE) on the real components). Plus tests for unhashable components, Hashed::create and the wire-patch path. Ran fmt and clippy -D warnings on horizon-protocol and horizon-client. About 480 of the diff's lines are that test table.

🤖 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/4742 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `parity/K-component-hash` --- ### 📝 Commits (2) - [`8e40d11`](https://github.com/horizon-rust/horizon/commit/8e40d11b27051a1717d62781436b93bef01f8e13) Hash item components in HashedStack like the vanilla client - [`424dc91`](https://github.com/horizon-rust/horizon/commit/424dc918e78ff6f2570c0df83a8bed74d7fae356) Merge hr/main into parity/K-component-hash ### 📊 Changes **4 files changed** (+869 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/remote.rs` (+13 -3) 📝 `crates/horizon-protocol/src/item.rs` (+27 -9) ➕ `crates/horizon-protocol/src/item/hash.rs` (+813 -0) 📝 `crates/horizon-protocol/src/registry.rs` (+16 -0) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally. Part of #3518 Second of two PRs (after #4738, `HashOps`): the container-click packets now carry the component hashes a vanilla server compares. ## Rows - `HashedPatchMap.create`: `Hashed::create` hashes every added component as its codec form (`TypedDataComponent.encodeValue(hashOps).asInt()`) and sends the removed ones. A stack kept as the server sent it (`Stack::wire`, patch bytes only) is decoded first (`WirePatch::decode`); before, such a stack sent no components and no removals at all. - `HashedStack.create`: the client's `send_clicks` / `remote_throw` build the hashed stack with the connection's registry names (`SyncedNames`, built-in registries first, then the synced ones), as the client's `decoratedHashOpsGenerator` does. Codec forms ported (`horizon-protocol/src/item/hash.rs`): ints (`damage`, `max_stack_size`, `max_damage`, `repair_cost`, `map_id`, `dyed_color`, `ominous_bottle_amplifier`), `rarity` / `base_color` as enum names, `unbreakable`, `enchantment_glint_override`, `item_model`, `custom_data`, `custom_name` / `item_name` / `lore` (text with `Codec.BOOL` styles as booleans), `enchantments` / `stored_enchantments`, `attack_range`, `custom_model_data`, `tooltip_display`, `potion_contents` (no custom effects/name), `suspicious_stew_effects`, `writable_book_content`, `written_book_content`, `charged_projectiles` / `bundle_contents` (item stack templates with their nested patch), `fireworks` (`UNSIGNED_BYTE` hashes as a byte), `firework_explosion`, `lodestone_tracker`, `trim`, `instrument`, `banner_patterns`, `painting/variant`. ## Not hashed (partial) These keep the old behaviour (left out of `added`, so a vanilla server resyncs a slot holding them): `profile` (`ResolvableProfile.CODEC`), `potion_contents` with custom effects or a custom name (Horizon keeps those as encoded bytes), every component Horizon reads past as `Component::Raw` (`container`, `block_entity_data`, `food`, `attribute_modifiers`, `equippable`, ...), books with filtered text (the filtered variants are dropped on read), and an id with no registry name. `creative_slot_lock` and `map_post_processing` have no persistent codec in vanilla (vanilla's client would throw), so they are never hashed. `lan/containers.rs::hashed_matches` (the server comparing hashes) is unchanged. ## Vanilla followed `HashedPatchMap.create`, `HashedStack.create`, `ClientPacketListener.decoratedHashOpsGenerator`, `TypedDataComponent.encodeValue`, `DataComponentPatch.CODEC`, and the `CODEC` of each component listed above. ## Tests `cargo test -p horizon-protocol --lib item::`. `component_hashes_match_vanilla` pins 45 hashes printed by vanilla 26.3 itself (a throwaway Java driver ran `encodeValue` through `VanillaRegistries.createWorldLookup().createSerializationContext(HashOps.CRC32C_INSTANCE)` on the real components). Plus tests for unhashable components, `Hashed::create` and the wire-patch path. Ran `fmt` and `clippy -D warnings` on `horizon-protocol` and `horizon-client`. About 480 of the diff's lines are that test table. 🤖 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:15:14 +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#5822
No description provided.