world = $world; } 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, $create); if($this->currentChunk === null){ return false; } } if($this->currentSubChunk === null or $this->currentY !== ($y >> 4)){ $this->currentY = $y >> 4; $this->currentSubChunk = $this->currentChunk->getSubChunk($y >> 4, $create); if($this->currentSubChunk instanceof EmptySubChunk){ $this->currentSubChunk = null; return false; } if($this->onSubChunkChangeFunc !== null){ ($this->onSubChunkChangeFunc)(); } } return true; } public function onSubChunkChange(\Closure $callback) : void{ Utils::validateCallableSignature(function(){}, $callback); $this->onSubChunkChangeFunc = $callback; } public function invalidate() : void{ $this->currentChunk = null; $this->currentSubChunk = null; } }