[PR #319] [MERGED] Trial spawner state machine, checked against vanilla #2487

Closed
opened 2026-11-02 15:56:37 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/319
Author: @ludovic111
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/15/2026
Merged by: @ludovic111

Base: main ← Head: feat/trial-spawners


📝 Commits (1)

  • ca76075 Trial spawner state machine, checked against vanilla

📊 Changes

8 files changed (+1652 additions, -56 deletions)

View changed files

📝 crates/horizon-client/examples/natural_spawn_fixture.rs (+272 -2)
📝 crates/horizon-client/src/mobs.rs (+2 -0)
📝 crates/horizon-client/src/mobs/spawner.rs (+58 -23)
➕ crates/horizon-client/src/mobs/trial_spawner.rs (+886 -0)
📝 crates/horizon-client/src/mobs/world.rs (+58 -27)
📝 crates/horizon-world/src/loot.rs (+25 -0)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaNaturalSpawnOracle.java (+113 -4)
➕ tools/test_trial_spawner_parity.py (+238 -0)

📄 Description

Part of #223. Thanks to Cosmic (Online5277) for the report.

What "trial chambers don't work" means today

Checked in game (seed 12345, chamber at x -2639..-2500, z 99..233) and with the harnesses:

  • Structure generation matches vanilla. test_chunk_generation_parity --structures-only --filter trial_chambers: 36 chunks over 4 sites, 0 differences. A whole chamber (81 chunks): 0 differences in blocks and block entities.
  • Trial spawners do nothing. There is no block entity: in survival 3 blocks away the spawner stays waiting_for_players, with no mob inside, no flames and no spawns. Generated spawner configs are dropped from fresh chunks, so saves lose them. This PR and the next fix it.
  • Vaults do nothing. A vault stays inactive with the player 2.5 blocks away (vanilla activates at 4); using a trial key does nothing, nothing is ejected. No vault block entity. Next PRs.
  • Decorated pots drop no loot. Breaking a corridor pot drops the pot but none of pots/trial_chambers/corridor (always one item). Next PRs.
  • Trial spawner visuals: flames, the spinning mob inside, the active/ominous textures and the ambient sound. Next PRs.
  • Ominous trial spawners (Bad Omen → Trial Omen, ominous item spawners). Next PRs.
  • [~] Breeze moves and attacks (covered by the mob_ai harness); bogged move. Dispensers and copper bulbs generate as vanilla; not checked further yet.

This PR

mobs::trial_spawner: vanilla's TrialSpawner and TrialSpawnerStateData without the game. It covers the configs (the trial_spawner registry or inline), the six states, player detection (every 20 ticks, with the visual line of sight), mob spawns, reward ejection, and loading and saving. Loading works like TagValueInput with the partial result, so a field that fails to decode falls back to its own default. The next PR wires this into the game.

New harness tools/test_trial_spawner_parity.py: 2,500 random trial spawners (tuff halls with glass, bars, slab and copper grate pillars, players in and out of range in every game mode, registry, inline and broken configs, all states, mobs killed along the way) are ticked for up to 600 ticks in VanillaNaturalSpawnOracle and in natural_spawn_fixture. States, spawns, level and game events, sounds, ejected items and the final state data are compared line by line.

Found while making it match:

  • Copper grates (TransparentBlock) have no visual shape, so a spawner sees through them.
  • A slime's or magma cube's obstruction box scales with the Size its spawn data sets. This also affects the ordinary spawner.
  • LootData::roll_split: getRandomItems with an empty context. The Items loot evaluator lacks nested tables and the enchant/potion functions the reward tables use.

Self-check

  • cargo fmt --check, cargo clippy --workspace --all-targets -D warnings: clean.
  • cargo test -p horizon-client -p horizon-world: all pass except title::tests::delete_refuses_an_open_world_then_removes_it_with_its_lock, which failed once in the full run and passes on its own, both here and on plain origin/main. It's flaky under load; nothing here touches it.
  • test_trial_spawner_parity: 2,500 cases match vanilla (2,167 spawns, 336 items, 3,265 states, 660 detections, 293 rewards; every state reached).
  • The oracle changed, so I reran test_spawner_parity (6,000 cases match) and test_natural_spawn_parity (15,500 cases match).
  • test_chunk_generation_parity --seeds 2 --structures-only --filter trial_chambers: 0 differences.

🤖 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/319 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/trial-spawners` --- ### 📝 Commits (1) - [`ca76075`](https://github.com/horizon-rust/horizon/commit/ca76075cc965fccd5b4b7dca16e891422f9f43ea) Trial spawner state machine, checked against vanilla ### 📊 Changes **8 files changed** (+1652 additions, -56 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/natural_spawn_fixture.rs` (+272 -2) 📝 `crates/horizon-client/src/mobs.rs` (+2 -0) 📝 `crates/horizon-client/src/mobs/spawner.rs` (+58 -23) ➕ `crates/horizon-client/src/mobs/trial_spawner.rs` (+886 -0) 📝 `crates/horizon-client/src/mobs/world.rs` (+58 -27) 📝 `crates/horizon-world/src/loot.rs` (+25 -0) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaNaturalSpawnOracle.java` (+113 -4) ➕ `tools/test_trial_spawner_parity.py` (+238 -0) </details> ### 📄 Description Part of #223. Thanks to Cosmic (Online5277) for the report. ## What "trial chambers don't work" means today Checked in game (seed 12345, chamber at x -2639..-2500, z 99..233) and with the harnesses: - [x] **Structure generation matches vanilla.** `test_chunk_generation_parity --structures-only --filter trial_chambers`: 36 chunks over 4 sites, 0 differences. A whole chamber (81 chunks): 0 differences in blocks and block entities. - [ ] **Trial spawners do nothing.** There is no block entity: in survival 3 blocks away the spawner stays `waiting_for_players`, with no mob inside, no flames and no spawns. Generated spawner configs are dropped from fresh chunks, so saves lose them. *This PR and the next fix it.* - [ ] **Vaults do nothing.** A vault stays `inactive` with the player 2.5 blocks away (vanilla activates at 4); using a trial key does nothing, nothing is ejected. No vault block entity. *Next PRs.* - [ ] **Decorated pots drop no loot.** Breaking a corridor pot drops the pot but none of `pots/trial_chambers/corridor` (always one item). *Next PRs.* - [ ] Trial spawner visuals: flames, the spinning mob inside, the active/ominous textures and the ambient sound. *Next PRs.* - [ ] Ominous trial spawners (Bad Omen → Trial Omen, ominous item spawners). *Next PRs.* - [~] Breeze moves and attacks (covered by the mob_ai harness); bogged move. Dispensers and copper bulbs generate as vanilla; not checked further yet. ## This PR `mobs::trial_spawner`: vanilla's `TrialSpawner` and `TrialSpawnerStateData` without the game. It covers the configs (the `trial_spawner` registry or inline), the six states, player detection (every 20 ticks, with the visual line of sight), mob spawns, reward ejection, and loading and saving. Loading works like `TagValueInput` with the partial result, so a field that fails to decode falls back to its own default. The next PR wires this into the game. New harness `tools/test_trial_spawner_parity.py`: 2,500 random trial spawners (tuff halls with glass, bars, slab and copper grate pillars, players in and out of range in every game mode, registry, inline and broken configs, all states, mobs killed along the way) are ticked for up to 600 ticks in `VanillaNaturalSpawnOracle` and in `natural_spawn_fixture`. States, spawns, level and game events, sounds, ejected items and the final state data are compared line by line. Found while making it match: - Copper grates (`TransparentBlock`) have no visual shape, so a spawner sees through them. - A slime's or magma cube's obstruction box scales with the `Size` its spawn data sets. This also affects the ordinary spawner. - `LootData::roll_split`: `getRandomItems` with an empty context. The `Items` loot evaluator lacks nested tables and the enchant/potion functions the reward tables use. ## Self-check - `cargo fmt --check`, `cargo clippy --workspace --all-targets -D warnings`: clean. - `cargo test -p horizon-client -p horizon-world`: all pass except `title::tests::delete_refuses_an_open_world_then_removes_it_with_its_lock`, which failed once in the full run and passes on its own, both here and on plain origin/main. It's flaky under load; nothing here touches it. - `test_trial_spawner_parity`: 2,500 cases match vanilla (2,167 spawns, 336 items, 3,265 states, 660 detections, 293 rewards; every state reached). - The oracle changed, so I reran `test_spawner_parity` (6,000 cases match) and `test_natural_spawn_parity` (15,500 cases match). - `test_chunk_generation_parity --seeds 2 --structures-only --filter trial_chambers`: 0 differences. 🤖 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-02 15:56:37 +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#2487
No description provided.