[PR #4764] [MERGED] Hash container, profile, sign, variant and other stream-only components in container clicks #5835

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

📋 Pull Request Information

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

Base: main ← Head: parity/K2-hash


📝 Commits (1)

  • c830a17 Hash the components Horizon keeps as stream bytes like the vanilla client (part 1)

📊 Changes

3 files changed (+658 additions, -29 deletions)

View changed files

📝 crates/horizon-protocol/src/item.rs (+50 -12)
📝 crates/horizon-protocol/src/item/hash.rs (+30 -17)
➕ crates/horizon-protocol/src/item/hash/raw.rs (+578 -0)

📄 Description

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

Part of #3518

What and why

Third PR on the hashed container-click components (after #4738 HashOps and #4742 Hashed::create): more of the components that #4742 left out of added now carry the hash a vanilla server compares. Horizon keeps these as stream bytes (Component::Raw) or dropped parts of them, so each is decoded from its STREAM_CODEC form into the value its CODEC encodes, then hashed.

Rows

  • HashedPatchMap.create: also hashes container, pot_decorations, block_state, bees, sulfur_cube_content, entity_data, block_entity_data, bucket_entity_data, sign_text_front/back, the NBT-only components (intangible_projectile, map_decorations, debug_stick_state, recipes, lock, container_loot: their stream form is the codec's NBT), profile, potion_contents with custom effects or a custom name, minimum_attack_charge, potion_duration_scale, tooltip_style, note_block_sound, enchantable, villager_food, glider, waxed, dye and every dye-valued and mob-variant component (holders by registry name, enums by serialized name). additional_trade_cost has no persistent codec in vanilla, so it is never hashed (vanilla's client would throw).
  • HashedStack.create: the hashed stack of a container click now carries those hashes.

Also fixes the profile component's PlayerSkin.Patch read: it read two strings per texture and treated the model as a texture, but the stream form is one identifier per texture and a boolean for the model type. Profile now keeps the patch (SkinPatch) and writes it back.

Still not hashed (next PR): the gameplay-data components (attribute_modifiers, food, consumable, equippable, tool, ...), block_transformer/jukebox_playable-style holders, direct holders, and books with filtered pages.

Kind

  • parity: Horizon now does what vanilla 26.3 does

Vanilla reference

TypedDataComponent.encodeValue, HashedPatchMap.create, and the CODEC/STREAM_CODEC of ItemContainerContents, PotDecorations, BlockItemStateProperties, Bees/BeehiveBlockEntity.Occupant, TypedEntityData, SignText, PotionContents, MobEffectInstance(.Details), ResolvableProfile, PlayerSkin.Patch, Enchantable, VillagerFood, DyeColor, the mob variants, SeededContainerLoot, MapDecorations.

Tests

cargo test -p horizon-protocol --lib item::. components_read_past_hash_as_vanilla_does pins 48 cases whose stream bytes and hashes vanilla 26.3 printed itself (a throwaway Java driver on the real jars: parse SNBT with the component's codec, encode with STREAM_CODEC, encodeValue through HashOps.CRC32C_INSTANCE), decoded here with Component::read. fmt and clippy -D warnings on horizon-protocol; horizon-client checks.

🤖 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/4764 **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/K2-hash` --- ### 📝 Commits (1) - [`c830a17`](https://github.com/horizon-rust/horizon/commit/c830a170ad792ab69d3749965ac7cea34d1c94aa) Hash the components Horizon keeps as stream bytes like the vanilla client (part 1) ### 📊 Changes **3 files changed** (+658 additions, -29 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-protocol/src/item.rs` (+50 -12) 📝 `crates/horizon-protocol/src/item/hash.rs` (+30 -17) ➕ `crates/horizon-protocol/src/item/hash/raw.rs` (+578 -0) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally. Part of #3518 ## What and why Third PR on the hashed container-click components (after #4738 `HashOps` and #4742 `Hashed::create`): more of the components that #4742 left out of `added` now carry the hash a vanilla server compares. Horizon keeps these as stream bytes (`Component::Raw`) or dropped parts of them, so each is decoded from its `STREAM_CODEC` form into the value its `CODEC` encodes, then hashed. ## Rows - `HashedPatchMap.create`: also hashes `container`, `pot_decorations`, `block_state`, `bees`, `sulfur_cube_content`, `entity_data`, `block_entity_data`, `bucket_entity_data`, `sign_text_front/back`, the NBT-only components (`intangible_projectile`, `map_decorations`, `debug_stick_state`, `recipes`, `lock`, `container_loot`: their stream form is the codec's NBT), `profile`, `potion_contents` with custom effects or a custom name, `minimum_attack_charge`, `potion_duration_scale`, `tooltip_style`, `note_block_sound`, `enchantable`, `villager_food`, `glider`, `waxed`, `dye` and every dye-valued and mob-variant component (holders by registry name, enums by serialized name). `additional_trade_cost` has no persistent codec in vanilla, so it is never hashed (vanilla's client would throw). - `HashedStack.create`: the hashed stack of a container click now carries those hashes. Also fixes the `profile` component's `PlayerSkin.Patch` read: it read two strings per texture and treated the model as a texture, but the stream form is one identifier per texture and a boolean for the model type. `Profile` now keeps the patch (`SkinPatch`) and writes it back. Still not hashed (next PR): the gameplay-data components (`attribute_modifiers`, `food`, `consumable`, `equippable`, `tool`, ...), `block_transformer`/`jukebox_playable`-style holders, direct holders, and books with filtered pages. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does ## Vanilla reference `TypedDataComponent.encodeValue`, `HashedPatchMap.create`, and the `CODEC`/`STREAM_CODEC` of `ItemContainerContents`, `PotDecorations`, `BlockItemStateProperties`, `Bees`/`BeehiveBlockEntity.Occupant`, `TypedEntityData`, `SignText`, `PotionContents`, `MobEffectInstance(.Details)`, `ResolvableProfile`, `PlayerSkin.Patch`, `Enchantable`, `VillagerFood`, `DyeColor`, the mob variants, `SeededContainerLoot`, `MapDecorations`. ## Tests `cargo test -p horizon-protocol --lib item::`. `components_read_past_hash_as_vanilla_does` pins 48 cases whose stream bytes and hashes vanilla 26.3 printed itself (a throwaway Java driver on the real jars: parse SNBT with the component's codec, encode with `STREAM_CODEC`, `encodeValue` through `HashOps.CRC32C_INSTANCE`), decoded here with `Component::read`. `fmt` and `clippy -D warnings` on `horizon-protocol`; `horizon-client` checks. 🤖 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:20 +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#5835
No description provided.