platz1de / Waterlogging

Add waterlogging to your PocketMine-MP server!
https://poggit.pmmp.io/p/WaterLogging/
GNU General Public License v3.0
16 stars 1 forks source link

Crash (bad subchunk y) #5

Open dadodasyra opened 1 week ago

dadodasyra commented 1 week ago

Sun_Nov_17-12.35.30-CET_2024.log Idk how to reproduce it correctly, but it happens and some of my players are exploiting it

Thread: Main
Error: Invalid subchunk Y coordinate 20
File: pmsrc/src/world/format/Chunk
Line: 282
Type: InvalidArgumentException
Backtrace:
#0 plugins/MiniCore/src/platz1de/WaterLogging/WaterLogging(270): pocketmine\world\format\Chunk->getSubChunk(int 20)
dadodasyra commented 1 week ago

It seems that in some way the plugin tried to waterlog something equals to Y 320

dadodasyra commented 1 week ago

I managed to reproduce it just by placing water on Y 319. I've temporarily set a workaround to avoid a crash with this:

    private static function getBlockLayer(World $world, Vector3 $pos): PalettedBlockArray
    {
        $subChunkY = $pos->getY() >> 4;
        if($subChunkY < Chunk::MIN_SUBCHUNK_INDEX || $subChunkY > Chunk::MAX_SUBCHUNK_INDEX) { //This caused a crash with subchunk 20
            return new PalettedBlockArray(0);
        }

        $subChunk = $world->getChunk($pos->getX() >> 4, $pos->getZ() >> 4)?->getSubChunk($subChunkY);

However, i dont understand and I didnt dived into the code to understand it so I'm pretty sure this is not the way it should be fixed