pocketmine\block\Block::getSide PHP Метод

getSide() публичный Метод

Returns the Block on the side $side, works like Vector3::side()
public getSide ( integer $side, integer $step = 1 ) : Block
$side integer
$step integer
Результат Block
    public function getSide($side, $step = 1)
    {
        if ($this->isValid()) {
            return $this->getLevel()->getBlock(Vector3::getSide($side, $step));
        }
        return Block::get(Item::AIR, 0, Position::fromObject(Vector3::getSide($side, $step)));
    }

Usage Example

Пример #1
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $down = $block->getSide(Vector3::SIDE_DOWN);
     if ($down->isTransparent() === false || $down instanceof Slab && ($down->meta & 0x8) === 0x8 || $down instanceof WoodSlab && ($down->meta & 0x8) === 0x8 || $down instanceof Stair && ($down->meta & 0x4) === 0x4) {
         $this->getLevel()->setBlock($this, Block::get($this->id, 0));
         $up = $block->getSide(Vector3::SIDE_UP);
         if ($block->getSide(Vector3::SIDE_EAST) && $block->getSide(Vector3::SIDE_WEST)) {
             if ($up->getSide(Vector3::SIDE_EAST)) {
                 $this->setDirection(Vector3::SIDE_EAST, true);
             } elseif ($up->getSide(Vector3::SIDE_WEST)) {
                 $this->setDirection(Vector3::SIDE_WEST, true);
             } else {
                 $this->setDirection(Vector3::SIDE_EAST);
             }
         } elseif ($block->getSide(Vector3::SIDE_SOUTH) && $block->getSide(Vector3::SIDE_NORTH)) {
             if ($up->getSide(Vector3::SIDE_SOUTH)) {
                 $this->setDirection(Vector3::SIDE_SOUTH, true);
             } elseif ($up->getSide(Vector3::SIDE_NORTH)) {
                 $this->setDirection(Vector3::SIDE_NORTH, true);
             } else {
                 $this->setDirection(Vector3::SIDE_SOUTH);
             }
         } else {
             $this->setDirection(Vector3::SIDE_NORTH);
         }
         return true;
     }
     return false;
 }
All Usage Examples Of pocketmine\block\Block::getSide