isChunkLoaded() public method

public isChunkLoaded ( integer $X, integer $Z ) : boolean
$X integer
$Z integer
return boolean
Example #1
0
 /**
  * @param int $x
  * @param int $z
  *
  * @return bool
  */
 public function isChunkLoaded($x, $z)
 {
     return isset($this->chunks[PHP_INT_SIZE === 8 ? ($x & 4294967295.0) << 32 | $z & 4294967295.0 : $x . ":" . $z]) or $this->provider->isChunkLoaded($x, $z);
 }
Example #2
0
 /**
  * @param int $x
  * @param int $z
  *
  * @return bool
  */
 public function isChunkLoaded($x, $z)
 {
     return isset($this->chunks[Level::chunkHash($x, $z)]) or $this->provider->isChunkLoaded($x, $z);
 }
Example #3
0
 public function unloadChunk($x, $z, $safe = \true, $trySave = \true)
 {
     if ($safe === \true and $this->isChunkInUse($x, $z)) {
         return \false;
     }
     if (!(isset($this->chunks[\PHP_INT_SIZE === 8 ? ($x & 0xffffffff) << 32 | $z & 0xffffffff : $x . ":" . $z]) or $this->provider->isChunkLoaded($x, $z))) {
         return \true;
     }
     $this->timings->doChunkUnload->startTiming();
     $index = \PHP_INT_SIZE === 8 ? ($x & 0xffffffff) << 32 | $z & 0xffffffff : $x . ":" . $z;
     $chunk = $this->getChunk($x, $z);
     if ($chunk !== \null and $chunk->getProvider() !== \null) {
         $this->server->getPluginManager()->callEvent($ev = new ChunkUnloadEvent($chunk));
         if ($ev->isCancelled()) {
             $this->timings->doChunkUnload->stopTiming();
             return \false;
         }
     }
     try {
         if ($chunk !== \null) {
             if ($trySave and $this->getAutoSave()) {
                 $entities = 0;
                 foreach ($chunk->getEntities() as $e) {
                     if ($e instanceof Player) {
                         continue;
                     }
                     ++$entities;
                 }
                 if ($chunk->hasChanged() or \count($chunk->getTiles()) > 0 or $entities > 0) {
                     $this->provider->setChunk($x, $z, $chunk);
                     $this->provider->saveChunk($x, $z);
                 }
             }
             foreach ($this->getChunkLoaders($x, $z) as $loader) {
                 $loader->onChunkUnloaded($chunk);
             }
         }
         $this->provider->unloadChunk($x, $z, $safe);
     } catch (\Exception $e) {
         $logger = $this->server->getLogger();
         $logger->error($this->server->getLanguage()->translateString("pocketmine.level.chunkUnloadError", [$e->getMessage()]));
         if ($logger instanceof MainLogger) {
             $logger->logException($e);
         }
     }
     unset($this->chunks[$index]);
     unset($this->chunkTickList[$index]);
     unset($this->chunkCache[$index]);
     $this->timings->doChunkUnload->stopTiming();
     return \true;
 }
Example #4
0
 /**
  * @param int $x
  * @param int $z
  *
  * @return bool
  */
 public function isChunkLoaded($x, $z)
 {
     return isset($this->chunks["{$x}:{$z}"]) or $this->provider->isChunkLoaded($x, $z);
 }
Example #5
0
 /**
  * @param int $x
  * @param int $z
  *
  * @return bool
  */
 public function isChunkLoaded($x, $z)
 {
     return isset($this->chunks[\PHP_INT_SIZE === 8 ? ($x & 0xffffffff) << 32 | $z & 0xffffffff : $x . ":" . $z]) or $this->provider->isChunkLoaded($x, $z);
 }