本文整理汇总了PHP中pocketmine\event\entity\EntityShootBowEvent::setProjectile方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityShootBowEvent::setProjectile方法的具体用法?PHP EntityShootBowEvent::setProjectile怎么用?PHP EntityShootBowEvent::setProjectile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\event\entity\EntityShootBowEvent
的用法示例。
在下文中一共展示了EntityShootBowEvent::setProjectile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onEntityShootBow
public function onEntityShootBow(EntityShootBowEvent $event)
{
if (!$event->isCancelled()) {
$arrow = $event->getProjectile();
$set = [$arrow->chunk, $arrow->nametag, $p];
$newArrow = new AbilityArrow(...$set);
$p = $event->getEntity();
if ($p instanceof Player) {
if (!$p->isCreative()) {
$list = [1 => FireArrow::class, 5 => TeleportArrow::class, 7 => SpiderArrow::class, 9 => HealArrow::class, 12 => PowerArrow::class];
$inv = $p->getInventory();
foreach ($inv->getContents() as $k => $i) {
$d = $i->getDamage();
if ($i->getID() == 351 && isset($list[$d])) {
$i->setCount($i->getCount() - 1);
$inv->setItem($k, $i);
$p->sendMessage([1 => "FireArrow", 5 => "TeleportArrow", 7 => "SpiderArrow", 9 => "HealArrow", 12 => "PowerArrow"][$d]);
$newArrow = new $list[$d](...$set);
break;
}
}
}
}
$event->setProjectile($newArrow);
}
}