mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-12 16:59:44 +00:00
SubChunkIteratorManager now accepts $create as a moveTo() parameter instead of in the constructor
This commit is contained in:
parent
6f087190f4
commit
45f5f112dd
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user