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

Lightcalculation of ChunkSelection faulty implemented resulting in client bugs (empty chunks don’t show light/render dark)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Minecraft 18w43a
    • Minecraft 1.8.1, Minecraft 1.8.3, Minecraft 1.8.4, Minecraft 1.8.5, Minecraft 1.8.6, Minecraft 15w41b, Minecraft 15w42a, Minecraft 15w44a, Minecraft 15w45a, Minecraft 16w06a, Minecraft 16w07b, Minecraft 1.9 Pre-Release 2, Minecraft 1.9 Pre-Release 4, Minecraft 1.9, Minecraft 1.9.4, Minecraft 1.10, Minecraft 1.10.2, Minecraft 16w39a, Minecraft 1.11.2, Minecraft 1.12.1, Minecraft 1.12.2, Minecraft 17w50a, Minecraft 18w06a, Minecraft 18w22c, Minecraft 1.13-pre1, Minecraft 1.13.1, Minecraft 1.13.2
    • Confirmed

      The code in ChunkSelection.java that reports if a specific part of a chunk needs to be delivered to a client or not is faulty:

      I'm not sure what the Class is named in the obfuscation. In the partially deobfuscated code it's ChunkSelection.java and the method's name is public boolean a().

      I'm guessing it's public boolean hasBlockData() in the original code

      ChunkSelection.java
      public boolean a(){ 
          return this.nonEmptyBlockCount == 0; 
      }
      

      This method is called when a Chunk is placed in the OutgoingQueue to a client. It checks if a ChunkSelection should be delivered or not.
      The code does not consider the fact that - even if there is no block in a chunkselection - there may still be light-information for that selection.

      This results in light-Bugs on the client side if a Chunk hast light-information in a chunkselection that does not contain any blocks.

      Video content:

      • Connecting to a Singleplayer World (same in Multiplayer)
      • Two chunks have obvious light-Information missing
      • Teleporting does not fix the problem
      • Placing a Block inside that specific chunkselection - thus working around the bug - does not fix the bug initially as the information only get updated on ChunkSending.
      • Teleporting post the workaround does fix the bug
      • Removing the Block - recreating the empty chunkselection and recreating the bug does work post teleport
      • F3 shows we are exactly at the edge of a chunkSelection (63/64)
      • The client-side light-updates in the area around a player does only fix the problem temporarily

      This can be fixed by changing the code:

      ChunkSelection.java
      public boolean a(){ 
         // return this.nonEmptyBlockCount == 0; 
           return false; //kade fix, bukkit/mc reports wrongly if a part of a chunk is empty or not.
      }
      

      Performance and Gameplay implications of this bugfix

      • Performance
        The performance impact is negligible. The problem occurs in <5% of chunks. Specifically: It occurs in every Chunk that has Blocks at the top of one ChunkSelection and light-information in the one above that but no blocks.
      • Bandwidth
        The Bandwidth increases a small amount for the <5% Chunks. But as all that is being sent is the light-map we are talking about a compressed data of only some bytes more.
      • Gameplay
        There are absolutely no side-effects of this fix. I have been running this code-change on my servers for at least 1 1/2 years now (concurrent playercount > 300).

      Conclusion
      In essence the Idea behind the "nonEmptyBlockCount == 0"-Check is good. But its neglecting the fact that there might be light-information present. As ChunkSelections without any lightinformation are null anyways there is no need for that check.

        1. __1.png
          __1.png
          1.20 MB
        2. __2.png
          __2.png
          585 kB
        3. 2016-02-17_11.02.11.png
          2016-02-17_11.02.11.png
          568 kB
        4. 2016-02-19_09.38.18.png
          2016-02-19_09.38.18.png
          318 kB
        5. 2016-06-08_17.35.47.png
          2016-06-08_17.35.47.png
          1.01 MB
        6. 2016-06-08_17.40.48.png
          2016-06-08_17.40.48.png
          594 kB
        7. 2018-06-02_21.34.23.png
          2018-06-02_21.34.23.png
          2.90 MB
        8. 2018-06-13_19.18.30.png
          2018-06-13_19.18.30.png
          4.04 MB
        9. SG_LightBug1.png
          SG_LightBug1.png
          2.46 MB
        10. SG_LightBug2.png
          SG_LightBug2.png
          3.70 MB
        11. SG_LightBug3.png
          SG_LightBug3.png
          4.97 MB
        12. SG_LightBug4.png
          SG_LightBug4.png
          2.39 MB

            fry [Mojang] Georgii Gavrichev
            Kademlia Kademlia
            Votes:
            46 Vote for this issue
            Watchers:
            28 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: