當前位置: 首頁>>代碼示例>>PHP>>正文


PHP BlockBreakEvent::setDrops方法代碼示例

本文整理匯總了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);
     }
 }
開發者ID:LilianRise,項目名稱:OreInstantDrop,代碼行數:11,代碼來源:Main.php

示例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)));
         }
     }
 }
開發者ID:Ad5001,項目名稱:AutoSmelt,代碼行數:18,代碼來源:Main.php

示例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();
         }
     }
 }
開發者ID:Bluplayz,項目名稱:BedwarsPE,代碼行數:39,代碼來源:Bedwars.php


注:本文中的pocketmine\event\block\BlockBreakEvent::setDrops方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。