[PR #4990] [MERGED] Run a mob's age boundary when it grows up, not only when it spawns #5993

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4990
Author: @MSedgeMC
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: fix/villager-age-boundary


📝 Commits (1)

  • 3edd56c Run a mob's age boundary when it grows up, not only when it spawns

📊 Changes

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

View changed files

📝 crates/horizon-client/src/game/sulfur_cubes.rs (+2 -1)
📝 crates/horizon-client/src/mobs/ai.rs (+74 -5)

📄 Description

Fixes AgeableMob.ageBoundaryReached being unreachable after spawn. (No issue; from the port ledger.)

Vanilla's AgeableMob.setAge is the only caller of ageBoundaryReached, and it calls it exactly when the age crosses zero — (old < 0 && age >= 0) || (old >= 0 && age < 0). That crossing is where Goat sets attack damage 1.0 → 2.0, Hoglin 0.5 → 6.0, and SulfurCube calls setSize(2, true).

Horizon wrote m.extra.age directly in both growth paths — the per-tick aiStep growth and age_up (feeding) — so finalize::age_boundary_reached only ever ran at spawn. It set the baby values correctly at birth and never updated them: a baby goat that grew up in a world, fed or not, kept attack damage 1.0 for life.

Both paths now go through the existing finalize::set_age, and so do a sheep's ate (vanilla's ageUp(60, false)) and the sulfur cube's own feeding, which was the one inline growth in the bin whose species has real boundary work. set_age fires only on a sign change, so every non-crossing step is bit-identical to before.

One thing worth knowing about reachability, because it explains why this is smaller than it sounds: Animal.mobInteract feeds with ageUp(getSpeedUpSecondsWhenFeeding(-age), true), which is 10% of the remaining ticks truncated to an int — below 200 ticks it adds nothing, so feeding can never cross the boundary. The crossings that happen in play are the organic per-tick ones. Fixing only the feeding path would have been vanilla-correct and invisible; the per-tick path is the one that matters.

Turtle deliberately left hand-patched: Turtle.ageBoundaryReached drops the TURTLE_GROW gift loot only on a ServerLevel with the mob_drops gamerule. That is a MobEvent::GiftLoot handled by Game, not something a &mut Mob hook can reach, so the two existing patches stay and no scute drops twice (the hook has no turtle arm).

Proven: cargo test -p horizon-client --lib age_up_tests → 2 passed on a build box: a goat at age −21 fed through age_up twice is still a 1.0 baby after the first and a 2.0 adult after the second, and a goat one tick from the boundary reaches 2.0 on its own tick. Both are red on main, where the damage stays 1.0.

Not proven: nothing in a game, and no harness — tools/test_mob_ai_parity.py has no growth scenario and neither the probe nor the oracle reports attribute bases, so adding goat_grows_up means extending both. A reviewer will probably want that; it is the honest follow-up rather than something I could build here.

Two deliberate non-conversions: llama and horse feeding have the same shape but no species boundary work (and their call sites also omit vanilla's forced = true bookkeeping, a separate deviation), and the tadpole has its own growth model.


🔄 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/4990 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/villager-age-boundary` --- ### 📝 Commits (1) - [`3edd56c`](https://github.com/horizon-rust/horizon/commit/3edd56c5e4c40a12420e004f656db95e5898732b) Run a mob's age boundary when it grows up, not only when it spawns ### 📊 Changes **2 files changed** (+76 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/sulfur_cubes.rs` (+2 -1) 📝 `crates/horizon-client/src/mobs/ai.rs` (+74 -5) </details> ### 📄 Description Fixes `AgeableMob.ageBoundaryReached` being unreachable after spawn. (No issue; from the port ledger.) Vanilla's `AgeableMob.setAge` is the only caller of `ageBoundaryReached`, and it calls it exactly when the age crosses zero — `(old < 0 && age >= 0) || (old >= 0 && age < 0)`. That crossing is where `Goat` sets attack damage 1.0 → 2.0, `Hoglin` 0.5 → 6.0, and `SulfurCube` calls `setSize(2, true)`. Horizon wrote `m.extra.age` directly in **both** growth paths — the per-tick `aiStep` growth and `age_up` (feeding) — so `finalize::age_boundary_reached` only ever ran at spawn. It set the baby values correctly at birth and never updated them: a baby goat that grew up in a world, fed or not, kept attack damage 1.0 for life. Both paths now go through the existing `finalize::set_age`, and so do a sheep's `ate` (vanilla's `ageUp(60, false)`) and the sulfur cube's own feeding, which was the one inline growth in the bin whose species has real boundary work. `set_age` fires only on a sign change, so every non-crossing step is bit-identical to before. **One thing worth knowing about reachability**, because it explains why this is smaller than it sounds: `Animal.mobInteract` feeds with `ageUp(getSpeedUpSecondsWhenFeeding(-age), true)`, which is 10% of the *remaining* ticks truncated to an int — below 200 ticks it adds nothing, so feeding can never cross the boundary. The crossings that happen in play are the organic per-tick ones. Fixing only the feeding path would have been vanilla-correct and invisible; the per-tick path is the one that matters. **Turtle deliberately left hand-patched:** `Turtle.ageBoundaryReached` drops the `TURTLE_GROW` gift loot only on a `ServerLevel` with the `mob_drops` gamerule. That is a `MobEvent::GiftLoot` handled by `Game`, not something a `&mut Mob` hook can reach, so the two existing patches stay and no scute drops twice (the hook has no turtle arm). **Proven:** `cargo test -p horizon-client --lib age_up_tests` → 2 passed on a build box: a goat at age −21 fed through `age_up` twice is still a 1.0 baby after the first and a 2.0 adult after the second, and a goat one tick from the boundary reaches 2.0 on its own tick. Both are red on `main`, where the damage stays 1.0. **Not proven:** nothing in a game, and no harness — `tools/test_mob_ai_parity.py` has no growth scenario and neither the probe nor the oracle reports attribute bases, so adding `goat_grows_up` means extending both. A reviewer will probably want that; it is the honest follow-up rather than something I could build here. Two deliberate non-conversions: llama and horse feeding have the same shape but no species boundary work (and their call sites also omit vanilla's `forced = true` bookkeeping, a separate deviation), and the tadpole has its own growth model. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:16:28 +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#5993
No description provided.