diff --git a/src/world/SimpleChunkManager.php b/src/world/SimpleChunkManager.php index 7911158b0..17325ad0f 100644 --- a/src/world/SimpleChunkManager.php +++ b/src/world/SimpleChunkManager.php @@ -28,8 +28,6 @@ use pocketmine\block\BlockFactory; use pocketmine\block\VanillaBlocks; use pocketmine\utils\Limits; use pocketmine\world\format\Chunk; -use pocketmine\world\utils\SubChunkExplorer; -use pocketmine\world\utils\SubChunkExplorerStatus; class SimpleChunkManager implements ChunkManager{ @@ -39,28 +37,23 @@ class SimpleChunkManager implements ChunkManager{ /** @var int */ protected $worldHeight; - /** @var SubChunkExplorer */ - protected $terrainPointer; - /** * SimpleChunkManager constructor. */ public function __construct(int $worldHeight = World::Y_MAX){ $this->worldHeight = $worldHeight; - $this->terrainPointer = new SubChunkExplorer($this); } public function getBlockAt(int $x, int $y, int $z) : Block{ - if($this->terrainPointer->moveTo($x, $y, $z) !== SubChunkExplorerStatus::INVALID){ - return BlockFactory::getInstance()->fromFullBlock($this->terrainPointer->currentSubChunk->getFullBlock($x & 0xf, $y & 0xf, $z & 0xf)); + if(($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null){ + return BlockFactory::getInstance()->fromFullBlock($chunk->getFullBlock($x & 0xf, $y, $z)); } return VanillaBlocks::AIR(); } public function setBlockAt(int $x, int $y, int $z, Block $block) : void{ - if($this->terrainPointer->moveTo($x, $y, $z) !== SubChunkExplorerStatus::INVALID){ - $this->terrainPointer->currentSubChunk->setFullBlock($x & 0xf, $y & 0xf, $z & 0xf, $block->getFullId()); - $this->terrainPointer->currentChunk->setDirtyFlag(Chunk::DIRTY_FLAG_TERRAIN, true); + if(($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null){ + $chunk->setFullBlock($x & 0xf, $y, $z & 0xf, $block->getFullId()); }else{ throw new \InvalidArgumentException("Cannot set block at coordinates x=$x,y=$y,z=$z, terrain is not loaded or out of bounds"); }