loadChunk() public method

public loadChunk ( integer $X, integer $Z, boolean $create = false ) : boolean
$X integer
$Z integer
$create boolean
return boolean
Exemplo n.º 1
0
 /**
  * @param int  $x
  * @param int  $z
  * @param bool $generate
  *
  * @return bool
  */
 public function loadChunk($x, $z, $generate = true)
 {
     if (isset($this->chunks[$index = PHP_INT_SIZE === 8 ? ($x & 4294967295.0) << 32 | $z & 4294967295.0 : $x . ":" . $z])) {
         return true;
     }
     $this->cancelUnloadChunkRequest($x, $z);
     $chunk = $this->provider->getChunk($x, $z, $generate);
     if ($chunk !== null) {
         $this->chunks[$index] = $chunk;
         $chunk->initChunk();
     } else {
         $this->timings->syncChunkLoadTimer->startTiming();
         $this->provider->loadChunk($x, $z, $generate);
         $this->timings->syncChunkLoadTimer->stopTiming();
         if (($chunk = $this->provider->getChunk($x, $z)) !== null) {
             $this->chunks[$index] = $chunk;
             $chunk->initChunk();
         } else {
             return false;
         }
     }
     $this->server->getPluginManager()->callEvent(new ChunkLoadEvent($chunk, !$chunk->isGenerated()));
     return true;
 }
Exemplo n.º 2
0
 /**
  * @param int  $x
  * @param int  $z
  * @param bool $generate
  *
  * @return bool
  */
 public function loadChunk($x, $z, $generate = true)
 {
     if (isset($this->chunks[$index = Level::chunkHash($x, $z)])) {
         return true;
     }
     $this->cancelUnloadChunkRequest($x, $z);
     $chunk = $this->provider->getChunk($x, $z, $generate);
     if ($chunk instanceof FullChunk) {
         $this->chunks[$index] = $chunk;
     } else {
         $this->timings->syncChunkLoadTimer->startTiming();
         $this->provider->loadChunk($x, $z, $generate);
         $this->timings->syncChunkLoadTimer->stopTiming();
         if (($chunk = $this->provider->getChunk($x, $z)) instanceof FullChunk) {
             $this->chunks[$index] = $chunk;
         } else {
             return false;
         }
     }
     $this->server->getPluginManager()->callEvent(new ChunkLoadEvent($chunk, !$chunk->isGenerated()));
     return true;
 }