loadChunk() 공개 메소드

public loadChunk ( integer $X, integer $Z, boolean $create = false ) : boolean
$X integer
$Z integer
$create boolean
리턴 boolean
예제 #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;
 }
예제 #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;
 }