本文整理汇总了PHP中pocketmine\event\block\BlockBreakEvent::setDrops方法的典型用法代码示例。如果您正苦于以下问题:PHP BlockBreakEvent::setDrops方法的具体用法?PHP BlockBreakEvent::setDrops怎么用?PHP BlockBreakEvent::setDrops使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\event\block\BlockBreakEvent
的用法示例。
在下文中一共展示了BlockBreakEvent::setDrops方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onBreak
public function onBreak(BlockBreakEvent $event)
{
if ($event->getBlock()->getId() == 15) {
$drops = array(Item::get(265, 0, 1));
$event->setDrops($drops);
}
if ($event->getBlock()->getId() == 14) {
$drops = array(Item::get(266, 0, 1));
$event->setDrops($drops);
}
}
示例2: onBreak
public function onBreak(BlockBreakEvent $ev)
{
$p = $ev->getPlayer();
$block = $ev->getBlock();
$item = $ev->getItem()->getId();
$ev->setInstaBreak(true);
foreach ($this->ores as $ore) {
if ($block->getId() === $ore && !$ev->isCancelled()) {
$ev->setDrops(array());
$p->sendMessage("§l§dAUTO-SMELTED!");
$p->getInventory()->addItem(Item::get($this->ingot[$ore]));
$x = $p->getX();
$y = $p->getY();
$z = $p->getZ();
$p->getLevel()->addSound(new FizzSound(new Vector3($x, $y, $z)));
}
}
}
示例3: onBreak
public function onBreak(BlockBreakEvent $event)
{
$player = $event->getPlayer();
$name = $player->getName();
$block = $event->getBlock();
$block2 = $player->getLevel()->getBlock(new Vector3($block->getX(), $block->getY() - 1, $block->getZ()), false);
if ($this->inArena($player)) {
$arena = $this->getArena($player);
$config = new Config($this->getDataFolder() . "Arenas/" . $arena . ".yml", Config::YAML);
$team = $this->getTeamByBed($arena, $block);
if ($config->get("Status") != "Lobby") {
if ($block->getId() == Block::BED_BLOCK) {
if ($team != $this->getTeam($player->getNameTag())) {
$config->setNested("Bed." . $team . ".Alive", false);
$config->save();
$event->setDrops(array());
$player->sendMessage($this->prefix . "Du hast das Bett von Team " . $team . " zerstört!");
foreach ($this->getPlayers($arena) as $pn) {
$p = $this->getServer()->getPlayerExact($pn);
if ($p != null) {
if ($team == $this->getTeam($p->getNameTag())) {
$p->sendMessage($this->prefix . TextFormat::RED . "Das Bett von deinem Team wurde zerstört!");
} else {
$p->sendMessage($this->prefix . "Das Bett von Team " . TextFormat::GOLD . $team . TextFormat::WHITE . " wurde zerstört!");
}
}
}
} else {
$player->sendMessage($this->prefix . "Du kannst dein eigenes Bett nicht zerstören!");
$event->setCancelled();
}
} elseif (!in_array($block->getId(), $this->breakableblocks)) {
$event->setCancelled();
}
} else {
$event->setCancelled();
}
}
}