[GH-ISSUE #2269] RIght clicking animal with spawn egg does not spawn baby version (unlike vanilla) #622

Closed
opened 2026-11-02 15:40:36 +07:00 by bsakaguchi · 3 comments
Owner
Originally created by @Cristiandis on GitHub (Oct 26, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/2269 horizon: https://github.com/user-attachments/assets/a591cda0-363d-4484-91aa-c7885f6a3bb0 java: https://github.com/user-attachments/assets/0f78f272-31c5-467b-b9c5-7aca0b3a2e9c
Author
Owner

@kacpherek commented on GitHub (Oct 26, 2026):

@Cristiandis thanks for the report! A fix is up in #2275: using a spawn egg on its own kind of mob spawns a baby, as in vanilla. It's waiting for review.

<!-- gh-comment-id:6422838101 --> @kacpherek commented on GitHub (Oct 26, 2026): @Cristiandis thanks for the report! A fix is up in #2275: using a spawn egg on its own kind of mob spawns a baby, as in vanilla. It's waiting for review.
Author
Owner

@levzzz5154 commented on GitHub (Oct 27, 2026):

🤖 Agent: I mapped the vanilla path and the place it is missing in Horizon, but I have not opened a pull request for it yet — here is the evidence so the next pass does not have to redo it.

Vanilla (net.minecraft.world.entity.Mob.checkAndHandleImportantInteractions, Mob.java:1155): when the held item is a SpawnEggItem, the server calls SpawnEggItem.spawnOffspringFromSpawnEgg(player, this, this.getType(), level, this.position(), stack) (SpawnEggItem.java:153), which

  • returns empty when the egg is not for the mob's own type (spawnsEntity), so the interaction falls through (InteractionResult.PASS);
  • otherwise builds the offspring: AgeableMob.getBreedOffspring for an ageable parent (the parent's own breed), else EntityType.create;
  • calls offspring.setBaby(true) and gives up (empty, so PASS) when the offspring cannot be a baby;
  • snaps it to the parent's position, applies the egg's components, adds it to the level and consumes one egg.

Horizon: the client's prediction for a server already knows the case (game/remote_mob_use.rs:29 — "a spawn egg of the mob's own kind" takes the click), but the local path has no spawn-egg branch at all: Game::interact_entity (game.rs:3959) → Game::interact_mob (game/creatures.rs:2849) handles the name tag, the leash, the bucket, the zombie villager, the trader, the allay and the sulfur cube, and never looks at a spawn egg, so right-clicking an animal with its own spawn egg does nothing (and the egg is not consumed). The missing piece is a branch in interact_mob that follows SpawnEggItem.spawnOffspringFromSpawnEgg: the parent's breed offspring, setBaby(true), the parent's position, the egg's components, and one egg less in hand.

I have not built that branch yet (it needs the mob's breed offspring and the baby age in the local mob model, and the "you already have too many of that" message for the entity limit), so I am leaving this open.

<!-- gh-comment-id:6440818345 --> @levzzz5154 commented on GitHub (Oct 27, 2026): 🤖 Agent: I mapped the vanilla path and the place it is missing in Horizon, but I have not opened a pull request for it yet — here is the evidence so the next pass does not have to redo it. Vanilla (`net.minecraft.world.entity.Mob.checkAndHandleImportantInteractions`, Mob.java:1155): when the held item is a `SpawnEggItem`, the server calls `SpawnEggItem.spawnOffspringFromSpawnEgg(player, this, this.getType(), level, this.position(), stack)` (SpawnEggItem.java:153), which - returns empty when the egg is not for the mob's own type (`spawnsEntity`), so the interaction falls through (`InteractionResult.PASS`); - otherwise builds the offspring: `AgeableMob.getBreedOffspring` for an ageable parent (the parent's own breed), else `EntityType.create`; - calls `offspring.setBaby(true)` and gives up (empty, so `PASS`) when the offspring cannot be a baby; - snaps it to the parent's position, applies the egg's components, adds it to the level and **consumes one egg**. Horizon: the client's prediction for a server already knows the case (`game/remote_mob_use.rs:29` — "a spawn egg of the mob's own kind" takes the click), but the local path has no spawn-egg branch at all: `Game::interact_entity` (`game.rs:3959`) → `Game::interact_mob` (`game/creatures.rs:2849`) handles the name tag, the leash, the bucket, the zombie villager, the trader, the allay and the sulfur cube, and never looks at a spawn egg, so right-clicking an animal with its own spawn egg does nothing (and the egg is not consumed). The missing piece is a branch in `interact_mob` that follows `SpawnEggItem.spawnOffspringFromSpawnEgg`: the parent's breed offspring, `setBaby(true)`, the parent's position, the egg's components, and one egg less in hand. I have not built that branch yet (it needs the mob's breed offspring and the baby age in the local mob model, and the "you already have too many of that" message for the entity limit), so I am leaving this open.
Author
Owner

@levzzz5154 commented on GitHub (Oct 27, 2026):

🤖 Agent: the behaviour is in main (PR #2275, fix/spawn-egg-baby, merged on Oct 27), and I opened PR #2791 to name the rule in the library and cover it with a test.

What main does today: Game::interact_mob → Game::spawn_egg_offspring (crates/horizon-client/src/game/creatures.rs) uses a spawn egg of the mob's own kind on a mob, spawns the offspring at the parent's position, makes it a baby (finalize::set_baby), keeps the parent's variant (and the sheep's wool colour), sends the item-use event and takes one egg less in hand. A wandering trader is left out, because WanderingTrader.getBreedOffspring returns null, and a mob that cannot be a baby does not take the egg.

What was missing is that the two decisions vanilla makes were buried in the game, where they cannot be tested. PR #2791 moves them into the library, named after the vanilla methods — spawn_egg_is_for (SpawnEggItem.spawnsEntity: the egg is for the mob's own kind) and spawn_egg_offspring (SpawnEggItem.spawnOffspringFromSpawnEgg: the baby, with the parent's variant and colour) — and adds mobs::finalize::tests::a_spawn_egg_offspring_is_a_baby, which builds a cow from the resources and checks that the offspring is a baby with the parent's variant, that another mob's egg does not match and that a plain item is not an egg. With the baby removed, the test fails on child.is_baby().

Vanilla reference: net.minecraft.world.entity.Mob.checkAndHandleImportantInteractions (Mob.java:1155) and net.minecraft.world.item.SpawnEggItem.spawnOffspringFromSpawnEgg (SpawnEggItem.java:153) — the offspring is the parent's breed (AgeableMob.getBreedOffspring), setBaby(true), at the parent's position, with the egg's components, and one egg consumed; the egg of another kind is InteractionResult.PASS and the click carries on.

One detail worth stating plainly: this path has no mob limit and no message in vanilla 26.3. Mob.checkAndHandleImportantInteractions and SpawnEggItem.spawnOffspringFromSpawnEgg have neither; the limit belongs to EntityType.canSpawn on the block path (SpawnEggItem.useOn). So the "you already have too many mobs of that type" message is not part of the animal path, and Horizon's path does not have one either.

Self-check: cargo test -p horizon-client --lib -- spawn_egg → 1 passed, 0 failed.

<!-- gh-comment-id:6441824284 --> @levzzz5154 commented on GitHub (Oct 27, 2026): 🤖 Agent: the behaviour is in `main` (PR #2275, `fix/spawn-egg-baby`, merged on Oct 27), and I opened PR #2791 to name the rule in the library and cover it with a test. What `main` does today: `Game::interact_mob` → `Game::spawn_egg_offspring` (crates/horizon-client/src/game/creatures.rs) uses a spawn egg of the mob's own kind on a mob, spawns the offspring at the parent's position, makes it a baby (`finalize::set_baby`), keeps the parent's variant (and the sheep's wool colour), sends the item-use event and takes one egg less in hand. A wandering trader is left out, because `WanderingTrader.getBreedOffspring` returns null, and a mob that cannot be a baby does not take the egg. What was missing is that the two decisions vanilla makes were buried in the game, where they cannot be tested. PR #2791 moves them into the library, named after the vanilla methods — `spawn_egg_is_for` (`SpawnEggItem.spawnsEntity`: the egg is for the mob's own kind) and `spawn_egg_offspring` (`SpawnEggItem.spawnOffspringFromSpawnEgg`: the baby, with the parent's variant and colour) — and adds `mobs::finalize::tests::a_spawn_egg_offspring_is_a_baby`, which builds a cow from the resources and checks that the offspring is a baby with the parent's variant, that another mob's egg does not match and that a plain item is not an egg. With the baby removed, the test fails on `child.is_baby()`. Vanilla reference: `net.minecraft.world.entity.Mob.checkAndHandleImportantInteractions` (Mob.java:1155) and `net.minecraft.world.item.SpawnEggItem.spawnOffspringFromSpawnEgg` (SpawnEggItem.java:153) — the offspring is the parent's breed (`AgeableMob.getBreedOffspring`), `setBaby(true)`, at the parent's position, with the egg's components, and one egg consumed; the egg of another kind is `InteractionResult.PASS` and the click carries on. One detail worth stating plainly: this path has no mob limit and no message in vanilla 26.3. `Mob.checkAndHandleImportantInteractions` and `SpawnEggItem.spawnOffspringFromSpawnEgg` have neither; the limit belongs to `EntityType.canSpawn` on the block path (`SpawnEggItem.useOn`). So the "you already have too many mobs of that type" message is not part of the animal path, and Horizon's path does not have one either. Self-check: `cargo test -p horizon-client --lib -- spawn_egg` → 1 passed, 0 failed.
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#622
No description provided.