Пример #1
0
 public function getSafeSpawn($spawn = false)
 {
     if ($spawn === false) {
         $spawn = $this->getSpawn();
     }
     if ($spawn instanceof Vector3) {
         $x = (int) round($spawn->x);
         $y = (int) round($spawn->y);
         $z = (int) round($spawn->z);
         for (; $y > 0; --$y) {
             $v = new Vector3($x, $y, $z);
             $b = $this->getBlock($v->getSide(0));
             if ($b === false) {
                 return $spawn;
             } elseif (!$b instanceof AirBlock) {
                 break;
             }
         }
         for (; $y < 128; ++$y) {
             $v = new Vector3($x, $y, $z);
             if ($this->getBlock($v->getSide(1)) instanceof AirBlock) {
                 if ($this->getBlock($v) instanceof AirBlock) {
                     return new Position($x, $y, $z, $this);
                 }
             } else {
                 ++$y;
             }
         }
         return new Position($x, $y, $z, $this);
     }
     return false;
 }
Пример #2
0
 public function getSide($side)
 {
     return new Position(parent::getSide($side), 0, 0, $this->level);
 }