I don't have any code at the moment. I only need to know how to get all blocks For example: PHP: Server::getInstance()->getDefaultLevel()->getBlocks()?????And than foreach and check the id
ALL blocks in a level? That might take days to compute and you will be annoyed by many memory leak problems when using setBlock spammy. The only solution would be to replace the blocks in a selection of chunk, with 1 subchunk in one tick (with a RepeatingTask), so the server would still be responsive and can clear its caches. Also don't use Server::getInstance() PHP: /** @var $level Level *///Kill me for this crappy way of finding the max x and max y values for chunks//And also this won't really work, there might be a single chunk missing and then you would end up missing chunks behind that./** BEGIN CRAPPY CODE */$maxPX = 0;while($level->getChunk($maxPX, 0) !== null){ $maxPX++;}$minPX = 0;while($level->getChunk($minPX, 0) !== null){ $minPX--;}$maxPY = 0;while($level->getChunk(0, $maxPY) !== null){ $maxPY++;}$minPY = 0;while($level->getChunk(0, $minPY) !== null){ $minPY--;}//and btw the server will crash on big worlds, here too many chunks loaded//now basically you need to store these values in your repeating task and go through the chunks or subchunks. Please note that on big worlds this might take weeks. Have fun, just don't do it.//Just for completeness, here is how you replace blocks in a chunk (not subchunk):$chunk = $level->getChunk($currX, $currY);//for loop through 0-15 $cbX and 0-15 $cbZ and 0-255 $cbYif($chunk->getBlockId($cbX, $cbY, $cbZ) == /*whatever*/){$chunk->setBlockId($cbX, $cbY, $cbZ, /*whatever*/);} Conclusion: DO NOT DO THIS WITH POCKETMINE. WRITE A SOFTWARE WHICH DIRECTLY EDITS THE LEVEL FILES, OR USE ONE LIKE MCEDIT.
I wonder if it's possible to NBT::readCompressed(...every chunk file) and then replace block ids. That'll be a lot quicker.
instead of reinventing the entire wheel, you could fast-serialize the chunk and throw it in an AsyncTask, and then replace all the IDs ;P Remember MineReset already does things a little like this.
Why do you want to do this? Wouldn't it be much more efficient to just make a very simple world generator maybe I'm missing something