本文整理汇总了PHP中BukkitPE\item\Item::useOn方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::useOn方法的具体用法?PHP Item::useOn怎么用?PHP Item::useOn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BukkitPE\item\Item
的用法示例。
在下文中一共展示了Item::useOn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onActivate
public function onActivate(Item $item, Player $player = null)
{
if ($item->getId() === Item::DYE and $item->getDamage() === 0xf) {
$item->count--;
TallGrassObject::growGrass($this->getLevel(), $this, new Random(mt_rand()), 8, 2);
return true;
} elseif ($item->isHoe()) {
$item->useOn($this);
$this->getLevel()->setBlock($this, new Farmland());
return true;
} elseif ($item->isShovel() and $this->getSide(1)->getId() === Block::AIR) {
$item->useOn($this);
$this->getLevel()->setBlock($this, new GrassPath());
return true;
}
return false;
}
示例2: onActivate
public function onActivate(Item $item, Player $player = null)
{
if ($item->isHoe()) {
$item->useOn($this);
$this->getLevel()->setBlock($this, Block::get(Item::FARMLAND, 0), true);
return true;
}
return false;
}
示例3: onActivate
public function onActivate(Item $item, Player $player = null)
{
if ($item->getId() === Item::FLINT_STEEL) {
$item->useOn($this);
$this->getLevel()->setBlock($this, new Air(), true);
$mot = (new Random())->nextSignedFloat() * M_PI * 2;
$tnt = Entity::createEntity("PrimedTNT", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new Compound("", ["Pos" => new Enum("Pos", [new Double("", $this->x + 0.5), new Double("", $this->y), new Double("", $this->z + 0.5)]), "Motion" => new Enum("Motion", [new Double("", -sin($mot) * 0.02), new Double("", 0.2), new Double("", -cos($mot) * 0.02)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)]), "Fuse" => new Byte("Fuse", 80)]));
$tnt->spawnToAll();
return true;
}
return false;
}