[PR #7174] [MERGED] A bred foal follows the nearest bred horse #7394

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7174
Author: @MSedgeMC
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: fix/horse-follow-mommy


📝 Commits (1)

  • 0167e02 A bred foal follows the nearest bred horse

📊 Changes

4 files changed (+198 additions, -5 deletions)

View changed files

📝 crates/horizon-client/src/entity_nbt.rs (+5 -4)
📝 crates/horizon-client/src/mobs.rs (+7 -0)
📝 crates/horizon-client/src/mobs/equine.rs (+185 -0)
📝 tools/port_map/game-011.tsv (+1 -1)

📄 Description

AbstractHorse.aiStep ends with followMommy(ServerLevel): a horse that is isBred, isBaby and not isEating looks for the nearest net.minecraft.world.entity.animal.equine.AbstractHorse that is isBred within 16 blocks (the MOMMY_TARGETING conditions, forNonCombat().range(16).ignoreLineOfSight() with PARENT_HORSE_SELECTOR, over its own box inflated by 16) and, when distanceToSqr(mommy) > 4.0, runs navigation.createPath(mommy, 0) — a path installed without touching the navigation's speed modifier.

Horizon modelled neither half: MobExtra had no Bred flag, the save wrote a constant Bred:0b and readAdditionalSaveData ignored the key, so no foal was ever pulled to its mother, and a save that carried Bred:1b lost it on the next save.

MobExtra.bred now holds the flag; entity_nbt writes it and reads it back for horses, donkeys, mules, skeleton and zombie horses, llamas and trader llamas; Seen.bred lets a foal read the flag on the horses it can see; and equine::follow_mommy runs where AbstractHorse.aiStep calls it — at the end of the horse's ai_step, and before the camel and llama ai_steps that vanilla reaches through super.aiStep(). The path goes in through create_path_to_entity (reach 0) and nav_move_to_path at the navigation's current speed_modifier, which is what createPath(entity, 0) leaves alone.

Nothing in 26.3 sets Bred at runtime (setBred has one caller, readAdditionalSaveData, and no subclass writes flag 8), so this shows up only for a horse whose save or /summon NBT carries Bred:1b — I checked every setBred/setFlag reference in the jar rather than assuming.

Proven: on the build VM, cargo test -q -p horizon-client-lib --lib follow_mommy_tests passes the new a_bred_foal_paths_to_the_nearest_bred_horse (1 passed), which runs a real ai_step over a stone floor and reads the navigation target: a bred foal with a bred horse 6 blocks away ends with a path to [6, 1, 0], and the nearer of two bred horses wins. The same test checks that no path appears for a foal that is not bred, an adult, a foal that is eating, a grown horse that is not bred, a cow, a horse 20 blocks away (outside range(16)) or a horse 1 block away (inside distanceToSqr > 4). cargo clippy -q -p horizon-client-lib --lib and -p horizon-client --lib print nothing, rustfmt --edition 2024 --check is clean on the three files, and python3 tools/port_ledger.py map-check tools/port_map/game-011.tsv reports 148 rows, no problems. The vanilla logic is javap -p -c -constants net.minecraft.world.entity.animal.equine.AbstractHorse → aiStep's last call, followMommy, getSlot, addAdditionalSaveData/readAdditionalSaveData, and the static initializer's MOMMY_TARGETING.

Not proven: the walk itself — the test reads the path the foal installed, not a ticked-out walk, and I did not run the game, so I have not watched a foal cross the field. AbstractHorse.getSlot (the other row of that batch) is untouched: /item still cannot reach a horse's slots. No test covers a camel or llama foal, which reach follow_mommy through the early returns in equine::ai_step.

Corrects the AbstractHorse.followMommy row of tools/port_map/game-011.tsv.


🔄 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/7174 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/horse-follow-mommy` --- ### 📝 Commits (1) - [`0167e02`](https://github.com/horizon-rust/horizon/commit/0167e02866f148184033a46fa1ed3e3fc5c450c9) A bred foal follows the nearest bred horse ### 📊 Changes **4 files changed** (+198 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/entity_nbt.rs` (+5 -4) 📝 `crates/horizon-client/src/mobs.rs` (+7 -0) 📝 `crates/horizon-client/src/mobs/equine.rs` (+185 -0) 📝 `tools/port_map/game-011.tsv` (+1 -1) </details> ### 📄 Description `AbstractHorse.aiStep` ends with `followMommy(ServerLevel)`: a horse that is `isBred`, `isBaby` and not `isEating` looks for the nearest `net.minecraft.world.entity.animal.equine.AbstractHorse` that is `isBred` within 16 blocks (the `MOMMY_TARGETING` conditions, `forNonCombat().range(16).ignoreLineOfSight()` with `PARENT_HORSE_SELECTOR`, over its own box inflated by 16) and, when `distanceToSqr(mommy) > 4.0`, runs `navigation.createPath(mommy, 0)` — a path installed without touching the navigation's speed modifier. Horizon modelled neither half: `MobExtra` had no `Bred` flag, the save wrote a constant `Bred:0b` and `readAdditionalSaveData` ignored the key, so no foal was ever pulled to its mother, and a save that carried `Bred:1b` lost it on the next save. `MobExtra.bred` now holds the flag; `entity_nbt` writes it and reads it back for horses, donkeys, mules, skeleton and zombie horses, llamas and trader llamas; `Seen.bred` lets a foal read the flag on the horses it can see; and `equine::follow_mommy` runs where `AbstractHorse.aiStep` calls it — at the end of the horse's `ai_step`, and before the camel and llama `ai_step`s that vanilla reaches through `super.aiStep()`. The path goes in through `create_path_to_entity` (reach 0) and `nav_move_to_path` at the navigation's current `speed_modifier`, which is what `createPath(entity, 0)` leaves alone. Nothing in 26.3 sets `Bred` at runtime (`setBred` has one caller, `readAdditionalSaveData`, and no subclass writes flag 8), so this shows up only for a horse whose save or `/summon` NBT carries `Bred:1b` — I checked every `setBred`/`setFlag` reference in the jar rather than assuming. **Proven:** on the build VM, `cargo test -q -p horizon-client-lib --lib follow_mommy_tests` passes the new `a_bred_foal_paths_to_the_nearest_bred_horse` (`1 passed`), which runs a real `ai_step` over a stone floor and reads the navigation target: a bred foal with a bred horse 6 blocks away ends with a path to `[6, 1, 0]`, and the nearer of two bred horses wins. The same test checks that no path appears for a foal that is not bred, an adult, a foal that is eating, a grown horse that is not bred, a cow, a horse 20 blocks away (outside `range(16)`) or a horse 1 block away (inside `distanceToSqr > 4`). `cargo clippy -q -p horizon-client-lib --lib` and `-p horizon-client --lib` print nothing, `rustfmt --edition 2024 --check` is clean on the three files, and `python3 tools/port_ledger.py map-check tools/port_map/game-011.tsv` reports `148 rows, no problems`. The vanilla logic is `javap -p -c -constants net.minecraft.world.entity.animal.equine.AbstractHorse` → `aiStep`'s last call, `followMommy`, `getSlot`, `addAdditionalSaveData`/`readAdditionalSaveData`, and the static initializer's `MOMMY_TARGETING`. **Not proven:** the walk itself — the test reads the path the foal installed, not a ticked-out walk, and I did not run the game, so I have not watched a foal cross the field. `AbstractHorse.getSlot` (the other row of that batch) is untouched: `/item` still cannot reach a horse's slots. No test covers a camel or llama foal, which reach `follow_mommy` through the early returns in `equine::ai_step`. Corrects the `AbstractHorse.followMommy` row of `tools/port_map/game-011.tsv`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:38:53 +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#7394
No description provided.