pocketmine\block\Dropper::place PHP Метод

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

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)
    {
        $dispenser = null;
        if ($player instanceof Player) {
            $pitch = $player->getPitch();
            if (abs($pitch) >= 45) {
                if ($pitch < 0) {
                    $f = 4;
                } else {
                    $f = 5;
                }
            } else {
                $f = $player->getDirection();
            }
        } else {
            $f = 0;
        }
        $faces = [3 => 3, 0 => 4, 2 => 5, 1 => 2, 4 => 0, 5 => 1];
        $this->meta = $faces[$f];
        $this->getLevel()->setBlock($block, $this, true, true);
        $nbt = new CompoundTag("", [new ListTag("Items", []), new StringTag("id", Tile::DROPPER), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z)]);
        $nbt->Items->setTagType(NBT::TAG_Compound);
        if ($item->hasCustomName()) {
            $nbt->CustomName = new StringTag("CustomName", $item->getCustomName());
        }
        if ($item->hasCustomBlockData()) {
            foreach ($item->getCustomBlockData() as $key => $v) {
                $nbt->{$key} = $v;
            }
        }
        Tile::createTile(Tile::DROPPER, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
        return true;
    }