[PR #2791] [MERGED] The spawn egg's offspring is a named, tested rule #4617

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2791
Author: @levzzz5154
Created: 10/27/2026
Status: ✅ Merged
Merged: 10/28/2026
Merged by: @ludovic111

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


📝 Commits (3)

  • 1654cb5 The spawn egg's offspring is a named, tested rule
  • 91de744 Merge remote-tracking branch 'upstream/main' into fix/spawn-egg-baby
  • 7006807 Keep set_baby's doc comment on set_baby

📊 Changes

2 files changed (+51 additions, -6 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+2 -6)
📝 crates/horizon-client/src/mobs/finalize.rs (+49 -0)

📄 Description

🤖 Opened by levzzz5154's AI agent (Claude Code), not by levzzz5154 himself.

What and why

#2269: right-clicking an animal with its spawn egg did not spawn a baby version.

The behaviour is in main since #2275 (fix/spawn-egg-baby): Game::interact_mob → Game::spawn_egg_offspring uses a spawn egg of the mob's own kind on the mob and spawns the offspring as a baby of that kind at the parent's position, and takes one egg less in hand.

What was missing is that the rule was buried in the game, where it cannot be tested: the two decisions vanilla makes — the egg is for the mob's own kind (SpawnEggItem.spawnsEntity), and the offspring is a baby with the parent's variant and colour (SpawnEggItem.spawnOffspringFromSpawnEgg) — sat inline in Game::spawn_egg_offspring. This pull request moves them into the library, where they are named after the vanilla methods and covered by a test, and has the game call them.

The test (mobs::finalize::tests::a_spawn_egg_offspring_is_a_baby) builds a cow from the resources and checks that the offspring of a spawn egg is a baby with the parent's variant, that an egg of another kind does not match, and that a plain item is not an egg. Without the baby (set_baby) the test fails on child.is_baby().

The "you already have too many of that" message is not part of this path in vanilla: Mob.checkAndHandleImportantInteractions and SpawnEggItem.spawnOffspringFromSpawnEgg have no mob limit and no message (the limit is EntityType.canSpawn on the block path, SpawnEggItem.useOn), so Horizon's path does not have one either.

Fixes #2269

Vanilla reference

  • net.minecraft.world.entity.Mob.checkAndHandleImportantInteractions (Mob.java:1155) — a SpawnEggItem in hand: SpawnEggItem.spawnOffspringFromSpawnEgg(player, this, this.getType(), serverLevel, this.position(), itemStack); the offspring is empty (InteractionResult.PASS) when the egg is not for the mob's own type, and this.onOffspringSpawnedFromEgg(player, mob) runs on the offspring.
  • net.minecraft.world.item.SpawnEggItem.spawnOffspringFromSpawnEgg (SpawnEggItem.java:153) — spawnsEntity (the egg is for this type), AgeableMob.getBreedOffspring (the parent's breed) or EntityType.create, offspring.setBaby(true) (and empty when it cannot be a baby), snapTo the parent's position, applyComponentsFromItemStack, level.addFreshEntityWithPassengers and spawnEggStack.consume(1, player).
  • net.minecraft.world.entity.Mob.getSpawnEgg (Mob.java:1442) — the egg of a mob's own kind.
  • net.minecraft.world.entity.animal.WanderingTrader.getBreedOffspring — null, so no offspring (Horizon keeps that case out).

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on cachyos-x8664, against upstream/main at ab080a540, 4 min 10 s)

Check Result
Scope ✅ 2 files, +51 −6
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 331 passed (17 s)
rustfmt ✅ (5 s)
clippy ✅ (1 min 7 s)
tests: horizon-client ✅ 1330 passed (2 min 2 s)
doc tests ✅ 0 passed (31 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 74 affected, to run in CI (--quick): arrow, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, breaking_model, cauldron, command_exec, composter, crafter and 62 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)
  • cargo test -p horizon-client --lib -- spawn_egg → 1 passed; 0 failed (mobs::finalize::tests::a_spawn_egg_offspring_is_a_baby).
  • The same test with the baby removed from spawn_egg_offspring → FAILED ... assertion failed: child.is_baby().
  • cargo fmt -p horizon-client → clean.
  • python3 tools/check_public_tree.py → "Public tree check passed." (run by the commit hook).

🤖 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/2791 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 10/28/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/spawn-egg-baby` --- ### 📝 Commits (3) - [`1654cb5`](https://github.com/horizon-rust/horizon/commit/1654cb51db5df2bd2263e8b77abdf851d0b158eb) The spawn egg's offspring is a named, tested rule - [`91de744`](https://github.com/horizon-rust/horizon/commit/91de7442503cb1c66ee6a4a5f24cb976ca066d6f) Merge remote-tracking branch 'upstream/main' into fix/spawn-egg-baby - [`7006807`](https://github.com/horizon-rust/horizon/commit/70068076f23c214f438174c8de337a5570c925ee) Keep set_baby's doc comment on set_baby ### 📊 Changes **2 files changed** (+51 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+2 -6) 📝 `crates/horizon-client/src/mobs/finalize.rs` (+49 -0) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code), not by levzzz5154 himself. ## What and why #2269: right-clicking an animal with its spawn egg did not spawn a baby version. The behaviour is in `main` since #2275 (`fix/spawn-egg-baby`): `Game::interact_mob` → `Game::spawn_egg_offspring` uses a spawn egg of the mob's own kind on the mob and spawns the offspring as a baby of that kind at the parent's position, and takes one egg less in hand. What was missing is that the rule was buried in the game, where it cannot be tested: the two decisions vanilla makes — the egg is for the mob's own kind (`SpawnEggItem.spawnsEntity`), and the offspring is a baby with the parent's variant and colour (`SpawnEggItem.spawnOffspringFromSpawnEgg`) — sat inline in `Game::spawn_egg_offspring`. This pull request moves them into the library, where they are named after the vanilla methods and covered by a test, and has the game call them. The test (`mobs::finalize::tests::a_spawn_egg_offspring_is_a_baby`) builds a cow from the resources and checks that the offspring of a spawn egg is a baby with the parent's variant, that an egg of another kind does not match, and that a plain item is not an egg. Without the baby (`set_baby`) the test fails on `child.is_baby()`. The "you already have too many of that" message is not part of this path in vanilla: `Mob.checkAndHandleImportantInteractions` and `SpawnEggItem.spawnOffspringFromSpawnEgg` have no mob limit and no message (the limit is `EntityType.canSpawn` on the block path, `SpawnEggItem.useOn`), so Horizon's path does not have one either. Fixes #2269 ## Vanilla reference - `net.minecraft.world.entity.Mob.checkAndHandleImportantInteractions` (Mob.java:1155) — a `SpawnEggItem` in hand: `SpawnEggItem.spawnOffspringFromSpawnEgg(player, this, this.getType(), serverLevel, this.position(), itemStack)`; the offspring is empty (`InteractionResult.PASS`) when the egg is not for the mob's own type, and `this.onOffspringSpawnedFromEgg(player, mob)` runs on the offspring. - `net.minecraft.world.item.SpawnEggItem.spawnOffspringFromSpawnEgg` (SpawnEggItem.java:153) — `spawnsEntity` (the egg is for this type), `AgeableMob.getBreedOffspring` (the parent's breed) or `EntityType.create`, `offspring.setBaby(true)` (and empty when it cannot be a baby), `snapTo` the parent's position, `applyComponentsFromItemStack`, `level.addFreshEntityWithPassengers` and `spawnEggStack.consume(1, player)`. - `net.minecraft.world.entity.Mob.getSpawnEgg` (Mob.java:1442) — the egg of a mob's own kind. - `net.minecraft.world.entity.animal.WanderingTrader.getBreedOffspring` — null, so no offspring (Horizon keeps that case out). ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on cachyos-x8664, against upstream/main at ab080a540, 4 min 10 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +51 −6 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 331 passed (17 s) | | rustfmt | ✅ (5 s) | | clippy | ✅ (1 min 7 s) | | tests: horizon-client | ✅ 1330 passed (2 min 2 s) | | doc tests | ✅ 0 passed (31 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 74 affected, to run in CI (--quick): arrow, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, breaking_model, cauldron, command_exec, composter, crafter and 62 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | - `cargo test -p horizon-client --lib -- spawn_egg` → `1 passed; 0 failed` (`mobs::finalize::tests::a_spawn_egg_offspring_is_a_baby`). - The same test with the baby removed from `spawn_egg_offspring` → `FAILED ... assertion failed: child.is_baby()`. - `cargo fmt -p horizon-client` → clean. - `python3 tools/check_public_tree.py` → "Public tree check passed." (run by the commit hook). 🤖 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-03 05:06:42 +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#4617
No description provided.