public function dropItem(Item $item)
{
if ($this->spawned === false or $this->blocked === true or !$this->isAlive()) {
return;
}
if ($this->isCreative() and $this->server->limitedCreative or $this->isSpectator()) {
//Ignore for limited creative
return;
}
if ($item->getId() === Item::AIR or $item->getCount() < 1) {
//Ignore dropping air or items with bad counts
return;
}
$ev = new PlayerDropItemEvent($this, $item);
$this->server->getPluginManager()->callEvent($ev);
if ($ev->isCancelled()) {
$this->getFloatingInventory()->removeItem($item);
$this->getInventory()->addItem($item);
return;
}
$motion = $this->getDirectionVector()->multiply(0.4);
$this->level->dropItem($this->add(0, 1.3, 0), $item, $motion, 40);
$this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, false);
}