Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-199966

Lightmaps for chunks before light stage get erased upon reloading

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.16.3, 1.16.4, 20w48a, 1.17.1, 1.18 Pre-release 1
    • None
    • Confirmed
    • Lighting

      As requested, this is a copy of this comment on MC-170012, posted as a separate report.

       

      Upon loading from disk, lightmaps are only loaded for chunks that were already lighted and discarded otherwise, although they are always saved to disk.

      net.minecraft.world.ChunkSerializer.java
      public static ProtoChunk deserialize(...) {
          ...
          boolean bl = compoundTag.getBoolean("isLightOn");
          ...
          if (bl) {
              if (compoundTag2.contains("BlockLight", 7)) {
                 lightingProvider.enqueueSectionData(LightType.BLOCK, ChunkSectionPos.from(pos, k), new ChunkNibbleArray(compoundTag2.getByteArray("BlockLight")), true);
              }
      
              if (bl2 && compoundTag2.contains("SkyLight", 7)) {
                 lightingProvider.enqueueSectionData(LightType.SKY, ChunkSectionPos.from(pos, k), new ChunkNibbleArray(compoundTag2.getByteArray("SkyLight")), true);
              }
          }
          ...
      }
      

       

      This basically erases any light propagations to chunks in pre_light stage when unloading them before the light stage and hence causes lighting glitches.

       

      The Vanilla code currently uses this mechanism to erase cached data, which only removes the isLightOn field but not the lightmaps themselves.

       

      As a concrete example I use the setup of MC-199952, which I suppose to be an instance of this:

      • Create a new world with seed 1122583309043747515
      • Set the render distance to 2
      • /tp -616 77 200
      • Reload the world
      • Fly to -669 80 207 and observe the lighting glitch

      Also note that the issue doesn't occur if omitting the reloading step, as expected.

            Unassigned Unassigned
            PhiPro Philipp Provenzano
            Votes:
            13 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              CHK: