pocketmine\block\Piston::place PHP Method

place() public method

public place ( Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null )
$item pocketmine\item\Item
$block Block
$target Block
$player pocketmine\Player
    public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
    {
        if ($player instanceof Player) {
            $pitch = $player->getPitch();
            if (abs($pitch) >= 45) {
                if ($pitch < 0) {
                    $f = 0;
                } else {
                    $f = 1;
                }
            } else {
                $f = $player->getDirection() + 2;
            }
        } else {
            $f = 0;
        }
        $faces = [0 => 0, 1 => 1, 2 => 5, 3 => 3, 4 => 4, 5 => 2];
        $this->meta = $faces[$f];
        $this->getLevel()->setBlock($block, $this, true, true);
        $nbt = new CompoundTag("", [new StringTag("id", Tile::PISTON), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z), new IntTag("blockData", 0), new IntTag("blockId", Item::PISTON_HEAD), new ByteTag("extending", 0), new IntTag("facing", $faces[$f]), new FloatTag("progress", 0.0)]);
        $tile = Tile::createTile("Piston", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
        return true;
    }