[PR #4884] [MERGED] Hash a container or bundle_contents predicate whose item predicate has exact components #5915

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

📋 Pull Request Information

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

Base: main ← Head: fix/hash-container-predicate


📝 Commits (1)

  • b213e53 Hash a container or bundle_contents predicate whose item predicate has exact components

📊 Changes

3 files changed (+121 additions, -8 deletions)

View changed files

📝 crates/horizon-protocol/src/item/hash/gameplay.rs (+96 -2)
📝 crates/horizon-protocol/src/item/hash/raw.rs (+23 -4)
📝 tools/port_map/rest-010.tsv (+2 -2)

📄 Description

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

Refs #3520 (rows HashedPatchMap.create and HashedStack.create: the last case left after #4862).

What and why

A container or bundle_contents partial predicate (in a can_break / can_place_on block predicate) holds an item predicate, which can hold exact components. Those components travel as NBT, where a Codec.BOOL is a byte, and a byte is not a boolean for HashOps. partial_predicate gave up on the whole component, so a vanilla server saw an unhashed slot and resynced it. #4862 said so: "still unhashed: a container or bundle_contents partial predicate whose item predicate has exact components".

  • COMPONENT_BOOLS: the Codec.BOOL field names of the item components' codecs (read from the 26.3 sources: food.can_always_eat, equippable.dispensable, lodestone_tracker.tracked, use_effects.can_sprint...), the key minecraft:enchantment_glint_override (a bare boolean component), and the predicate and text fields already in PREDICATE_BOOLS.
  • partial_predicate hashes a nested components with that set when every byte in it sits under such a name. A byte under any other name (it could be a Codec.BYTE) or inside a list keeps the old result: not hashed, never a wrong hash.

Vanilla reference

HashedPatchMap.create / HashedStack.create hash each component with codec.encodeStart(registryAccess.createSerializationContext(HashOps.CRC32C_INSTANCE), value) (ServerPlayer, the HashGenerator at line 289). The DataComponentPredicate codec is a dispatchedMap; ItemPredicate holds DataComponentExactPredicate as a map of component type to the component's own codec value.

How it was checked

  • A Java driver on the 26.3 jars (not committed) parsed SNBT through DataComponents.CAN_PLACE_ON's codec, printed the stream bytes and the HashOps.CRC32C_INSTANCE hash. Four cases, now in predicates_and_filtered_books_hash_as_vanilla_does: glint override true (-1100559882) and false (-566759991), damage plus a custom_name with bold in a bundle predicate (-473617213), a food with can_always_eat and a float saturation (1890827479). The first was the case the test expected None for; the other three are new.
  • a_byte_is_a_bool_only_under_a_name_the_codecs_give_to_one: the named, unnamed, listed and nested byte.
  • pr_ready --quick: fmt, clippy, 140 horizon-protocol tests, 481 python tests pass; parity harnesses left to CI.

Not covered: a nested component whose codec has a byte under a name not in COMPONENT_BOOLS (the predicate stays unhashed, as before).

🤖 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/4884 **Author:** [@xFedeT](https://github.com/xFedeT) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/hash-container-predicate` --- ### 📝 Commits (1) - [`b213e53`](https://github.com/horizon-rust/horizon/commit/b213e5346b5cacbe659c3770f3869842f366352c) Hash a container or bundle_contents predicate whose item predicate has exact components ### 📊 Changes **3 files changed** (+121 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-protocol/src/item/hash/gameplay.rs` (+96 -2) 📝 `crates/horizon-protocol/src/item/hash/raw.rs` (+23 -4) 📝 `tools/port_map/rest-010.tsv` (+2 -2) </details> ### 📄 Description > 🤖 Opened by xFedeT's AI agent (Claude Code, Claude Sonnet 5.5), not by xFedeT personally. Refs #3520 (rows `HashedPatchMap.create` and `HashedStack.create`: the last case left after #4862). ## What and why A `container` or `bundle_contents` partial predicate (in a `can_break` / `can_place_on` block predicate) holds an item predicate, which can hold exact `components`. Those components travel as NBT, where a `Codec.BOOL` is a byte, and a byte is not a boolean for `HashOps`. `partial_predicate` gave up on the whole component, so a vanilla server saw an unhashed slot and resynced it. #4862 said so: "still unhashed: a `container` or `bundle_contents` partial predicate whose item predicate has exact `components`". - `COMPONENT_BOOLS`: the `Codec.BOOL` field names of the item components' codecs (read from the 26.3 sources: `food.can_always_eat`, `equippable.dispensable`, `lodestone_tracker.tracked`, `use_effects.can_sprint`...), the key `minecraft:enchantment_glint_override` (a bare boolean component), and the predicate and text fields already in `PREDICATE_BOOLS`. - `partial_predicate` hashes a nested `components` with that set when every byte in it sits under such a name. A byte under any other name (it could be a `Codec.BYTE`) or inside a list keeps the old result: not hashed, never a wrong hash. ## Vanilla reference `HashedPatchMap.create` / `HashedStack.create` hash each component with `codec.encodeStart(registryAccess.createSerializationContext(HashOps.CRC32C_INSTANCE), value)` (`ServerPlayer`, the `HashGenerator` at line 289). The `DataComponentPredicate` codec is a `dispatchedMap`; `ItemPredicate` holds `DataComponentExactPredicate` as a map of component type to the component's own codec value. ## How it was checked - A Java driver on the 26.3 jars (not committed) parsed SNBT through `DataComponents.CAN_PLACE_ON`'s codec, printed the stream bytes and the `HashOps.CRC32C_INSTANCE` hash. Four cases, now in `predicates_and_filtered_books_hash_as_vanilla_does`: glint override true (`-1100559882`) and false (`-566759991`), `damage` plus a `custom_name` with `bold` in a bundle predicate (`-473617213`), a `food` with `can_always_eat` and a float saturation (`1890827479`). The first was the case the test expected `None` for; the other three are new. - `a_byte_is_a_bool_only_under_a_name_the_codecs_give_to_one`: the named, unnamed, listed and nested byte. - `pr_ready --quick`: fmt, clippy, 140 horizon-protocol tests, 481 python tests pass; parity harnesses left to CI. Not covered: a nested component whose codec has a byte under a name not in `COMPONENT_BOOLS` (the predicate stays unhashed, as before). 🤖 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:53 +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#5915
No description provided.