[PR #86] [MERGED] Match the variant components of entity predicates (taming grants only Best Friends Forever) #2316

Closed
opened 2026-11-02 15:54:55 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/86
Author: @ludovic111
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @ludovic111

Base: main ← Head: fix/wolf-advancements-65


📝 Commits (1)

  • 0b362e2 Match the variant components of entity predicates

📊 Changes

6 files changed (+319 additions, -1 deletions)

View changed files

➕ crates/horizon-client/examples/entity_components_probe.rs (+89 -0)
📝 crates/horizon-client/src/advancements.rs (+24 -1)
📝 crates/horizon-client/src/game/advancements.rs (+4 -0)
📝 crates/horizon-client/src/mobs/finalize.rs (+19 -0)
➕ mods/horizon/src/test/java/dev/horizonlab/parity/VanillaEntityComponentsOracle.java (+116 -0)
➕ tools/test_entity_components_parity.py (+67 -0)

📄 Description

What was wrong

Taming a wolf granted The Whole Pack and A Complete Catalogue together with Best Friends Forever (#65). Both are lists of tame_animal criteria, one per wolf / cat variant, each with an entity predicate like {"minecraft:components": {"minecraft:wolf/variant": "minecraft:ashen"}}. Horizon's EntityPredicate (advancements.rs) treated minecraft:components as always true, so the first animal tamed matched every criterion of both advancements at once.

What vanilla does

EntityPredicate.matches tests its components part with DataComponentExactPredicate.test(entity): for every expected component, entity.get(type) must equal it (Objects.equals), so an entity without the component never matches. Animals report their variant through their get override, e.g. Wolf.get(DataComponents.WOLF_VARIANT) returns castComponentValue(..., getVariant()) (likewise cats, frogs, pigs, cows, chickens, zombie nautiluses). tame_an_animal has no conditions, so only Best Friends Forever is granted by the first tame.

Fix

  • mobs::finalize::variant_component / species_variant_component: the variant data component (minecraft:<species>/variant) and registry entry a mob reports.
  • EntityView.components, filled by mob_entity; the minecraft:components sub-predicate compares it exactly (namespaces normalised), absent components never matching.

leash_all_frog_variants uses the same predicates; its player_interacted_with_entity trigger isn't fired by Horizon yet (unchanged here).

Tests

  • New harness tools/test_entity_components_parity.py (VanillaEntityComponentsOracle + examples/entity_components_probe.rs): the real EntityPredicate of every criterion of complete_catalogue, whole_pack and leash_all_frog_variants (plus their components alone and with another entity type), decoded with the registries' ops, on real wolves, cats, frogs, pigs, cows and chickens made with EntityType.create(LOAD) and given each registered variant through Entity.setComponent. 32 entities × 77 predicates: all match (51 true, 2,413 false; the old rule answered true to every components-only predicate).
  • cargo fmt --check, cargo clippy --workspace --all-targets --locked -D warnings, cargo test --workspace --locked and tools/check_public_tree.py pass.

Fixes #65

🤖 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/86 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/wolf-advancements-65` --- ### 📝 Commits (1) - [`0b362e2`](https://github.com/horizon-rust/horizon/commit/0b362e270f8824db5c4db0c849b3cf712e9cddc4) Match the variant components of entity predicates ### 📊 Changes **6 files changed** (+319 additions, -1 deletions) <details> <summary>View changed files</summary> ➕ `crates/horizon-client/examples/entity_components_probe.rs` (+89 -0) 📝 `crates/horizon-client/src/advancements.rs` (+24 -1) 📝 `crates/horizon-client/src/game/advancements.rs` (+4 -0) 📝 `crates/horizon-client/src/mobs/finalize.rs` (+19 -0) ➕ `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaEntityComponentsOracle.java` (+116 -0) ➕ `tools/test_entity_components_parity.py` (+67 -0) </details> ### 📄 Description ## What was wrong Taming a wolf granted **The Whole Pack** and **A Complete Catalogue** together with **Best Friends Forever** (#65). Both are lists of `tame_animal` criteria, one per wolf / cat variant, each with an entity predicate like `{"minecraft:components": {"minecraft:wolf/variant": "minecraft:ashen"}}`. Horizon's `EntityPredicate` (`advancements.rs`) treated `minecraft:components` as always true, so the first animal tamed matched every criterion of both advancements at once. ## What vanilla does `EntityPredicate.matches` tests its `components` part with `DataComponentExactPredicate.test(entity)`: for every expected component, `entity.get(type)` must equal it (`Objects.equals`), so an entity without the component never matches. Animals report their variant through their `get` override, e.g. `Wolf.get(DataComponents.WOLF_VARIANT)` returns `castComponentValue(..., getVariant())` (likewise cats, frogs, pigs, cows, chickens, zombie nautiluses). `tame_an_animal` has no conditions, so only **Best Friends Forever** is granted by the first tame. ## Fix - `mobs::finalize::variant_component` / `species_variant_component`: the variant data component (`minecraft:<species>/variant`) and registry entry a mob reports. - `EntityView.components`, filled by `mob_entity`; the `minecraft:components` sub-predicate compares it exactly (namespaces normalised), absent components never matching. `leash_all_frog_variants` uses the same predicates; its `player_interacted_with_entity` trigger isn't fired by Horizon yet (unchanged here). ## Tests - New harness `tools/test_entity_components_parity.py` (`VanillaEntityComponentsOracle` + `examples/entity_components_probe.rs`): the real `EntityPredicate` of every criterion of `complete_catalogue`, `whole_pack` and `leash_all_frog_variants` (plus their components alone and with another entity type), decoded with the registries' ops, on real wolves, cats, frogs, pigs, cows and chickens made with `EntityType.create(LOAD)` and given each registered variant through `Entity.setComponent`. 32 entities × 77 predicates: all match (51 true, 2,413 false; the old rule answered true to every components-only predicate). - `cargo fmt --check`, `cargo clippy --workspace --all-targets --locked -D warnings`, `cargo test --workspace --locked` and `tools/check_public_tree.py` pass. Fixes #65 🤖 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-02 15:54:55 +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#2316
No description provided.