public function setChunk($chunkX, $chunkZ, FullChunk $chunk) { if (!$chunk instanceof Chunk) { throw new \Exception("Invalid Chunk class"); } $chunk->setProvider($this); if ($chunk->isPopulated() === false) { $this->unloadChunk($chunkX, $chunkZ, false); $regionX = $regionZ = null; self::getRegionIndex($chunkX, $chunkZ, $regionX, $regionZ); $this->loadRegion($regionX, $regionZ); $region = $this->getRegion($regionX, $regionZ); $region->removeChunk($chunkX - $region->getX() * 32, $chunkZ - $region->getZ() * 32); $this->loadChunk($chunkX, $chunkZ); } else { $chunk->setX($chunkX); $chunk->setZ($chunkZ); $this->chunks[Level::chunkHash($chunkX, $chunkZ)] = $chunk; //$this->saveChunk($chunkX, $chunkZ); } }
/** * @param int $chunkX * @param int $chunkZ * @param FullChunk $chunk */ public function setChunk($chunkX, $chunkZ, FullChunk $chunk) { $this->chunks[$index = PHP_INT_SIZE === 8 ? ($chunkX & 0xffffffff) << 32 | $chunkZ & 0xffffffff : $chunkX . ":" . $chunkZ] = $chunk; $this->changes[$index] = $chunk; if ($chunk->isPopulated()) { //TODO: Queue to be sent } }
/** * @param int $chunkX * @param int $chunkZ * @param FullChunk $chunk */ public function setChunk($chunkX, $chunkZ, FullChunk $chunk) { $this->chunks[$index = Level::chunkHash($chunkX, $chunkZ)] = $chunk; $this->changes[$index] = $chunk; if ($chunk->isPopulated()) { //TODO: Queue to be sent } }