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

Heightmap min value not set when loading chunk from NBT

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Awaiting Response
    • None
    • Minecraft 1.11.2, Minecraft 1.12.2, Minecraft 1.13.2
    • Confirmed
    • Lighting

      The bug

      Note: The following is based on decompiled code, using MCP naming.

      The minimum heightmap value for a chunk is currently set when the heightmap is populated either by chunk generation on the server, or by a chunk data packet being received by the client. However, it is not set when a chunk is read from NBT (see AnvilChunkLoader#readChunkFromNBT()).

      This means that server-side, any chunk not freshly generated will have a heightmap minimum of 0.
      The main effect of this is that lighting checks performed by Chunk#recheckGaps() will call World#checkLightFor() for all y-values between 0 and the heightmap value for that column (+1), instead of a reduced range.

      Possible fix

      The heightMapMinimum field should be updated when the heightmap is set in Chunk#setHeightMap(). For example:

      public void setHeightMap(int[] newHeightMap)
      {
          if (this.heightMap.length != newHeightMap.length)
          {
              LOGGER.warn("Could not set level chunk heightmap, array length is {} instead of {}", newHeightMap.length, this.heightMap.length);
          }
          else
          {
              System.arraycopy(newHeightMap, 0, this.heightMap, 0, this.heightMap.length);
              // *update heightmap min value here*
          }
      }
      

            Unassigned Unassigned
            quadraxis Ben Staddon
            Votes:
            8 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: