Skip to content

Instantly share code, notes, and snippets.

@legoboy0215
Forked from shoghicp/deleteBlocks.php
Created March 1, 2016 00:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save legoboy0215/39990e8eb0f5d27a2c90 to your computer and use it in GitHub Desktop.
Save legoboy0215/39990e8eb0f5d27a2c90 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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment