[PR #4504] [MERGED] Apply a spawn egg's components to the mob it spawns #5662

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

📋 Pull Request Information

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

Base: main ← Head: fix/spawn-egg-components


📝 Commits (2)

  • 864f314 Apply a spawn egg's components to the mob it spawns
  • b043f39 Merge remote-tracking branch 'origin/main' into fix-4504

📊 Changes

4 files changed (+106 additions, -20 deletions)

View changed files

📝 crates/horizon-client/src/entity_nbt.rs (+96 -7)
📝 crates/horizon-client/src/game.rs (+1 -1)
📝 crates/horizon-client/src/game/creatures.rs (+5 -6)
📝 crates/horizon-client/src/game/dispenser.rs (+4 -6)

📄 Description

Closes the applyImplicitComponents rows for the farm animals in the port ledger. (No issue.)

Vanilla's EntityType.create runs Mob.finalizeSpawn — which is where the biome variant, the sheep colour and the mooshroom type come from — and then PostSpawnProcessor.apply → Entity.applyComponentsFromItemStack → the entity's applyImplicitComponents. That is what makes SpawnEggItem.spawnMob and MobBucketItem.spawn honour a stack's components: a minecraft:chicken_spawn_egg carrying minecraft:chicken/variant = minecraft:warm spawns a warm chicken, not the biome's temperate one.

Horizon had the bucket half of that hook (entity_nbt::load_bucket_data, for axolotl, salmon and tropical fish) and nothing for eggs — the egg's stack never reached the mob, so its components were dropped. The function is now apply_item_components, the shared item→mob hook, with arms for chicken|/cow|/pig variant and sound_variant, mooshroom/variant and sheep/color, and both spawn paths (Game::use_spawn_egg, the dispenser) call it after the mob is finalized, which is vanilla's order and is why the component wins.

Each component maps through the helpers the rest of the port already uses rather than a new table: finalize::variant_index (the same one the natural-spawn path stores a registry name with), finalize::sound_variants (pinned by an existing test to the exported *_sound_variant registry order), u8::from(name == "brown") for the mooshroom (the same expression the save's Type uses) and render::DYE_NAMES for the sheep (DyeColor ids). No RNG is drawn, so the tick's random sequence is untouched.

What is proven: cargo test -p horizon-client --lib item_component_tests → 1 passed on a build box with the prepared 26.3 data: a chicken egg carrying minecraft:warm on a mob left at temperate gives variant 1, and a sheep egg carrying lime gives colour 5.

What is not proven: no in-game check (an egg from the creative menu with a component, or a /give with components, landing the right variant), and pr_ready was not run, so CI's verify is the workspace check.

Two deliberate gaps, both pre-existing and named rather than silently left: spawn_egg_offspring (a chicken laying from an egg-carrying parent) does not apply components, and an egg with no variant component keeps the biome variant, where vanilla may reset to the component's default or pick a spawn variant — that needs the jar to settle and is untouched here.

This branch touches entity_nbt.rs and game/creatures.rs, in apply_item_components and use_spawn_egg; a sibling PR of ours touches other functions in those files.


🔄 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/4504 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/spawn-egg-components` --- ### 📝 Commits (2) - [`864f314`](https://github.com/horizon-rust/horizon/commit/864f314abf6618629399c998b865db907277f57e) Apply a spawn egg's components to the mob it spawns - [`b043f39`](https://github.com/horizon-rust/horizon/commit/b043f3977b9fb80aa476076c79b4ca8988d2f58b) Merge remote-tracking branch 'origin/main' into fix-4504 ### 📊 Changes **4 files changed** (+106 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/entity_nbt.rs` (+96 -7) 📝 `crates/horizon-client/src/game.rs` (+1 -1) 📝 `crates/horizon-client/src/game/creatures.rs` (+5 -6) 📝 `crates/horizon-client/src/game/dispenser.rs` (+4 -6) </details> ### 📄 Description Closes the `applyImplicitComponents` rows for the farm animals in the port ledger. (No issue.) Vanilla's `EntityType.create` runs `Mob.finalizeSpawn` — which is where the biome variant, the sheep colour and the mooshroom type come from — and then `PostSpawnProcessor.apply` → `Entity.applyComponentsFromItemStack` → the entity's `applyImplicitComponents`. That is what makes `SpawnEggItem.spawnMob` and `MobBucketItem.spawn` honour a stack's components: a `minecraft:chicken_spawn_egg` carrying `minecraft:chicken/variant = minecraft:warm` spawns a warm chicken, not the biome's temperate one. Horizon had the bucket half of that hook (`entity_nbt::load_bucket_data`, for axolotl, salmon and tropical fish) and nothing for eggs — the egg's stack never reached the mob, so its components were dropped. The function is now `apply_item_components`, the shared item→mob hook, with arms for `chicken|/cow|/pig` `variant` and `sound_variant`, `mooshroom/variant` and `sheep/color`, and both spawn paths (`Game::use_spawn_egg`, the dispenser) call it **after** the mob is finalized, which is vanilla's order and is why the component wins. Each component maps through the helpers the rest of the port already uses rather than a new table: `finalize::variant_index` (the same one the natural-spawn path stores a registry name with), `finalize::sound_variants` (pinned by an existing test to the exported `*_sound_variant` registry order), `u8::from(name == "brown")` for the mooshroom (the same expression the save's `Type` uses) and `render::DYE_NAMES` for the sheep (DyeColor ids). No RNG is drawn, so the tick's random sequence is untouched. **What is proven:** `cargo test -p horizon-client --lib item_component_tests` → 1 passed on a build box with the prepared 26.3 data: a chicken egg carrying `minecraft:warm` on a mob left at temperate gives variant 1, and a sheep egg carrying `lime` gives colour 5. **What is not proven:** no in-game check (an egg from the creative menu with a component, or a `/give` with components, landing the right variant), and `pr_ready` was not run, so CI's `verify` is the workspace check. Two deliberate gaps, both pre-existing and named rather than silently left: `spawn_egg_offspring` (a chicken laying from an egg-carrying parent) does not apply components, and an egg with **no** variant component keeps the biome variant, where vanilla may reset to the component's default or pick a spawn variant — that needs the jar to settle and is untouched here. This branch touches `entity_nbt.rs` and `game/creatures.rs`, in `apply_item_components` and `use_spawn_egg`; a sibling PR of ours touches other functions in those files. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:14:09 +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#5662
No description provided.