[PR #2586] [MERGED] Worldgen: chunk generation spawns its animals as vanilla, ticking or not #4449

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2586
Author: @FusselTV
Created: 10/27/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @ludovic111

Base: main ← Head: fix/generation-animals


📝 Commits (3)

  • 266c7a2 Worldgen: finalize structure mobs at placement, as vanilla
  • 1a80673 Worldgen: structure mobs save the fields vanilla's chunk keeps
  • 22054ee Worldgen: chunk generation spawns its animals as vanilla, ticking or not

📊 Changes

21 files changed (+1052 additions, -106 deletions)

View changed files

📝 crates/horizon-client/examples/probe/finalize_spawn_fixture.rs (+3 -2)
📝 crates/horizon-client/examples/probe/natural_spawn_fixture.rs (+1 -1)
📝 crates/horizon-client/src/entity_nbt.rs (+251 -16)
📝 crates/horizon-client/src/game.rs (+4 -0)
📝 crates/horizon-client/src/game/creatures.rs (+13 -3)
📝 crates/horizon-client/src/game/levels.rs (+1 -0)
📝 crates/horizon-client/src/game/natural_spawning.rs (+77 -28)
📝 crates/horizon-client/src/game/persist.rs (+10 -2)
📝 crates/horizon-client/src/game/raids.rs (+1 -1)
📝 crates/horizon-client/src/mobs/finalize.rs (+8 -3)
📝 crates/horizon-client/src/mobs/nautilus.rs (+0 -13)
📝 crates/horizon-client/src/mobs/spawn_selection.rs (+13 -12)
📝 crates/horizon-client/src/mobs/spawner.rs (+9 -1)
📝 crates/horizon-client/src/mobs/trial_spawner.rs (+9 -1)
📝 crates/horizon-client/src/vanillagen.rs (+34 -1)
➕ crates/horizon-client/src/vanillagen/structure_mobs.rs (+519 -0)
📝 crates/horizon-world/src/worldgen/generator.rs (+44 -11)
📝 crates/horizon-world/src/worldgen/generator_decoration.rs (+42 -9)
📝 crates/horizon-world/src/worldgen/structure/legacy.rs (+6 -1)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaFinalizeSpawnOracle.java (+1 -1)

...and 1 more files

📄 Description

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

What and why

Builds on #2544 (and #2437 under it); please review the last commit.

Vanilla places a chunk's passive animals while generating it: NoiseBasedChunkGenerator.spawnOriginalMobs → NaturalSpawner.spawnMobsForChunkGeneration, at the SPAWN step, with the WorldGenRegion's random for the spawn rules and finalizeSpawn. Horizon ran the same selection from the game tick, for chunks that were fresh and lit. So:

  • a world generated with ticks frozen, as a seed generator does, had no animals at all; seed 12345, 512 × 512 blocks, mob spawning on: vanilla 25, Horizon 0;
  • with ticks running, Horizon placed fewer (pig 9 / 15, sheep 3 / 8, chicken 3 / 6, rabbit 3 / 5), and they had no variants, babies or group data: the rules and finalizeSpawn drew from other randoms and the reduced spawning::finalize was used;
  • the spawn list and costs came from the biome's noise cell, while vanilla reads the zoomed biome (NATURAL_MOB_SPAWNS is fullResolutionBiomes; the spawn probability is not);
  • members of a pack kept each other out, while a WorldGenRegion has no entities in the way (getEntities is empty).

What changes:

  • A chunk gets its animals as soon as it is lit, whatever the tick state (Game::spawn_fresh_chunks, called after the streaming update instead of from the creature tick).
  • The positions come from the same selection, which already matches vanilla. The rules and finalizeSpawn draw from the chunk's region random (OverworldGenerator::region_random, shared with decoration).
  • Each mob is made with its constructor's state and finalized like a structure mob (Reason::ChunkGeneration, group data per pack), then loaded from the NBT generation would save.
  • The spawn list, spawn costs and biome tags of natural spawning read the zoomed biome; the spawn probability keeps the noise cell.
  • At generation, pack members do not obstruct each other.
  • Goats and frogs keep their cooldowns under vanilla's memory names (long_jump_cooling_down, ram_cooldown_ticks), and rabbits save the attack damage attribute Rabbit.setVariant makes.
  • Test oracle: VanillaNaturalSpawnOracle's generation mode sees no entities, as a WorldGenRegion.

Vanilla reference

  • NoiseBasedChunkGenerator.spawnOriginalMobs, NaturalSpawner.spawnMobsForChunkGeneration.
  • WorldGenRegion: random (worldgen_region_random at the center), getEntities (empty), getCurrentDifficultyAt.
  • EnvironmentAttributes.NATURAL_MOB_SPAWNS (fullResolutionBiomes), CREATURE_WORLD_GEN_SPAWN_PROBABILITY.
  • MemoryModuleType.LONG_JUMP_COOLDOWN_TICKS / RAM_COOLDOWN_TICKS; Rabbit.setVariant.

Tests

  • tools/test_natural_spawn_parity.py: 15,500 cases match vanilla. Negative control: with pack members still obstructing each other, generation case 1466 differs from the corrected oracle.

  • tools/test_finalize_spawn_parity.py: 24,000 cases match.

  • End to end, 512 × 512 blocks with mob spawning on, compared with vanilla 26.3 (a second vanilla run in brackets):

    Seed Same position Chunks with other animals
    12345 25 of 25 (25 of 25) 0 (0)
    1 13 of 17 (12 of 17) 1 (3)
    8675309 119 of 140 (112 of 140) 15 (15)

    Seed 12345 with ticks frozen: all 25 animals at vanilla's exact positions. The remaining differences sit where vanilla's own decoration differs between runs.

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on d56d30548c99, against upstream/main at cb43e3278, 9 min 54 s)

Check Result
Scope ⚠️ 21 files, +1052 −106; 1150 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 320 passed (28 s)
rustfmt ✅ (8 s)
clippy ✅ (2 min 3 s)
tests: horizon-client, horizon-world ✅ 1582 passed (5 min 55 s)
doc tests ✅ 0 passed (1 min 17 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 334 affected, to run in CI (--quick): arrow, attribute_map_queries, attribute_updates, auto_jump, bamboo, biome_source_codec, biome_temperature, biome_weather, biome_zoom, block_blob, block_collision_scan, block_column and 322 more
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/2586 **Author:** [@FusselTV](https://github.com/FusselTV) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/generation-animals` --- ### 📝 Commits (3) - [`266c7a2`](https://github.com/horizon-rust/horizon/commit/266c7a2cd92116965fd379884591ddab373b3f46) Worldgen: finalize structure mobs at placement, as vanilla - [`1a80673`](https://github.com/horizon-rust/horizon/commit/1a80673d50561657398e977cdd4618b1011a5c07) Worldgen: structure mobs save the fields vanilla's chunk keeps - [`22054ee`](https://github.com/horizon-rust/horizon/commit/22054eee9000528cec04c9c95c4885248f9a8112) Worldgen: chunk generation spawns its animals as vanilla, ticking or not ### 📊 Changes **21 files changed** (+1052 additions, -106 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/probe/finalize_spawn_fixture.rs` (+3 -2) 📝 `crates/horizon-client/examples/probe/natural_spawn_fixture.rs` (+1 -1) 📝 `crates/horizon-client/src/entity_nbt.rs` (+251 -16) 📝 `crates/horizon-client/src/game.rs` (+4 -0) 📝 `crates/horizon-client/src/game/creatures.rs` (+13 -3) 📝 `crates/horizon-client/src/game/levels.rs` (+1 -0) 📝 `crates/horizon-client/src/game/natural_spawning.rs` (+77 -28) 📝 `crates/horizon-client/src/game/persist.rs` (+10 -2) 📝 `crates/horizon-client/src/game/raids.rs` (+1 -1) 📝 `crates/horizon-client/src/mobs/finalize.rs` (+8 -3) 📝 `crates/horizon-client/src/mobs/nautilus.rs` (+0 -13) 📝 `crates/horizon-client/src/mobs/spawn_selection.rs` (+13 -12) 📝 `crates/horizon-client/src/mobs/spawner.rs` (+9 -1) 📝 `crates/horizon-client/src/mobs/trial_spawner.rs` (+9 -1) 📝 `crates/horizon-client/src/vanillagen.rs` (+34 -1) ➕ `crates/horizon-client/src/vanillagen/structure_mobs.rs` (+519 -0) 📝 `crates/horizon-world/src/worldgen/generator.rs` (+44 -11) 📝 `crates/horizon-world/src/worldgen/generator_decoration.rs` (+42 -9) 📝 `crates/horizon-world/src/worldgen/structure/legacy.rs` (+6 -1) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaFinalizeSpawnOracle.java` (+1 -1) _...and 1 more files_ </details> ### 📄 Description > 🤖 Opened by FusselTV's AI agent (Claude Code, Opus 5.5), not by FusselTV personally. ## What and why Builds on #2544 (and #2437 under it); please review the last commit. Vanilla places a chunk's passive animals while generating it: `NoiseBasedChunkGenerator.spawnOriginalMobs` → `NaturalSpawner.spawnMobsForChunkGeneration`, at the SPAWN step, with the `WorldGenRegion`'s random for the spawn rules and `finalizeSpawn`. Horizon ran the same selection from the game tick, for chunks that were fresh and lit. So: - a world generated with ticks frozen, as a seed generator does, had no animals at all; seed 12345, 512 × 512 blocks, mob spawning on: vanilla 25, Horizon 0; - with ticks running, Horizon placed fewer (pig 9 / 15, sheep 3 / 8, chicken 3 / 6, rabbit 3 / 5), and they had no variants, babies or group data: the rules and `finalizeSpawn` drew from other randoms and the reduced `spawning::finalize` was used; - the spawn list and costs came from the biome's noise cell, while vanilla reads the zoomed biome (`NATURAL_MOB_SPAWNS` is `fullResolutionBiomes`; the spawn probability is not); - members of a pack kept each other out, while a `WorldGenRegion` has no entities in the way (`getEntities` is empty). What changes: - A chunk gets its animals as soon as it is lit, whatever the tick state (`Game::spawn_fresh_chunks`, called after the streaming update instead of from the creature tick). - The positions come from the same selection, which already matches vanilla. The rules and `finalizeSpawn` draw from the chunk's region random (`OverworldGenerator::region_random`, shared with decoration). - Each mob is made with its constructor's state and finalized like a structure mob (`Reason::ChunkGeneration`, group data per pack), then loaded from the NBT generation would save. - The spawn list, spawn costs and biome tags of natural spawning read the zoomed biome; the spawn probability keeps the noise cell. - At generation, pack members do not obstruct each other. - Goats and frogs keep their cooldowns under vanilla's memory names (`long_jump_cooling_down`, `ram_cooldown_ticks`), and rabbits save the attack damage attribute `Rabbit.setVariant` makes. - Test oracle: `VanillaNaturalSpawnOracle`'s generation mode sees no entities, as a `WorldGenRegion`. ## Vanilla reference - `NoiseBasedChunkGenerator.spawnOriginalMobs`, `NaturalSpawner.spawnMobsForChunkGeneration`. - `WorldGenRegion`: `random` (`worldgen_region_random` at the center), `getEntities` (empty), `getCurrentDifficultyAt`. - `EnvironmentAttributes.NATURAL_MOB_SPAWNS` (`fullResolutionBiomes`), `CREATURE_WORLD_GEN_SPAWN_PROBABILITY`. - `MemoryModuleType.LONG_JUMP_COOLDOWN_TICKS` / `RAM_COOLDOWN_TICKS`; `Rabbit.setVariant`. ## Tests - `tools/test_natural_spawn_parity.py`: 15,500 cases match vanilla. Negative control: with pack members still obstructing each other, generation case 1466 differs from the corrected oracle. - `tools/test_finalize_spawn_parity.py`: 24,000 cases match. - End to end, 512 × 512 blocks with mob spawning on, compared with vanilla 26.3 (a second vanilla run in brackets): | Seed | Same position | Chunks with other animals | |---|---|---| | 12345 | 25 of 25 (25 of 25) | 0 (0) | | 1 | 13 of 17 (12 of 17) | 1 (3) | | 8675309 | 119 of 140 (112 of 140) | 15 (15) | Seed 12345 with ticks frozen: all 25 animals at vanilla's exact positions. The remaining differences sit where vanilla's own decoration differs between runs. ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on d56d30548c99, against upstream/main at cb43e3278, 9 min 54 s) | Check | Result | | --- | --- | | Scope | ⚠️ 21 files, +1052 −106; 1150 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 320 passed (28 s) | | rustfmt | ✅ (8 s) | | clippy | ✅ (2 min 3 s) | | tests: horizon-client, horizon-world | ✅ 1582 passed (5 min 55 s) | | doc tests | ✅ 0 passed (1 min 17 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 334 affected, to run in CI (--quick): arrow, attribute_map_queries, attribute_updates, auto_jump, bamboo, biome_source_codec, biome_temperature, biome_weather, biome_zoom, block_blob, block_collision_scan, block_column and 322 more | | 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>
bsakaguchi 2026-11-03 04:17:14 +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#4449
No description provided.