[PR #7402] [MERGED] Hatch a ghastling with its own setup, not an adult's #7580

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

📋 Pull Request Information

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

Base: main ← Head: fix/ghastling-age


📝 Commits (1)

  • f395135 Hatch a ghastling with its own setup, not an adult's

📊 Changes

4 files changed (+48 additions, -2 deletions)

View changed files

📝 crates/horizon-client/src/game/ghasts.rs (+6 -1)
📝 crates/horizon-client/src/mobs/finalize.rs (+5 -0)
📝 crates/horizon-client/src/mobs/happy_ghast.rs (+36 -0)
📝 tools/port_map/game-012.tsv (+1 -1)

📄 Description

A hydrated dried ghast hatches a baby happy ghast. DriedGhastBlock.spawnGhastling creates the mob, calls setBaby(true), and only then calls addFreshEntity; AgeableMob.setBaby reaches setAge, which crosses the age boundary and runs HappyGhast.ageBoundaryReached — babyGhastSetup — while the mob is still outside the level. So the ghastling joins the world already set up as a ghastling: baby dimensions (0.2375 of the adult box, eye height 0.46875), a baby flying move control and baby flying navigation, no goals (its brain drives it), and the still timeout cleared.

What Horizon got wrong

Horizon's hatch path in game/ghasts.rs called spawn_mob — which registers the age-zero (adult) setup, adultGhastSetup: the three goals (HappyGhastFloat, GhastTempt, FloatAround), a ground navigation and the brain stopped — and only afterwards wrote m.extra.age = -24000 directly on the spawned mob.

finalize::age_boundary_reached had arms for the goat, the hoglin and the sulfur cube but none for the happy ghast, so that age write crossed the boundary without running HappyGhast.ageBoundaryReached at all. The ghastling only picked up its own setup at the next server_ai_step, whose ensure_setup re-runs it.

The box and the model were never wrong (Mob::dims and the renderer read is_baby() live), and the adult goals never ticked as an adult, since server_ai_step calls ensure_setup before goals.tick. What differs is the state the mob is in when it joins the level: its goal set, move control and navigation are the adult's, and the shooting of entity_join_level / mob_spawned (and anything else that reads the mob before its first AI step) sees that adult setup instead of the ghastling's vanilla applies before addFreshEntity.

The fix

  • mobs/finalize.rs: age_boundary_reached gains a Species::HappyGhast arm calling happy_ghast::ensure_setup, matching HappyGhast.ageBoundaryReached (which calls babyGhastSetup or adultGhastSetup and then Animal's no-op).
  • game/ghasts.rs: the hatch now uses finalize::set_age(m, -24000) instead of writing extra.age, so the crossing dispatches and the ghastling's setup is in place before its first tick.
  • tools/port_map/game-012.tsv: the HappyGhast.ageBoundaryReached row named ensure_setup but not the dispatch that reaches it; it now points at finalize.rs::age_boundary_reached.

Proven:

  • cargo test -p horizon-client-lib --lib a_hatched_ghastling — new test at mobs/happy_ghast.rs::tests::a_hatched_ghastling_is_set_up_as_one_at_the_age_crossing. It builds a happy ghast, asserts the adult setup is what construction left (scratch[0] == 2, HappyGhastFloatGoal registered), runs finalize::set_age(.., -24000), and asserts scratch[0] == 1, none of the three adult goals registered, NavKind::Flying and can_float. Fails on main at the scratch[0] assertion (left: 2, right: 1, "babyGhastSetup ran"); passes with the change.
  • 26.3 jar: DriedGhastBlock.spawnGhastling calls HappyGhast.setBaby(true) at bytecode 33-36 and ServerLevel.addFreshEntity at 84-87, in that order. AgeableMob.setBaby calls setAge(getBabyStartAge()), and AgeableMob.setAge calls ageBoundaryReached() when the sign crosses. HappyGhast.ageBoundaryReached calls babyGhastSetup() when isBaby(), then Animal.ageBoundaryReached. HappyGhast.BABY_DIMENSIONS is the type's dimensions scaled by 0.2375f with eye height 0.46875f.
  • cargo clippy -q -p horizon-client-lib --lib and -p horizon-client --lib: silent. rustfmt --edition 2024 --check on the three touched Rust files: clean.

Not proven:

  • The reported symptom itself — a ghastling that looks adult — was the single-player/server draw and box path, already fixed on main by 868069dea (a server's client now reads DATA_BABY_ID for the happy ghast). I did not reproduce the report against a build without that fix, and there is no in-game screenshot here: this PR closes the remaining setup-at-hatch gap from the vanilla order, not the reported model.
  • The visible window is narrow. Because server_ai_step calls ensure_setup before goals.tick, the adult goals never tick as an adult on a living, non-immobile mob; the wrong setup is observable at the join hooks and to anything reading the mob before its first AI step, not as a wrong frame.
  • Sounds: happy_ghast::sounds already selects the entity.ghastling.* set from is_baby() and was not changed here.

🔄 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/7402 **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/ghastling-age` --- ### 📝 Commits (1) - [`f395135`](https://github.com/horizon-rust/horizon/commit/f395135ea5f0ebe34c57928af3ef85c4b7864bdc) Hatch a ghastling with its own setup, not an adult's ### 📊 Changes **4 files changed** (+48 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/ghasts.rs` (+6 -1) 📝 `crates/horizon-client/src/mobs/finalize.rs` (+5 -0) 📝 `crates/horizon-client/src/mobs/happy_ghast.rs` (+36 -0) 📝 `tools/port_map/game-012.tsv` (+1 -1) </details> ### 📄 Description A hydrated dried ghast hatches a baby happy ghast. `DriedGhastBlock.spawnGhastling` creates the mob, calls `setBaby(true)`, and only then calls `addFreshEntity`; `AgeableMob.setBaby` reaches `setAge`, which crosses the age boundary and runs `HappyGhast.ageBoundaryReached` — `babyGhastSetup` — while the mob is still outside the level. So the ghastling joins the world already set up as a ghastling: baby dimensions (0.2375 of the adult box, eye height 0.46875), a baby flying move control and baby flying navigation, no goals (its brain drives it), and the still timeout cleared. ## What Horizon got wrong Horizon's hatch path in `game/ghasts.rs` called `spawn_mob` — which registers the age-zero (adult) setup, `adultGhastSetup`: the three goals (`HappyGhastFloat`, `GhastTempt`, `FloatAround`), a ground navigation and the brain stopped — and only afterwards wrote `m.extra.age = -24000` directly on the spawned mob. `finalize::age_boundary_reached` had arms for the goat, the hoglin and the sulfur cube but none for the happy ghast, so that age write crossed the boundary without running `HappyGhast.ageBoundaryReached` at all. The ghastling only picked up its own setup at the next `server_ai_step`, whose `ensure_setup` re-runs it. The box and the model were never wrong (`Mob::dims` and the renderer read `is_baby()` live), and the adult goals never ticked as an adult, since `server_ai_step` calls `ensure_setup` before `goals.tick`. What differs is the state the mob is *in when it joins the level*: its goal set, move control and navigation are the adult's, and the shooting of `entity_join_level` / `mob_spawned` (and anything else that reads the mob before its first AI step) sees that adult setup instead of the ghastling's vanilla applies before `addFreshEntity`. ## The fix - `mobs/finalize.rs`: `age_boundary_reached` gains a `Species::HappyGhast` arm calling `happy_ghast::ensure_setup`, matching `HappyGhast.ageBoundaryReached` (which calls `babyGhastSetup` or `adultGhastSetup` and then `Animal`'s no-op). - `game/ghasts.rs`: the hatch now uses `finalize::set_age(m, -24000)` instead of writing `extra.age`, so the crossing dispatches and the ghastling's setup is in place before its first tick. - `tools/port_map/game-012.tsv`: the `HappyGhast.ageBoundaryReached` row named `ensure_setup` but not the dispatch that reaches it; it now points at `finalize.rs::age_boundary_reached`. **Proven:** - `cargo test -p horizon-client-lib --lib a_hatched_ghastling` — new test at `mobs/happy_ghast.rs::tests::a_hatched_ghastling_is_set_up_as_one_at_the_age_crossing`. It builds a happy ghast, asserts the adult setup is what construction left (`scratch[0] == 2`, `HappyGhastFloatGoal` registered), runs `finalize::set_age(.., -24000)`, and asserts `scratch[0] == 1`, none of the three adult goals registered, `NavKind::Flying` and `can_float`. Fails on `main` at the `scratch[0]` assertion (`left: 2, right: 1`, "babyGhastSetup ran"); passes with the change. - 26.3 jar: `DriedGhastBlock.spawnGhastling` calls `HappyGhast.setBaby(true)` at bytecode 33-36 and `ServerLevel.addFreshEntity` at 84-87, in that order. `AgeableMob.setBaby` calls `setAge(getBabyStartAge())`, and `AgeableMob.setAge` calls `ageBoundaryReached()` when the sign crosses. `HappyGhast.ageBoundaryReached` calls `babyGhastSetup()` when `isBaby()`, then `Animal.ageBoundaryReached`. `HappyGhast.BABY_DIMENSIONS` is the type's dimensions scaled by `0.2375f` with eye height `0.46875f`. - `cargo clippy -q -p horizon-client-lib --lib` and `-p horizon-client --lib`: silent. `rustfmt --edition 2024 --check` on the three touched Rust files: clean. **Not proven:** - The reported symptom itself — a ghastling that looks adult — was the single-player/server draw and box path, already fixed on `main` by 868069dea (a server's client now reads `DATA_BABY_ID` for the happy ghast). I did not reproduce the report against a build without that fix, and there is no in-game screenshot here: this PR closes the remaining setup-at-hatch gap from the vanilla order, not the reported model. - The visible window is narrow. Because `server_ai_step` calls `ensure_setup` before `goals.tick`, the adult goals never tick as an adult on a living, non-immobile mob; the wrong setup is observable at the join hooks and to anything reading the mob before its first AI step, not as a wrong frame. - Sounds: `happy_ghast::sounds` already selects the `entity.ghastling.*` set from `is_baby()` and was not changed here. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 07:20:11 +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#7580
No description provided.