[PR #4772] [MERGED] Hash item behaviour components (food, tool, equippable, attributes, ...) in container clicks #5842

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

📋 Pull Request Information

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

Base: main ← Head: parity/K2-hash-2


📝 Commits (1)

  • a87db94 Hash the item behaviour components like the vanilla client (part 2)

📊 Changes

3 files changed (+670 additions, -3 deletions)

View changed files

📝 crates/horizon-protocol/src/item/hash.rs (+1 -0)
➕ crates/horizon-protocol/src/item/hash/gameplay.rs (+522 -0)
📝 crates/horizon-protocol/src/item/hash/raw.rs (+147 -3)

📄 Description

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

Part of #3518

What and why

Fourth PR on the hashed container-click components (#4738, #4742, #4764): the components that tune an item's behaviour (what /give or a server's custom items carry) now carry their hash too. Horizon keeps them as stream bytes, so each is decoded from its STREAM_CODEC form into the value its CODEC encodes and hashed.

Rows

  • HashedPatchMap.create: also hashes use_effects, attribute_modifiers, food, consumable (with its consume effects), use_remainder, use_cooldown, damage_resistant, tool, weapon, equippable, repairable, death_protection, blocks_attacks, piercing_weapon, kinetic_weapon, attack_animation, interact_animation, provides_trim_material, jukebox_playable, provides_banner_patterns, break_sound, compostable, cooking_fuel, brewing_fuel and mob_visibility. Fields equal to their optionalFieldOf default are left out (sound defaults are compared by name, as vanilla compares the registry holders); holder sets are #tag, a lone entry, or a list as HolderSetCodec writes them; direct sound events hash as their record.
  • HashedStack.create: the stack of a container click carries those hashes.

Still not hashed: can_place_on / can_break, books with filtered text, direct (inline) holders of trim, instrument, painting/variant, banner_patterns, jukebox_playable, provides_trim_material, and ids with no registry name.

Kind

  • parity: Horizon now does what vanilla 26.3 does

Vanilla reference

TypedDataComponent.encodeValue, HashedPatchMap.create, and the CODEC / STREAM_CODEC of FoodProperties, Consumable, ConsumeEffect and its five types, UseRemainder, UseCooldown, DamageResistant, Tool, Weapon, Equippable, Repairable, DeathProtection, BlocksAttacks, PiercingWeapon, KineticWeapon, SwingAnimation, UseEffects, ItemAttributeModifiers, SoundEvent, HolderSetCodec, MobVisibility, Compostable, CookingFuel, BrewingFuel.

Tests

cargo test -p horizon-protocol --lib item::. gameplay_components_hash_as_vanilla_does pins 42 cases (stream bytes and hash printed by vanilla 26.3 itself through a throwaway Java driver on the real jars: SNBT parsed with the component's codec, encoded with its STREAM_CODEC, encodeValue through HashOps.CRC32C_INSTANCE), decoded here with Component::read. The three components whose registries the driver could not load (provides_trim_material, jukebox_playable, provides_banner_patterns) share the helpers of the pinned ones but are not pinned. fmt and clippy -D warnings on horizon-protocol.

🤖 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/4772 **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-2` --- ### 📝 Commits (1) - [`a87db94`](https://github.com/horizon-rust/horizon/commit/a87db94c53e0043e5687c124ca5303b336a89679) Hash the item behaviour components like the vanilla client (part 2) ### 📊 Changes **3 files changed** (+670 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-protocol/src/item/hash.rs` (+1 -0) ➕ `crates/horizon-protocol/src/item/hash/gameplay.rs` (+522 -0) 📝 `crates/horizon-protocol/src/item/hash/raw.rs` (+147 -3) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally. Part of #3518 ## What and why Fourth PR on the hashed container-click components (#4738, #4742, #4764): the components that tune an item's behaviour (what `/give` or a server's custom items carry) now carry their hash too. Horizon keeps them as stream bytes, so each is decoded from its `STREAM_CODEC` form into the value its `CODEC` encodes and hashed. ## Rows - `HashedPatchMap.create`: also hashes `use_effects`, `attribute_modifiers`, `food`, `consumable` (with its consume effects), `use_remainder`, `use_cooldown`, `damage_resistant`, `tool`, `weapon`, `equippable`, `repairable`, `death_protection`, `blocks_attacks`, `piercing_weapon`, `kinetic_weapon`, `attack_animation`, `interact_animation`, `provides_trim_material`, `jukebox_playable`, `provides_banner_patterns`, `break_sound`, `compostable`, `cooking_fuel`, `brewing_fuel` and `mob_visibility`. Fields equal to their `optionalFieldOf` default are left out (sound defaults are compared by name, as vanilla compares the registry holders); holder sets are `#tag`, a lone entry, or a list as `HolderSetCodec` writes them; direct sound events hash as their record. - `HashedStack.create`: the stack of a container click carries those hashes. Still not hashed: `can_place_on` / `can_break`, books with filtered text, direct (inline) holders of `trim`, `instrument`, `painting/variant`, `banner_patterns`, `jukebox_playable`, `provides_trim_material`, and ids with no registry name. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does ## Vanilla reference `TypedDataComponent.encodeValue`, `HashedPatchMap.create`, and the `CODEC` / `STREAM_CODEC` of `FoodProperties`, `Consumable`, `ConsumeEffect` and its five types, `UseRemainder`, `UseCooldown`, `DamageResistant`, `Tool`, `Weapon`, `Equippable`, `Repairable`, `DeathProtection`, `BlocksAttacks`, `PiercingWeapon`, `KineticWeapon`, `SwingAnimation`, `UseEffects`, `ItemAttributeModifiers`, `SoundEvent`, `HolderSetCodec`, `MobVisibility`, `Compostable`, `CookingFuel`, `BrewingFuel`. ## Tests `cargo test -p horizon-protocol --lib item::`. `gameplay_components_hash_as_vanilla_does` pins 42 cases (stream bytes and hash printed by vanilla 26.3 itself through a throwaway Java driver on the real jars: SNBT parsed with the component's codec, encoded with its `STREAM_CODEC`, `encodeValue` through `HashOps.CRC32C_INSTANCE`), decoded here with `Component::read`. The three components whose registries the driver could not load (`provides_trim_material`, `jukebox_playable`, `provides_banner_patterns`) share the helpers of the pinned ones but are not pinned. `fmt` and `clippy -D warnings` on `horizon-protocol`. 🤖 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:22 +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#5842
No description provided.