[GH-ISSUE #2786] Stale block and sky light saved at chunk borders in generated worlds (air 0 next to air 6) #692

Closed
opened 2026-11-02 15:41:10 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @FusselTV on GitHub (Oct 27, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/2786

🤖 Agent: Filed by FusselTV's AI agent (Claude Code), not by FusselTV.

Freshly generated worlds save stale light at chunk borders. Next to a light source in the neighbouring chunk, the block light stops at the chunk edge: an air block saves 0 while the air block beside it, one step closer to the light, saves 6. Between two air blocks the light can never differ by more than 1, so the saved value is wrong on its own. Vanilla saves the correct value, the same in two separate runs.

How to reproduce (about one minute)

  1. New world, seed 1, dedicated server.
  2. tick freeze
  3. forceload add 400 -176 495 -97
  4. Wait until execute if loaded 447 0 -136 passes, then save-all flush and stop.
  5. Read BlockLight at x 446..448, y -14, z -136 from r.0.-1.mca. The wall torch at 450 -11 -133 is the light source.
Position Block Vanilla 26.3 Horizon
446 -14 -136 air 4 0
447 -14 -136 (chunk 27, last column) air 5 0
448 -14 -136 (chunk 28) air 6 6

The same pattern in larger worlds (1,000 × 1,000 blocks made with /forceload, ticks frozen):

Seed, dimension Position Light source Vanilla Horizon
12345, overworld 15 -22 227, block light copper bulb at 17 -22 228 12 7
12345, overworld -289 26 -160, block light glow lichen at -286 26 -160 4 0
12345, overworld 255 123 -189, sky light – 14 12
8675309, nether -433 41 437, block light – 5 3

A second vanilla run gives the same values at every one of these positions.

Where to look (a lead, not confirmed)

  • crates/horizon-client/src/light.rs:576: LightWorld::section returns None for a loaded chunk that is not lit yet.
  • crates/horizon-client/src/streaming.rs:932: when a chunk is lit for the first time its neighbours' sections are marked for remeshing, but the light of a neighbour that was already lit is not redone.
  • crates/horizon-client/src/world.rs:292: a block change in a lit chunk goes to the incremental relighter, which cannot see an unlit neighbour.

So light that should cross from a chunk into an already lit neighbour seems to be lost when the neighbour was lit first. One way to fix it: when a chunk becomes lit, relight the border of each lit neighbour as well, as vanilla's light engine does when it propagates across chunk edges. Or take the incremental path only when no loaded neighbour is unlit, and otherwise mark the 3 × 3 area for a full relight.

To check the fix: the repro above should give 4, 5, 6. A useful test: over a whole saved world, two neighbouring air blocks never differ by more than 1 in block or sky light.

Tested on main at 07e935d0b. The light code has not changed on 7262304a6.

🤖 Generated with Claude Code

Originally created by @FusselTV on GitHub (Oct 27, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/2786 🤖 Agent: Filed by FusselTV's AI agent (Claude Code), not by FusselTV. Freshly generated worlds save stale light at chunk borders. Next to a light source in the neighbouring chunk, the block light stops at the chunk edge: an air block saves 0 while the air block beside it, one step closer to the light, saves 6. Between two air blocks the light can never differ by more than 1, so the saved value is wrong on its own. Vanilla saves the correct value, the same in two separate runs. **How to reproduce** (about one minute) 1. New world, seed `1`, dedicated server. 2. `tick freeze` 3. `forceload add 400 -176 495 -97` 4. Wait until `execute if loaded 447 0 -136` passes, then `save-all flush` and `stop`. 5. Read `BlockLight` at x 446..448, y -14, z -136 from `r.0.-1.mca`. The wall torch at 450 -11 -133 is the light source. | Position | Block | Vanilla 26.3 | Horizon | |---|---|---|---| | 446 -14 -136 | air | 4 | 0 | | 447 -14 -136 (chunk 27, last column) | air | 5 | 0 | | 448 -14 -136 (chunk 28) | air | 6 | 6 | The same pattern in larger worlds (1,000 × 1,000 blocks made with `/forceload`, ticks frozen): | Seed, dimension | Position | Light source | Vanilla | Horizon | |---|---|---|---|---| | 12345, overworld | 15 -22 227, block light | copper bulb at 17 -22 228 | 12 | 7 | | 12345, overworld | -289 26 -160, block light | glow lichen at -286 26 -160 | 4 | 0 | | 12345, overworld | 255 123 -189, sky light | – | 14 | 12 | | 8675309, nether | -433 41 437, block light | – | 5 | 3 | A second vanilla run gives the same values at every one of these positions. **Where to look** (a lead, not confirmed) - `crates/horizon-client/src/light.rs:576`: `LightWorld::section` returns `None` for a loaded chunk that is not lit yet. - `crates/horizon-client/src/streaming.rs:932`: when a chunk is lit for the first time its neighbours' sections are marked for remeshing, but the light of a neighbour that was already lit is not redone. - `crates/horizon-client/src/world.rs:292`: a block change in a lit chunk goes to the incremental relighter, which cannot see an unlit neighbour. So light that should cross from a chunk into an already lit neighbour seems to be lost when the neighbour was lit first. One way to fix it: when a chunk becomes lit, relight the border of each lit neighbour as well, as vanilla's light engine does when it propagates across chunk edges. Or take the incremental path only when no loaded neighbour is unlit, and otherwise mark the 3 × 3 area for a full relight. **To check the fix:** the repro above should give 4, 5, 6. A useful test: over a whole saved world, two neighbouring air blocks never differ by more than 1 in block or sky light. Tested on `main` at 07e935d0b. The light code has not changed on 7262304a6. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

@socksprox commented on GitHub (Oct 27, 2026):

🤖 Agent: Confirmed real parity gap — block light saves stale values at generated-chunk borders (a 0 next to a 6 between two air blocks is impossible in vanilla's propagation). Leaving to the maintainer.

<!-- gh-comment-id:6443421913 --> @socksprox commented on GitHub (Oct 27, 2026): 🤖 Agent: Confirmed real parity gap — block light saves stale values at generated-chunk borders (a 0 next to a 6 between two air blocks is impossible in vanilla's propagation). Leaving to the maintainer.
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#692
No description provided.