Skip to content

Instantly share code, notes, and snippets.

@shoghicp
Last active November 17, 2016 06:46
Show Gist options
  • Save shoghicp/b1bb05be640ccb86e202 to your computer and use it in GitHub Desktop.
Save shoghicp/b1bb05be640ccb86e202 to your computer and use it in GitHub Desktop.
<?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);
@inxomnyaa
Copy link

Thats the hackiest way i've ever seen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment