pocketmine\level\format\LevelProvider::requestChunkTask PHP Method

requestChunkTask() public method

Requests a MC: PE network chunk to be sent
public requestChunkTask ( integer $x, integer $z ) : AsyncTask | null
$x integer
$z integer
return pocketmine\scheduler\AsyncTask | null
    public function requestChunkTask($x, $z);

Usage Example

Example #1
0
 protected function processChunkRequest()
 {
     if (count($this->chunkSendQueue) > 0) {
         $this->timings->syncChunkSendTimer->startTiming();
         $x = null;
         $z = null;
         foreach ($this->chunkSendQueue as $index => $players) {
             if (isset($this->chunkSendTasks[$index])) {
                 continue;
             }
             if (PHP_INT_SIZE === 8) {
                 $x = $index >> 32 << 32 >> 32;
                 $z = ($index & 4294967295.0) << 32 >> 32;
             } else {
                 list($x, $z) = explode(":", $index);
                 $x = (int) $x;
                 $z = (int) $z;
             }
             if (ADVANCED_CACHE == true and ($cache = Cache::get("world:" . $this->getId() . ":" . $index)) !== false) {
                 /** @var Player[] $players */
                 foreach ($players as $player) {
                     if ($player->isConnected() and isset($player->usedChunks[$index])) {
                         $player->sendChunk($x, $z, $cache);
                     }
                 }
                 unset($this->chunkSendQueue[$index]);
             } else {
                 $this->chunkSendTasks[$index] = true;
                 $this->timings->syncChunkSendPrepareTimer->startTiming();
                 $task = $this->provider->requestChunkTask($x, $z);
                 if ($task instanceof AsyncTask) {
                     $this->server->getScheduler()->scheduleAsyncTask($task);
                 }
                 $this->timings->syncChunkSendPrepareTimer->stopTiming();
             }
         }
         $this->timings->syncChunkSendTimer->stopTiming();
     }
 }
All Usage Examples Of pocketmine\level\format\LevelProvider::requestChunkTask