Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-6678

ChunkSnapshot#.isSectionEmpty() not working as intended.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None
    • MC Version 1.17.1, Latest Spigot Build

    • This server is running CraftBukkit version 3203-Spigot-18c71bf-aa69d1c (MC: 1.17.1) (Implementing API version 1.17.1-R0.1-SNAPSHOT)
    • Yes

      I am trying to work out the max height of a chunk, so rather than getting the height of all blocks in the chunk, i decided to use this method.

      It seems that it has a "memory" for when blocks are placed very high up, and does not immediately purge them. So a block could be temporarily placed very high up and it is not until a server restart that it is lowered back down to the actual height.

       

      private int getChunkHeight(final int chunkX, final int chunkZ) {
          ChunkSnapshot chunkSnapshot = this.world.getChunkAt(chunkX,chunkZ).getChunkSnapshot();
          for (int y = 15; y >= 0; y--) {
              if (!chunkSnapshot.isSectionEmpty(y)) {
                  return y+1;
              }
          }
          return 16;
      }
      

      This code will return 16 if a block was placed at y 255 and then removed

       

            Unassigned Unassigned
            olijeffers0n Ollie
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: