mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-17 03:08:58 +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);
|
$this->chunkLoadTask->setNextRun($this->chunkLoadTask->getNextRun() + 30);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($this->loadQueue[$index]);
|
unset($this->loadQueue[$index]);
|
||||||
$this->usedChunks[$index] = [false, 0];
|
$this->usedChunks[$index] = [false, 0];
|
||||||
|
|
||||||
|
@ -393,14 +393,16 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
|
|
||||||
foreach($this->usedChunks as $index => $p){
|
foreach($this->usedChunks as $index => $p){
|
||||||
Level::getXZ($index, $X, $Z);
|
Level::getXZ($index, $X, $Z);
|
||||||
|
$chunk = $this->getChunkAt($X, $Z, true);
|
||||||
for($Y = 0; $Y < 8; ++$Y){
|
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){
|
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)));
|
$x = mt_rand(0, 15);
|
||||||
if($block instanceof Block){
|
$y = mt_rand(0, 15);
|
||||||
if($block->onUpdate(self::BLOCK_UPDATE_RANDOM) === self::BLOCK_UPDATE_NORMAL){
|
$z = mt_rand(0, 15);
|
||||||
$this->updateAround($block, self::BLOCK_UPDATE_NORMAL);
|
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){
|
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){
|
public function addEntity(Entity $entity){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user