[PR #293] [MERGED] mob_ai oracle: wait for the light engine before ticking (drowned flake, #290) #2461

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

📋 Pull Request Information

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

Base: main ← Head: fix/drowned-parity


📝 Commits (1)

  • fa188fc mob_ai oracle: wait for the scene's light updates before ticking (#290)

📊 Changes

1 file changed (+13 additions, -1 deletions)

View changed files

📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaMobAiOracle.java (+13 -1)

📄 Description

Fixes #290

What

The mob_ai oracle now waits for the light engine to finish the scene's light updates before it ticks a scenario.

Why

The extra random draw was vanilla's own: Mob.isSunBurnTick draws random.nextFloat() only when the brightness at the drowned's eyes is above 0.5. The pools are made with fill over the flat world's dirt. Until the light thread has processed those checkBlocks, the water still reads the dirt's sky light (0), so the roll is skipped. Once it has, the water reads 13 and the roll happens.

The oracle started a scenario once hasLightWork() had been false for 6 ticks. Light updates reach ThreadedLevelLightEngine.lightTasks through the chunk task dispatcher, though, and hasLightWork() can't see them there. Those 6 ticks pass in microseconds (waitUntilNextTick runs all tasks), so whether the light was settled by tick 1 or tick 16 depended on thread timing. That is why drowned_pool or drowned_pool_swimmer failed at random, one draw off, followed by the extra entity.drowned.ambient_water. Horizon always has the settled light, so the Rust side was right and needs no change. Its output is byte-identical over 5 runs.

How

After build, queue ThreadedLevelLightEngine.waitForPendingTasks on each of the 81 forced chunks. These are POST_UPDATE tasks, queued behind the scene's checkBlocks, so they complete only after the light pass that covers the fill. The scenario ticks once all of them are done (and hasLightWork() is false, as before).

How tested

  • Diagnosis: 5 Rust probe runs gave identical output; 5 oracle runs before the fix gave 2 different outputs. The failing one lacks the Mob.isSunBurnTick:564 draw at drowned_pool_swimmer tick 1, where Horizon draws it in sun_burn_tick.
  • After the fix, on main b5a2afb7: python3 tools/test_mob_ai_parity.py, 5 consecutive full runs (oracle re-run fresh every time):
run 1: 120/120 scenarios match entirely; 40948/40948 mob-ticks match
run 2: 120/120 scenarios match entirely; 40948/40948 mob-ticks match
run 3: 120/120 scenarios match entirely; 40948/40948 mob-ticks match
run 4: 120/120 scenarios match entirely; 40948/40948 mob-ticks match
run 5: 120/120 scenarios match entirely; 40948/40948 mob-ticks match
vanilla.txt md5 identical in all 5 runs (f1728e89…)
  • Java oracle only: no Rust, so fmt and clippy are unaffected.

Nothing player-facing (skip-release). Nothing needs Ludovic.

🤖 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/293 **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:** `fix/drowned-parity` --- ### 📝 Commits (1) - [`fa188fc`](https://github.com/horizon-rust/horizon/commit/fa188fca423a562b71dac5ef4a5b928eed586a7e) mob_ai oracle: wait for the scene's light updates before ticking (#290) ### 📊 Changes **1 file changed** (+13 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaMobAiOracle.java` (+13 -1) </details> ### 📄 Description Fixes #290 ## What The mob_ai oracle now waits for the light engine to finish the scene's light updates before it ticks a scenario. ## Why The extra random draw was vanilla's own: `Mob.isSunBurnTick` draws `random.nextFloat()` only when the brightness at the drowned's eyes is above 0.5. The pools are made with `fill` over the flat world's dirt. Until the light thread has processed those `checkBlock`s, the water still reads the dirt's sky light (0), so the roll is skipped. Once it has, the water reads 13 and the roll happens. The oracle started a scenario once `hasLightWork()` had been false for 6 ticks. Light updates reach `ThreadedLevelLightEngine.lightTasks` through the chunk task dispatcher, though, and `hasLightWork()` can't see them there. Those 6 ticks pass in microseconds (`waitUntilNextTick` runs all tasks), so whether the light was settled by tick 1 or tick 16 depended on thread timing. That is why drowned_pool or drowned_pool_swimmer failed at random, one draw off, followed by the extra `entity.drowned.ambient_water`. Horizon always has the settled light, so the Rust side was right and needs no change. Its output is byte-identical over 5 runs. ## How After `build`, queue `ThreadedLevelLightEngine.waitForPendingTasks` on each of the 81 forced chunks. These are POST_UPDATE tasks, queued behind the scene's `checkBlock`s, so they complete only after the light pass that covers the fill. The scenario ticks once all of them are done (and `hasLightWork()` is false, as before). ## How tested - Diagnosis: 5 Rust probe runs gave identical output; 5 oracle runs before the fix gave 2 different outputs. The failing one lacks the `Mob.isSunBurnTick:564` draw at drowned_pool_swimmer tick 1, where Horizon draws it in `sun_burn_tick`. - After the fix, on main b5a2afb7: `python3 tools/test_mob_ai_parity.py`, 5 consecutive full runs (oracle re-run fresh every time): ``` run 1: 120/120 scenarios match entirely; 40948/40948 mob-ticks match run 2: 120/120 scenarios match entirely; 40948/40948 mob-ticks match run 3: 120/120 scenarios match entirely; 40948/40948 mob-ticks match run 4: 120/120 scenarios match entirely; 40948/40948 mob-ticks match run 5: 120/120 scenarios match entirely; 40948/40948 mob-ticks match vanilla.txt md5 identical in all 5 runs (f1728e89…) ``` - Java oracle only: no Rust, so fmt and clippy are unaffected. Nothing player-facing (`skip-release`). Nothing needs Ludovic. 🤖 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:22 +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#2461
No description provided.