I get a weird block glitch when i interact with some blocks on an island i created with this code Code: public function generateChunk(int $chunkX, int $chunkZ) { $chunk = $this->level->getChunk($chunkX, $chunkZ); $chunk->setGenerated(); if ($chunkX % 20 == 0 && $chunkZ % 20 == 0) { //set block on chunk } Tree::growTree($this->level, $chunkX * 16 + 3, 6, $chunkZ * 16 + 4, $this->random, 0); $chunk->setX($chunkX); $chunk->setZ($chunkZ); $this->level->setChunk($chunkX, $chunkZ, $chunk); } } You can see this gif of what happens -> Spawn protection = -1 Even with no editing on playerinteractevent Does anyone know why this is happening or how to fix?
This is really weird, do you have any plugins interfering with PlayerInteractEvent or PlayerActionPacket?
@Muqsit No, i only have devtools and the plugin i am working on, no event listener yet. This only happens when i generate the island and teleport to it in the same session after loading the level, not after relogging. Also i generate the island at level's spawn and spawn protection is -1, if that has anything to do with it.
then this suggests a client issue. try teleporting the client out of reach and then in reach again after generating
no wait i get the same glitch after respawn only the blocks appear back, you can still interact and the blocks disappear
this is really weird, how are you generating exactly and when are you putting the player on top of the island?
When the player does /is go they go on top of the island, i am modifying this plugin, it happens in this plugin too, here's the generation -> https://github.com/TheFixerDevelopment/SkyblockPE/tree/Pocketmine-ONLY/src/SkyBlock/generator
I did, but I’m pretty clueless. dktapps said there might be a race between chunk sending and generation, but i don‘t understand why and what the result would be.
still happening, i did this --> Code: $chunk = $this->level->getChunk($chunkX, $chunkZ); $chunk->setGenerated(); $chunk->setPopulated();
This bug appears to be caused by an issue with Level block object caching. I've encountered this issue myself without plugins, on both newly-generated worlds and worlds loaded from disk. Working on a fix. Technical TL;DR: Before chunks are loaded/generated, Level->getBlock[At]() will return, and cache, an AIR block. The bad cache does not later get cleared when chunks are set into the world. This results in the server erroneously thinking that you're clicking on an AIR block and not [whatever] block.