[PR #7750] Native hooks: mob_split, baby_entity_spawn #7797

Open
opened 2026-11-03 07:24:17 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7750
Author: @levzzz5154
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: native/mob-split-baby-spawn


📝 Commits (2)

  • da55dd6 Native mods: mob_split and baby_entity_spawn hooks
  • de39b5b Native hooks: mob_split and baby_entity_spawn name kinds with their namespace

📊 Changes

5 files changed (+238 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+44 -1)
📝 crates/horizon-client/src/game/native_hooks.rs (+58 -0)
📝 crates/horizon-client/src/mod_api/generated.rs (+102 -0)
➕ tools/native-hook-fragments/baby_entity_spawn.json (+17 -0)
➕ tools/native-hook-fragments/mob_split.json (+17 -0)

📄 Description

🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally.

Part of #4953: mob_split, baby_entity_spawn.

What it adds

Neither name existed before. entity_breed already exists but only listens after a breeding; it is kept as it is.
Both hooks are server side, cancellable, and cost nothing without mods (the dispatch is over an empty list;
baby_entity_spawn also skips building its arguments when no mod is loaded). No random draw is added, dropped
or moved.

  • mob_split (NeoForge MobSplitEvent). Vanilla Slime.remove, for a dying slime or magma cube above size 1,
    right after the 2 to 4 child count is drawn. Arguments: parent (entity id), kind, size, child_size
    (size / 2), count. A mod may change count (0 to 64) or set cancel: no children spawn. The random draw
    for the count is made first, so the world's random is the same whatever a mod does. Sulfur cubes
    (split_sulfur_cube) are not covered.
  • baby_entity_spawn (NeoForge BabyEntitySpawnEvent). Fires at the start of Horizon's breed(), before the baby
    is made. Arguments: parent, partner (entity ids), player (UUID of the player who fed them into love, 0
    when none), kind (the baby's type; horse plus donkey is minecraft:mule). Cancel: no baby, no experience
    orb, no animals_bred statistic, no bred_animals advancement and no heart particles. The parents still
    rest and lose their love (age 6000, love 0). That matches NeoForge, whose cancel path resets the parents'
    age and love and returns before finalizeSpawnChildFromBreeding. Horizon's mob tick already set the parent's
    age and love before the game sees the breed event, so only the partner is set again.
    • Covered: every animal that makes a baby through breed() (cows, pigs, sheep, chickens, horses, donkeys,
      mules, llamas, cats, wolves, foxes, pandas, goats, axolotls, mooshrooms, nautili, armadillos).
    • Not covered: turtles and frogs (the egg or spawn is placed by their goal), sniffers (an egg), villagers
      (villagers.rs giveBirth path). For llamas and
      sniffers the experience and, for a sniffer, the plop sound are made in the parent's tick before the game
      sees the breed, so a cancel there stops the baby only.
    • entity_breed still fires after a cancel, with no child.
    • The mod cannot replace the child (NeoForge's setChild); not offered.

Proof

A throwaway eprintln!("TESTHOOK ...") in each native_* fn (removed; git diff shows none), with env switches
TESTHOOK_CANCEL, TESTHOOK_COUNT=7, and one to open the baby gate without a mod. Built --profile fast, driven
offscreen with horizon-ctl launch --world W --creative --offscreen --wait in scratch homes: summon a size-3 slime,
a size-2 magma cube, two cows with InLove:600; kill the slimes; wait; kill @e[type=cow] to count.

TESTHOOK mob_split parent=708 kind=minecraft:slime size=3 child=1 count=2
TESTHOOK mob_split parent=709 kind=minecraft:magma_cube size=2 child=1 count=4
TESTHOOK baby parent=712 partner=711 player=0 kind=minecraft:cow
Run Slimes after the kills Cows
no mod behaviour (hooks only print) 2 and 4 children (as drawn) 3 (a baby)
TESTHOOK_CANCEL none left 2 (no baby)
TESTHOOK_COUNT=7 7 children each 2

Not run: a dedicated server, a fed-by-player cow (the player UUID path; the test cows had no feeder, so it
printed 0), horse and donkey (they need taming, so did not breed), a real native mod bundle, the parity harnesses.

pr_ready (tools/pr_ready.py --quick --base hr/main on cachyos-x8664, against hr/main at 6ed5b17a6, 2 min 42 s)

Check Result
Scope ✅ 5 files, +237 −1
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 614 passed (33 s)
rustfmt ✅ (6 s)
clippy ✅ (51 s)
tests: horizon-client, horizon-client-lib ✅ 2184 passed (56 s)
doc tests ✅ 0 passed (2 s)
content root tests ➖ content root untouched
mod API up to date ✅ (14 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 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/7750 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `native/mob-split-baby-spawn` --- ### 📝 Commits (2) - [`da55dd6`](https://github.com/horizon-rust/horizon/commit/da55dd6ef656ebc1f13bf89996c0d7402e866a29) Native mods: mob_split and baby_entity_spawn hooks - [`de39b5b`](https://github.com/horizon-rust/horizon/commit/de39b5b799d22467b3cea5693630487b1d5c1641) Native hooks: mob_split and baby_entity_spawn name kinds with their namespace ### 📊 Changes **5 files changed** (+238 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+44 -1) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+58 -0) 📝 `crates/horizon-client/src/mod_api/generated.rs` (+102 -0) ➕ `tools/native-hook-fragments/baby_entity_spawn.json` (+17 -0) ➕ `tools/native-hook-fragments/mob_split.json` (+17 -0) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally. Part of #4953: `mob_split`, `baby_entity_spawn`. ## What it adds Neither name existed before. `entity_breed` already exists but only listens after a breeding; it is kept as it is. Both hooks are server side, cancellable, and cost nothing without mods (the dispatch is over an empty list; `baby_entity_spawn` also skips building its arguments when no mod is loaded). No random draw is added, dropped or moved. - **`mob_split`** (NeoForge `MobSplitEvent`). Vanilla `Slime.remove`, for a dying slime or magma cube above size 1, right after the 2 to 4 child count is drawn. Arguments: `parent` (entity id), `kind`, `size`, `child_size` (size / 2), `count`. A mod may change `count` (0 to 64) or set `cancel`: no children spawn. The random draw for the count is made first, so the world's random is the same whatever a mod does. Sulfur cubes (`split_sulfur_cube`) are not covered. - **`baby_entity_spawn`** (NeoForge `BabyEntitySpawnEvent`). Fires at the start of Horizon's `breed()`, before the baby is made. Arguments: `parent`, `partner` (entity ids), `player` (UUID of the player who fed them into love, 0 when none), `kind` (the baby's type; horse plus donkey is `minecraft:mule`). Cancel: no baby, no experience orb, no `animals_bred` statistic, no `bred_animals` advancement and no heart particles. The parents still rest and lose their love (age 6000, love 0). That matches NeoForge, whose cancel path resets the parents' age and love and returns before `finalizeSpawnChildFromBreeding`. Horizon's mob tick already set the parent's age and love before the game sees the breed event, so only the partner is set again. - Covered: every animal that makes a baby through `breed()` (cows, pigs, sheep, chickens, horses, donkeys, mules, llamas, cats, wolves, foxes, pandas, goats, axolotls, mooshrooms, nautili, armadillos). - Not covered: turtles and frogs (the egg or spawn is placed by their goal), sniffers (an egg), villagers (`villagers.rs` giveBirth path). For llamas and sniffers the experience and, for a sniffer, the plop sound are made in the parent's tick before the game sees the breed, so a cancel there stops the baby only. - `entity_breed` still fires after a cancel, with no child. - The mod cannot replace the child (NeoForge's `setChild`); not offered. ## Proof A throwaway `eprintln!("TESTHOOK ...")` in each `native_*` fn (removed; `git diff` shows none), with env switches `TESTHOOK_CANCEL`, `TESTHOOK_COUNT=7`, and one to open the baby gate without a mod. Built `--profile fast`, driven offscreen with `horizon-ctl launch --world W --creative --offscreen --wait` in scratch homes: summon a size-3 slime, a size-2 magma cube, two cows with `InLove:600`; `kill` the slimes; wait; `kill @e[type=cow]` to count. ``` TESTHOOK mob_split parent=708 kind=minecraft:slime size=3 child=1 count=2 TESTHOOK mob_split parent=709 kind=minecraft:magma_cube size=2 child=1 count=4 TESTHOOK baby parent=712 partner=711 player=0 kind=minecraft:cow ``` | Run | Slimes after the kills | Cows | | --- | --- | --- | | no mod behaviour (hooks only print) | 2 and 4 children (as drawn) | 3 (a baby) | | `TESTHOOK_CANCEL` | none left | 2 (no baby) | | `TESTHOOK_COUNT=7` | 7 children each | 2 | Not run: a dedicated server, a fed-by-player cow (the `player` UUID path; the test cows had no feeder, so it printed 0), horse and donkey (they need taming, so did not breed), a real native mod bundle, the parity harnesses. **pr_ready** (`tools/pr_ready.py --quick --base hr/main` on cachyos-x8664, against hr/main at 6ed5b17a6, 2 min 42 s) | Check | Result | | --- | --- | | Scope | ✅ 5 files, +237 −1 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 614 passed (33 s) | | rustfmt | ✅ (6 s) | | clippy | ✅ (51 s) | | tests: horizon-client, horizon-client-lib | ✅ 2184 passed (56 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (14 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 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>
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#7797
No description provided.