Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
$world = $this->getServer()->getDefaultLevel();
$radius = 136;
$total = (($radius * 2) + 1) ** 2;
$count = 0;
$bList = clone \pocketmine\block\Block::$list;
$search = [];
$replace = [];
for($i = 0; $i < 256; ++$i){
if($bList[$i] === null){
$search[] = chr($i);
$replace[] = "\x00";
}
}
$reflection = new \ReflectionClass(\pocketmine\level\format\generic\BaseFullChunk::class);
$blocks = $reflection->getProperty("blocks");
$blocks->setAccessible(true);
for($chunkX = -$radius; $chunkX <= $radius; ++$chunkX){
for($chunkZ = -$radius; $chunkZ <= $radius; ++$chunkZ){
$chunk = $world->getChunk($chunkX, $chunkZ, false);
if($chunk !== null){
$blocks->setValue($chunk, str_replace($search, $replace, $chunk->getBlockIdArray()));
$chunk->setChanged();
$world->setChunk($chunkX, $chunkZ, $chunk, false);
$world->saveChunks();
}
$world->unloadChunk($chunkX, $chunkZ, false);
++$count;
}
echo "[".round(($count/$total) * 100, 0)."%] $count/$total\n";
}
$world->save(true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.