[PR #4907] [MERGED] Hash exact component predicates in container and bundle_contents predicates #5934

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

📋 Pull Request Information

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

Base: main ← Head: parity/K4-exact-components


📝 Commits (2)

  • 91e1f8a Hash exact component predicates nested in container and bundle_contents predicates
  • 36e3765 Merge hr/main into parity/K4-exact-components

📊 Changes

4 files changed (+299 additions, -112 deletions)

View changed files

📝 crates/horizon-protocol/src/item/hash.rs (+1 -0)
➕ crates/horizon-protocol/src/item/hash/exact.rs (+170 -0)
📝 crates/horizon-protocol/src/item/hash/gameplay.rs (+4 -112)
📝 crates/horizon-protocol/src/item/hash/raw.rs (+124 -0)

📄 Description

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

Part of #3520

What and why

Seventh PR on the hashed container-click components (#4738, #4742, #4764, #4772, #4782, #4862). It hashes the last case #4862 left out.

Rows

  • HashedPatchMap.create and HashedStack.create: a container / bundle_contents partial predicate (in can_place_on / can_break) whose item predicate has exact components now hashes. DataComponentExactPredicate.CODEC is DataComponentType.VALUE_MAP_CODEC, a Codec.dispatchedMap of component type to that type's own codec, so each value is hashed by its component's codec form. The values are NBT, and the only thing NBT cannot say is which bytes are a Codec.BOOL; new item/hash/exact.rs lists those per component, from the pinned 26.3 codecs (food, equippable, consumable with its effects, potion_contents, tool, tooltip_display, fireworks, written_book_content, custom_model_data.flags, text components, a bare enchantment_glint_override, ...), and recurses where the value holds item stacks (container, bundle_contents, charged_projectiles, use_remainder, whose components is a patch with !name removals) and into nested item predicates and their partial predicates. custom_data and the entity data stay raw NBT. A component with no persistent codec (creative_slot_lock, map_post_processing, additional_trade_cost) cannot be in a predicate, so it stays unhashed.

  • With this, both rows have nothing left unhashed that vanilla hashes.

  • Main meanwhile got b213e5346, which hashes these predicates by a flat list of bool key names and leaves any other byte unhashed. This replaces that list (COMPONENT_BOOLS, has_unnamed_byte) with each component's own codec shape, so no byte is left ambiguous; its three vanilla-pinned cases stay and pass.

Kind

  • parity: Horizon now does what vanilla 26.3 does

Vanilla reference

DataComponentExactPredicate, DataComponentType.VALUE_MAP_CODEC, DataComponentMatchers, ItemPredicate, CollectionPredicate, ContainerPredicate, BundlePredicate, ItemStackTemplate, DataComponentPatch.CODEC, and the Codec.BOOL fields of the component codecs.

Tests

cargo test -p horizon-protocol --lib item::: exact_components_in_predicates_hash_as_vanilla_does pins 21 more cases whose stream bytes and hashes vanilla 26.3 printed itself (a throwaway Java driver on the real jars: SNBT through can_place_on's codec, STREAM_CODEC.encode, encodeValue through HashOps.CRC32C_INSTANCE); the old container_components case now has vanilla's hash instead of None. 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/4907 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `parity/K4-exact-components` --- ### 📝 Commits (2) - [`91e1f8a`](https://github.com/horizon-rust/horizon/commit/91e1f8a8cd9b69b923513072bf06ece381405e91) Hash exact component predicates nested in container and bundle_contents predicates - [`36e3765`](https://github.com/horizon-rust/horizon/commit/36e376591afbff2498205b26c533dcc484142085) Merge hr/main into parity/K4-exact-components ### 📊 Changes **4 files changed** (+299 additions, -112 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-protocol/src/item/hash.rs` (+1 -0) ➕ `crates/horizon-protocol/src/item/hash/exact.rs` (+170 -0) 📝 `crates/horizon-protocol/src/item/hash/gameplay.rs` (+4 -112) 📝 `crates/horizon-protocol/src/item/hash/raw.rs` (+124 -0) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally. Part of #3520 ## What and why Seventh PR on the hashed container-click components (#4738, #4742, #4764, #4772, #4782, #4862). It hashes the last case #4862 left out. ## Rows - `HashedPatchMap.create` and `HashedStack.create`: a `container` / `bundle_contents` partial predicate (in `can_place_on` / `can_break`) whose item predicate has exact `components` now hashes. `DataComponentExactPredicate.CODEC` is `DataComponentType.VALUE_MAP_CODEC`, a `Codec.dispatchedMap` of component type to that type's own codec, so each value is hashed by its component's codec form. The values are NBT, and the only thing NBT cannot say is which bytes are a `Codec.BOOL`; new `item/hash/exact.rs` lists those per component, from the pinned 26.3 codecs (`food`, `equippable`, `consumable` with its effects, `potion_contents`, `tool`, `tooltip_display`, `fireworks`, `written_book_content`, `custom_model_data.flags`, text components, a bare `enchantment_glint_override`, ...), and recurses where the value holds item stacks (`container`, `bundle_contents`, `charged_projectiles`, `use_remainder`, whose `components` is a patch with `!name` removals) and into nested item predicates and their partial predicates. `custom_data` and the entity data stay raw NBT. A component with no persistent codec (`creative_slot_lock`, `map_post_processing`, `additional_trade_cost`) cannot be in a predicate, so it stays unhashed. - With this, both rows have nothing left unhashed that vanilla hashes. - Main meanwhile got b213e5346, which hashes these predicates by a flat list of bool key names and leaves any other byte unhashed. This replaces that list (`COMPONENT_BOOLS`, `has_unnamed_byte`) with each component's own codec shape, so no byte is left ambiguous; its three vanilla-pinned cases stay and pass. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does ## Vanilla reference `DataComponentExactPredicate`, `DataComponentType.VALUE_MAP_CODEC`, `DataComponentMatchers`, `ItemPredicate`, `CollectionPredicate`, `ContainerPredicate`, `BundlePredicate`, `ItemStackTemplate`, `DataComponentPatch.CODEC`, and the `Codec.BOOL` fields of the component codecs. ## Tests `cargo test -p horizon-protocol --lib item::`: `exact_components_in_predicates_hash_as_vanilla_does` pins 21 more cases whose stream bytes and hashes vanilla 26.3 printed itself (a throwaway Java driver on the real jars: SNBT through `can_place_on`'s codec, `STREAM_CODEC.encode`, `encodeValue` through `HashOps.CRC32C_INSTANCE`); the old `container_components` case now has vanilla's hash instead of `None`. `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:16:01 +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#5934
No description provided.