diff --git a/src/pocketmine/world/Explosion.php b/src/pocketmine/world/Explosion.php index a7d19bdb1..71b20e981 100644 --- a/src/pocketmine/world/Explosion.php +++ b/src/pocketmine/world/Explosion.php @@ -83,7 +83,7 @@ class Explosion{ $this->size = $size; $this->what = $what; - $this->subChunkHandler = new SubChunkIteratorManager($this->world, false); + $this->subChunkHandler = new SubChunkIteratorManager($this->world); } /** @@ -119,7 +119,7 @@ class Explosion{ $vBlock->y = $pointerY >= $y ? $y : $y - 1; $vBlock->z = $pointerZ >= $z ? $z : $z - 1; - if(!$this->subChunkHandler->moveTo($vBlock->x, $vBlock->y, $vBlock->z)){ + if(!$this->subChunkHandler->moveTo($vBlock->x, $vBlock->y, $vBlock->z, false)){ continue; } diff --git a/src/pocketmine/world/light/LightUpdate.php b/src/pocketmine/world/light/LightUpdate.php index fe0d153ae..cf36908ac 100644 --- a/src/pocketmine/world/light/LightUpdate.php +++ b/src/pocketmine/world/light/LightUpdate.php @@ -67,7 +67,7 @@ abstract class LightUpdate{ private function prepareNodes() : void{ foreach($this->updateNodes as $blockHash => [$x, $y, $z, $newLevel]){ - if($this->subChunkHandler->moveTo($x, $y, $z)){ + if($this->subChunkHandler->moveTo($x, $y, $z, false)){ $oldLevel = $this->getLight($x, $y, $z); if($oldLevel !== $newLevel){ @@ -100,7 +100,7 @@ abstract class LightUpdate{ ]; foreach($points as list($cx, $cy, $cz)){ - if($this->subChunkHandler->moveTo($cx, $cy, $cz)){ + if($this->subChunkHandler->moveTo($cx, $cy, $cz, true)){ $this->computeRemoveLight($cx, $cy, $cz, $oldAdjacentLight); } } @@ -111,7 +111,7 @@ abstract class LightUpdate{ unset($this->spreadVisited[World::blockHash($x, $y, $z)]); - if(!$this->subChunkHandler->moveTo($x, $y, $z)){ + if(!$this->subChunkHandler->moveTo($x, $y, $z, false)){ continue; } @@ -130,7 +130,7 @@ abstract class LightUpdate{ ]; foreach($points as list($cx, $cy, $cz)){ - if($this->subChunkHandler->moveTo($cx, $cy, $cz)){ + if($this->subChunkHandler->moveTo($cx, $cy, $cz, true)){ $this->computeSpreadLight($cx, $cy, $cz, $newAdjacentLight); } } diff --git a/src/pocketmine/world/utils/SubChunkIteratorManager.php b/src/pocketmine/world/utils/SubChunkIteratorManager.php index ef1e6cdee..55e8bbf7d 100644 --- a/src/pocketmine/world/utils/SubChunkIteratorManager.php +++ b/src/pocketmine/world/utils/SubChunkIteratorManager.php @@ -43,21 +43,18 @@ class SubChunkIteratorManager{ protected $currentY; /** @var int */ protected $currentZ; - /** @var bool */ - protected $allocateEmptySubs = true; - public function __construct(ChunkManager $world, bool $allocateEmptySubs = true){ + public function __construct(ChunkManager $world){ $this->world = $world; - $this->allocateEmptySubs = $allocateEmptySubs; } - public function moveTo(int $x, int $y, int $z) : bool{ + public function moveTo(int $x, int $y, int $z, bool $create) : bool{ if($this->currentChunk === null or $this->currentX !== ($x >> 4) or $this->currentZ !== ($z >> 4)){ $this->currentX = $x >> 4; $this->currentZ = $z >> 4; $this->currentSubChunk = null; - $this->currentChunk = $this->world->getChunk($this->currentX, $this->currentZ); + $this->currentChunk = $this->world->getChunk($this->currentX, $this->currentZ, $create); if($this->currentChunk === null){ return false; } @@ -66,7 +63,7 @@ class SubChunkIteratorManager{ if($this->currentSubChunk === null or $this->currentY !== ($y >> 4)){ $this->currentY = $y >> 4; - $this->currentSubChunk = $this->currentChunk->getSubChunk($y >> 4, $this->allocateEmptySubs); + $this->currentSubChunk = $this->currentChunk->getSubChunk($y >> 4, $create); if($this->currentSubChunk instanceof EmptySubChunk){ return false; }