[PR #7317] [MERGED] A horse's or a llama's variant component sets its coat colour #7488

Closed
opened 2026-11-03 06:40:06 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7317
Author: @MSedgeMC
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: fix/horse-llama-variant-component


📝 Commits (3)

  • 0be2aa7 A horse's or a llama's variant component sets its coat colour
  • 3e08545 Test the horse's and the llama's variant component
  • 02de4be Merge remote-tracking branch 'upstream/main' into HEAD

📊 Changes

4 files changed (+180 additions, -8 deletions)

View changed files

📝 crates/horizon-client/src/entity_nbt.rs (+76 -3)
📝 crates/horizon-client/src/mobs/equine.rs (+13 -0)
📝 crates/horizon-client/src/mobs/finalize.rs (+86 -0)
📝 tools/port_map/game-011.tsv (+5 -5)

📄 Description

Vanilla's Horse.applyImplicitComponent and Llama.applyImplicitComponent call setVariant from the minecraft:horse/variant and minecraft:llama/variant components, so an item that carries one (a spawn egg with that component) spawns that coat. Horse.Variant is an enum, white 0 to dark_brown 6, and Llama.Variant creamy 0 to gray 3; the component stores the enum name, not a registry id. Horse.setVariant writes variant.getId() & 0xFF | this.getTypeVariant() & -256, so the markings the spawn drew (the high byte) stay. Horse.get(DataComponents.HORSE_VARIANT) and Llama.get(DataComponents.LLAMA_VARIANT) report the coat back.

Horizon's entity_nbt::apply_item_components read the variant components of chickens, cows, pigs, zombie nautiluses, mooshrooms, sheep, axolotls, salmon, tropical fish, foxes and frogs but not horses or llamas (and not trader llamas, which inherit the llama's), so an egg carrying one dropped it and the mob kept the coat its spawn picked. finalize::variant_index and variant_name had no horse or llama entry either, so minecraft:dark_brown fell through the frog name list and read as temperate, i.e. red. Neither mob reported the component, so an advancement entity predicate or a loot table asking for it never matched.

The save's variant key is VariantUtils.writeVariant's, and only the seven classes that call it write one (wolf, cat, frog, pig, cow, chicken, zombie nautilus): a horse and a llama store a packed Variant int, a fox and a mooshroom Type. species_variant_component gated that key, so once a horse and a llama report the component the write and the read of variant go through a new finalize::saves_variant_name, keeping both mobs' saves byte-identical to vanilla. That also stops a mooshroom being read from a variant key its own save never carries.

Proven: the vanilla side is the 26.3 client jar: DataComponents registers horse/variant as Variant.CODEC and llama/variant as Llama.Variant.CODEC; Horse.applyImplicitComponent compares DataComponents.HORSE_VARIANT and calls setVariant, which keeps getTypeVariant() & -256; Horse.Variant is WHITE(0) ... DARK_BROWN(6, "dark_brown"), Llama.Variant CREAMY(0) ... GRAY(3, "gray"); VariantUtils.writeVariant stores Identifier.CODEC under "variant" and grep writeVariant over the decompiled world/entity/animal tree finds the seven callers named above.

On the build VM, cargo test -q -p horizon-client-lib --lib a_horse passes 3 tests, including the new a_horse_or_llama_spawn_egg_picks_its_variant_component and a_horse_and_a_llama_report_their_variant_component. With the Species::Horse arm of apply_item_components deleted the first one fails on Horse.Variant.DARK_BROWN: left: 4, right: 6, so the test is what the fix turns over. cargo test -q -p horizon-client-lib --lib entity_nbt:: passes 38, finalize:: 8 and equine:: 7. cargo clippy -q -p horizon-client-lib --lib prints nothing and rustfmt --edition 2024 --check passes on all three files.

Not proven: I did not run the game. The in-game check is a minecraft:horse_spawn_egg carrying minecraft:horse/variant=minecraft:dark_brown hatching a dark brown horse with the markings a spawn would have drawn, and a minecraft:llama_spawn_egg with minecraft:llama/variant=minecraft:gray hatching a gray llama. The get half is only proved through species_variant_component itself, not through a live advancement predicate. An unknown name sets the enum default (white, creamy) where vanilla's codec would reject the component; that is the same leniency every other variant arm here has.

Corrects the Horse.setVariant, Horse.get, Horse.applyImplicitComponent, Llama.get and Llama.applyImplicitComponent rows of tools/port_map/game-011.tsv.


🔄 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/7317 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/horse-llama-variant-component` --- ### 📝 Commits (3) - [`0be2aa7`](https://github.com/horizon-rust/horizon/commit/0be2aa7dc3070fac09a7f1a77b27f55e415458e8) A horse's or a llama's variant component sets its coat colour - [`3e08545`](https://github.com/horizon-rust/horizon/commit/3e08545adc6a93f5548fca58e26a44a62298ab41) Test the horse's and the llama's variant component - [`02de4be`](https://github.com/horizon-rust/horizon/commit/02de4be7322e43c0079be654137714be114d2a0b) Merge remote-tracking branch 'upstream/main' into HEAD ### 📊 Changes **4 files changed** (+180 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/entity_nbt.rs` (+76 -3) 📝 `crates/horizon-client/src/mobs/equine.rs` (+13 -0) 📝 `crates/horizon-client/src/mobs/finalize.rs` (+86 -0) 📝 `tools/port_map/game-011.tsv` (+5 -5) </details> ### 📄 Description Vanilla's `Horse.applyImplicitComponent` and `Llama.applyImplicitComponent` call `setVariant` from the `minecraft:horse/variant` and `minecraft:llama/variant` components, so an item that carries one (a spawn egg with that component) spawns that coat. `Horse.Variant` is an enum, white 0 to dark_brown 6, and `Llama.Variant` creamy 0 to gray 3; the component stores the enum name, not a registry id. `Horse.setVariant` writes `variant.getId() & 0xFF | this.getTypeVariant() & -256`, so the markings the spawn drew (the high byte) stay. `Horse.get(DataComponents.HORSE_VARIANT)` and `Llama.get(DataComponents.LLAMA_VARIANT)` report the coat back. Horizon's `entity_nbt::apply_item_components` read the variant components of chickens, cows, pigs, zombie nautiluses, mooshrooms, sheep, axolotls, salmon, tropical fish, foxes and frogs but not horses or llamas (and not trader llamas, which inherit the llama's), so an egg carrying one dropped it and the mob kept the coat its spawn picked. `finalize::variant_index` and `variant_name` had no horse or llama entry either, so `minecraft:dark_brown` fell through the frog name list and read as temperate, i.e. red. Neither mob reported the component, so an advancement entity predicate or a loot table asking for it never matched. The save's `variant` key is `VariantUtils.writeVariant`'s, and only the seven classes that call it write one (wolf, cat, frog, pig, cow, chicken, zombie nautilus): a horse and a llama store a packed `Variant` int, a fox and a mooshroom `Type`. `species_variant_component` gated that key, so once a horse and a llama report the component the write and the read of `variant` go through a new `finalize::saves_variant_name`, keeping both mobs' saves byte-identical to vanilla. That also stops a mooshroom being read from a `variant` key its own save never carries. **Proven:** the vanilla side is the 26.3 client jar: `DataComponents` registers `horse/variant` as `Variant.CODEC` and `llama/variant` as `Llama.Variant.CODEC`; `Horse.applyImplicitComponent` compares `DataComponents.HORSE_VARIANT` and calls `setVariant`, which keeps `getTypeVariant() & -256`; `Horse.Variant` is `WHITE(0) ... DARK_BROWN(6, "dark_brown")`, `Llama.Variant` `CREAMY(0) ... GRAY(3, "gray")`; `VariantUtils.writeVariant` stores `Identifier.CODEC` under `"variant"` and `grep writeVariant` over the decompiled `world/entity/animal` tree finds the seven callers named above. On the build VM, `cargo test -q -p horizon-client-lib --lib a_horse` passes 3 tests, including the new `a_horse_or_llama_spawn_egg_picks_its_variant_component` and `a_horse_and_a_llama_report_their_variant_component`. With the `Species::Horse` arm of `apply_item_components` deleted the first one fails on `Horse.Variant.DARK_BROWN: left: 4, right: 6`, so the test is what the fix turns over. `cargo test -q -p horizon-client-lib --lib entity_nbt::` passes 38, `finalize::` 8 and `equine::` 7. `cargo clippy -q -p horizon-client-lib --lib` prints nothing and `rustfmt --edition 2024 --check` passes on all three files. **Not proven:** I did not run the game. The in-game check is a `minecraft:horse_spawn_egg` carrying `minecraft:horse/variant=minecraft:dark_brown` hatching a dark brown horse with the markings a spawn would have drawn, and a `minecraft:llama_spawn_egg` with `minecraft:llama/variant=minecraft:gray` hatching a gray llama. The `get` half is only proved through `species_variant_component` itself, not through a live advancement predicate. An unknown name sets the enum default (white, creamy) where vanilla's codec would reject the component; that is the same leniency every other variant arm here has. Corrects the `Horse.setVariant`, `Horse.get`, `Horse.applyImplicitComponent`, `Llama.get` and `Llama.applyImplicitComponent` rows of `tools/port_map/game-011.tsv`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:40:06 +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#7488
No description provided.