pocketmine\level\Level::dropItem PHP Method

dropItem() public method

public dropItem ( Vector3 $source, Item $item, Vector3 $motion = null, integer $delay = 10 ) : null | Item
$source pocketmine\math\Vector3
$item pocketmine\item\Item
$motion pocketmine\math\Vector3
$delay integer
return null | pocketmine\entity\Item
    public function dropItem(Vector3 $source, Item $item, Vector3 $motion = null, int $delay = 10)
    {
        $motion = $motion === null ? new Vector3(lcg_value() * 0.2 - 0.1, 0.2, lcg_value() * 0.2 - 0.1) : $motion;
        $itemTag = NBT::putItemHelper($item);
        $itemTag->setName("Item");
        if ($item->getId() > 0 and $item->getCount() > 0) {
            $itemEntity = Entity::createEntity("Item", $this->getChunk($source->getX() >> 4, $source->getZ() >> 4, true), new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $source->getX()), new DoubleTag("", $source->getY()), new DoubleTag("", $source->getZ())]), "Motion" => new ListTag("Motion", [new DoubleTag("", $motion->x), new DoubleTag("", $motion->y), new DoubleTag("", $motion->z)]), "Rotation" => new ListTag("Rotation", [new FloatTag("", lcg_value() * 360), new FloatTag("", 0)]), "Health" => new ShortTag("Health", 5), "Item" => $itemTag, "PickupDelay" => new ShortTag("PickupDelay", $delay)]));
            $itemEntity->spawnToAll();
            return $itemEntity;
        }
        return null;
    }
Level