[PR #2275] [MERGED] Spawn a baby when a spawn egg is used on its own mob kind #4165

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2275
Author: @kacpherek
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/27/2026
Merged by: @ludovic111

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


📝 Commits (2)

  • e71d428 Spawn a baby when a spawn egg is used on its own mob kind
  • f364c4f Leave wandering traders out of the spawn egg baby check

📊 Changes

1 file changed (+43 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+43 -0)

📄 Description

What and why

Right-clicking a mob with a spawn egg of its own kind (cow egg on a cow) did nothing special in Horizon: the click fell through to the item and spawned an adult on the block behind. Vanilla spawns a baby of that mob at its position instead.

interact_mob now runs this check right after name tags, where vanilla's Mob.checkAndHandleImportantInteractions does it:

  • the egg must be the clicked mob's own kind and the mob must have a baby form (can_be_baby: ageable mobs, zombies, piglins, zoglins); otherwise the click passes on as before;
  • the baby spawns at the parent's feet, is made a baby with set_baby, and takes the parent's variant (and wool colour for sheep), as getBreedOffspring with the parent as both parents would give;
  • one egg is used outside creative, the arm swings, and player_interacted_with_entity fires.

Because guests and the in-process single player server go through the same use_item → interact_mob path, this covers the server-thread game too.

Not covered (small follow-ups if wanted): the egg's custom name is not copied to the baby (applyComponentsFromItemStack), tame wolf/cat parents don't pass tameness, and the Fox/Zombie onOffspringSpawnedFromEgg extras (trusted player, loot pickup) are skipped.

Fixes #2269.

Vanilla reference

  • Mob.checkAndHandleImportantInteractions (Mob.java:1186-1210)
  • SpawnEggItem.spawnOffspringFromSpawnEgg (SpawnEggItem.java:149-177)

Self-check

cargo check -p horizon-client passes. Not tested in game.


🔄 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/2275 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/27/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/spawn-egg-baby` --- ### 📝 Commits (2) - [`e71d428`](https://github.com/horizon-rust/horizon/commit/e71d4281acce0741804c2120bbcc6ed57dbe66d2) Spawn a baby when a spawn egg is used on its own mob kind - [`f364c4f`](https://github.com/horizon-rust/horizon/commit/f364c4f9c6fdb28e114ef5b7a84d1f62e5a988d5) Leave wandering traders out of the spawn egg baby check ### 📊 Changes **1 file changed** (+43 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+43 -0) </details> ### 📄 Description ## What and why Right-clicking a mob with a spawn egg of its own kind (cow egg on a cow) did nothing special in Horizon: the click fell through to the item and spawned an adult on the block behind. Vanilla spawns a baby of that mob at its position instead. `interact_mob` now runs this check right after name tags, where vanilla's `Mob.checkAndHandleImportantInteractions` does it: - the egg must be the clicked mob's own kind and the mob must have a baby form (`can_be_baby`: ageable mobs, zombies, piglins, zoglins); otherwise the click passes on as before; - the baby spawns at the parent's feet, is made a baby with `set_baby`, and takes the parent's variant (and wool colour for sheep), as `getBreedOffspring` with the parent as both parents would give; - one egg is used outside creative, the arm swings, and `player_interacted_with_entity` fires. Because guests and the in-process single player server go through the same `use_item` → `interact_mob` path, this covers the server-thread game too. Not covered (small follow-ups if wanted): the egg's custom name is not copied to the baby (`applyComponentsFromItemStack`), tame wolf/cat parents don't pass tameness, and the Fox/Zombie `onOffspringSpawnedFromEgg` extras (trusted player, loot pickup) are skipped. Fixes #2269. ## Vanilla reference - `Mob.checkAndHandleImportantInteractions` (Mob.java:1186-1210) - `SpawnEggItem.spawnOffspringFromSpawnEgg` (SpawnEggItem.java:149-177) ## Self-check `cargo check -p horizon-client` passes. Not tested in game. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:15:10 +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#4165
No description provided.