mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 18:59:00 +00:00
Added Empty chunk detection
This commit is contained in:
parent
36cdfd969d
commit
6f9becdbb3
@ -568,6 +568,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$this->chunkLoadTask->setNextRun($this->chunkLoadTask->getNextRun() + 30);
|
||||
return;
|
||||
}
|
||||
|
||||
unset($this->loadQueue[$index]);
|
||||
$this->usedChunks[$index] = [false, 0];
|
||||
|
||||
|
@ -393,14 +393,16 @@ class Level implements ChunkManager, Metadatable{
|
||||
|
||||
foreach($this->usedChunks as $index => $p){
|
||||
Level::getXZ($index, $X, $Z);
|
||||
$chunk = $this->getChunkAt($X, $Z, true);
|
||||
for($Y = 0; $Y < 8; ++$Y){
|
||||
if(!$this->getChunkAt($X, $Z, true)->isSectionEmpty($Y)){
|
||||
if(!$chunk->isSectionEmpty($Y)){
|
||||
$section = $chunk->getSection($Y);
|
||||
for($i = 0; $i < 3; ++$i){
|
||||
$block = $this->getBlock(new Vector3(($X << 4) + mt_rand(0, 15), ($Y << 4) + mt_rand(0, 15), ($Z << 4) + mt_rand(0, 15)));
|
||||
if($block instanceof Block){
|
||||
if($block->onUpdate(self::BLOCK_UPDATE_RANDOM) === self::BLOCK_UPDATE_NORMAL){
|
||||
$this->updateAround($block, self::BLOCK_UPDATE_NORMAL);
|
||||
}
|
||||
$x = mt_rand(0, 15);
|
||||
$y = mt_rand(0, 15);
|
||||
$z = mt_rand(0, 15);
|
||||
if($section->getBlockId($x, $y, $z) !== 0){
|
||||
$this->getBlock(new Vector3($X * 16 + $x, $Y * 16 + $y, $Z * 16 + $z))->onUpdate(self::BLOCK_UPDATE_RANDOM);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -233,7 +233,11 @@ abstract class BaseChunk implements Chunk{
|
||||
}
|
||||
|
||||
public function setSection($fY, ChunkSection $section){
|
||||
$this->sections[(int) $fY] = $section;
|
||||
if(substr_count($section->getIdArray(), "\x00") === 4096 and substr_count($section->getDataArray(), "\x00") === 2048){
|
||||
$this->sections[(int) $fY] = new EmptyChunkSection($fY);
|
||||
}else{
|
||||
$this->sections[(int) $fY] = $section;
|
||||
}
|
||||
}
|
||||
|
||||
public function addEntity(Entity $entity){
|
||||
|
Loading…
x
Reference in New Issue
Block a user