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

Dedicated server packet error when too many blocks in a chunk are modified

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • None
    • 20w46a, 20w48a
    • Operating System: Windows 10 (amd64) version 10.0
      Java Version: 1.8.0_51, Oracle Corporation
      Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    • Plausible
    • Data Packs, Networking
    • Very Important

      When using the provided datapack to cut holes in the terrain on a dedicated server, I was disconnected as soon as it started destroying blocks.

      Update
      I used Fabric to locate the issue and believe it it a lighting issue in LightUpdateS2CPacket. In 1.16.4, the read method in the packed looked like this:

          public void read(PacketByteBuf buf) throws IOException {
              this.chunkX = buf.readVarInt();
              this.chunkZ = buf.readVarInt();
              this.field_25659 = buf.readBoolean();
              this.skyLightMask = buf.readVarLong();
              this.blockLightMask = buf.readVarLong();
              this.filledSkyLightMask = buf.readVarLong();
              this.filledBlockLightMask = buf.readVarLong();
              this.skyLightUpdates = Lists.newArrayList();
      
              int j;
              for(j = 0; j < 18; ++j) {
                  if ((this.skyLightMask & 1L << j) != 0L) {
                      this.skyLightUpdates.add(buf.readByteArray(2048));
                  }
              }
      
              this.blockLightUpdates = Lists.newArrayList();
      
              for(j = 0; j < 18; ++j) {
                  if ((this.blockLightMask & 1L << j) != 0L) {
                      this.blockLightUpdates.add(buf.readByteArray(2048));
                  }
              }
      
          }
      

      Where in the latest snapshot it is

          public void read(PacketByteBuf buf) throws IOException {
              this.chunkX = buf.readVarInt();
              this.chunkZ = buf.readVarInt();
              this.field_25659 = buf.readBoolean();
              this.skyLightMask = buf.readVarLong();
              this.blockLightMask = buf.readVarLong();
              this.filledSkyLightMask = buf.readVarLong();
              this.filledBlockLightMask = buf.readVarLong();
              this.skyLightUpdates = Lists.newArrayList();
      
              int j;
              for(j = 0; j < 64; ++j) {
                  if ((this.skyLightMask & 1L << j) != 0L) {
                      this.skyLightUpdates.add(buf.readByteArray(2048));
                  }
              }
      
              this.blockLightUpdates = Lists.newArrayList();
      
              for(j = 0; j < 64; ++j) {
                  if ((this.blockLightMask & 1L << j) != 0L) {
                      this.blockLightUpdates.add(buf.readByteArray(2048));
                  }
              }
      
          }
      

      The key change here is

      for(j = 0; j < 64; ++j)
          if ((this.skyLightMask & 1L << j) != 0L)
      

      which when the condition passes for any value greater than 17, causes too much data to be read from the buffer leading to an exception.
      Reverting the change from 64 to 18 using a mixin solved the issue.

      Steps to Reproduce:
      1. Run a dedicated server with the provided datapack. It appears to work fine in singleplayer.
      2. Throw a snowball at some terrain.

            panda4994 [Mojang] Panda
            Ocelot5836 Brandon Silva
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: