-
Bug
-
Resolution: Fixed
-
1.15.1, 1.15.2 Pre-release 2, 1.15.2, 20w06a, 20w20b, 20w21a, 1.16.2, 1.16.4, 20w48a, 1.17, 1.17.1 Pre-release 1, 1.17.1, 21w37a, 21w40a, 1.18, 1.19 Pre-release 3
-
Confirmed
-
Lighting
-
Important
Upon initial lighting of a chunk, skylight (and blocklight which doesn't matter here) is directly propagated to all neighbors. However, those neighbors might not have their lightmaps set up correctly, yet.
Non-empty subchunks are only registered during initial lighting
public CompletableFuture<Chunk> light(Chunk chunk, boolean bl) { ChunkPos chunkPos = chunk.getPos(); chunk.setLightOn(false); this.enqueue(chunkPos.x, chunkPos.z, ServerLightingProvider.Stage.PRE_UPDATE, Util.debugRunnable(() -> { ChunkSection[] chunkSections = chunk.getSectionArray(); for(int i = 0; i < 16; ++i) { ChunkSection chunkSection = chunkSections[i]; if (!ChunkSection.isEmpty(chunkSection)) { super.updateSectionStatus(ChunkSectionPos.from(chunkPos, i), false); } } ...
This means that during initial lighting, neighbor chunks might have not yet registered their non-empty subchunks and hence lightmaps might not have been setup yet correctly.
This can cause skylight updates to get stuck at missing lightmaps. When later on the missing lightmaps get created during initial lighting of the neighbor chunks, those lightmaps will be initialized by copying down the skylight values from the lightmap above it. Hence, if such a subchunk contains any blocks but did not have a lightmap associated to it, the lightmap will now be initialized to wrong values, making the subchunk erroneously bright.
As a concrete example, I will use "erase cached data" in order to force a relighting and hence simulate initial skylight on a well controlled geometry.
- Create a new redstone-ready world
- /tp 500 56 0
- /fill 496 80 0 511 95 15 minecraft:stone hollow
- /setblock 487 119 7 minecraft:stone
- /tp @s 0 56 0 270 0
- Optimize world -> erase cached data
- Fly 500 blocks in +x direction and fly inside the stone cube using spectator mode
Fortunately, this issue is quite easy to solve. Simply move the registration of non-empty subchunks outside of the initial lighting to some earlier stage. Concretely, add some pre_light stage to worldgen that registers all non-empty subchunks and require all neighbors to have passed this stage before running initial lighting for a chunk.
Best,
PhiPro
- relates to
-
MC-199966 Lightmaps for chunks before light stage get erased upon reloading
- Open
-
MC-170010 Sky-lightmaps not properly initialized
- Resolved
-
MC-196542 Small cleanup for skylight propagation code
- Resolved
-
MC-196614 Queued lightmaps are ignored for skylight propagation and initialization
- Resolved
-
MC-196725 Lightmaps get lost upon unloading chunks
- Resolved