[SPIGOT-6678] ChunkSnapshot#.isSectionEmpty() not working as intended. Created: 26/Jul/21  Updated: 27/Jul/21  Resolved: 27/Jul/21

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Ollie Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Environment:

MC Version 1.17.1, Latest Spigot Build


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

 Description   

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

 



 Comments   
Comment by Ollie [ 26/Jul/21 ]

Cool, thanks! 

Comment by Marvin Rieple [ 26/Jul/21 ]

Made a PR for this: craftbukkit#902

Generated at Tue Apr 22 03:00:30 UTC 2025 using Jira 10.3.5#10030005-sha1:190c783f2bd6c69cd5accdb70f97e48812a78d14.