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


PHP BlockBreakEvent::getItem方法代碼示例

本文整理匯總了PHP中pocketmine\event\block\BlockBreakEvent::getItem方法的典型用法代碼示例。如果您正苦於以下問題:PHP BlockBreakEvent::getItem方法的具體用法?PHP BlockBreakEvent::getItem怎麽用?PHP BlockBreakEvent::getItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pocketmine\event\block\BlockBreakEvent的用法示例。


在下文中一共展示了BlockBreakEvent::getItem方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: onBreak

 public function onBreak(BlockBreakEvent $event)
 {
     $player = $event->getPlayer();
     if ($player->isCreative()) {
         return;
     }
     $time = round(microtime(true) * 1000);
     if ($event->getBlock()->getBreakTime($event->getItem()) <= 0.2) {
         return;
     }
     if ($time - $this->tictock[$player->getName()] <= 200) {
         if (!isset($this->kick[$player->getName()])) {
             $this->kick[$player->getName()] = 1;
         } else {
             $this->kick[$player->getName()]++;
         }
         if ($this->kick > 2) {
             $player->kick("파괴자모드 감지");
             if (isset($this->kick[$player->getName()])) {
                 unset($this->kick[$player->getName()]);
             }
         }
         $event->setCancelled();
     } else {
         if (isset($this->kick[$player->getName()])) {
             unset($this->kick[$player->getName()]);
         }
     }
     $this->tictock[$player->getName()] = $time;
 }
開發者ID:EmreTr1,項目名稱:rtr,代碼行數:30,代碼來源:TICTOCK.php

示例2: onBlockBreak

 public function onBlockBreak(BlockBreakEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     $pl = $ev->getPlayer();
     if (!$this->getState($pl, false)) {
         return;
     }
     if (!$pl->isCreative() || !$this->creative) {
         if ($this->items && !isset($this->items[$ev->getItem()->getId()])) {
             echo "Not using an Axe\n";
             //##DEBUG
             return;
         }
     }
     if ($this->leaves) {
         $damage = $this->destroyTree($ev->getBlock());
     } else {
         $damage = $this->destroyTrunk($ev->getBlock());
     }
     if ($damage && $this->items && $this->itemwear) {
         $hand = $pl->getInventory()->getItemInHand();
         $hand->setDamage($hand->getDamage() + $this->itemwear * $damage);
         $pl->getInventory()->setItemInHand($hand);
         if ($this->broadcast) {
             $this->owner->getServer()->broadcastMessage(mc::_("%1% used TreeCapitator", $pl->getName()));
         } else {
             $pl->sendMessage(mc::_("Used TreeCapitator"));
         }
     }
 }
開發者ID:DWWf,項目名稱:pocketmine-plugins,代碼行數:32,代碼來源:TreeCapitator.php

示例3: blockBreak

 public function blockBreak(BlockBreakEvent $event)
 {
     //1
     $id = $event->getItem()->getId();
     if ($id == $this->id) {
         $player = $event->getPlayer();
         $username = $player->getName();
         if (empty($this->data[$user][1])) {
             $x = $event->getBlock()->x;
             $y = $event->getBlock()->y;
             $z = $event->getBlock()->z;
             $this->data[$user][1] = array($x, $y, $z);
             $ms = "";
             if (isset($this->data[$user][2])) {
                 //片方がセットされていたら
                 $ms = "[FiredNubesco] Second position has been set to: {$x}, {$y}, {$z}";
                 $size = $this->countBlocks($player);
                 if ($num != false) {
                     $ms .= " (Size: " . $size[0] . "X" . $size[1] . ")";
                 }
             } else {
                 $ms = "[FiredNubesco] First position has been set to: {$x}, {$y}, {$z}";
             }
             $player->sendMessage($ms);
             $event->setCancelled(true);
         }
     }
     return true;
 }
開發者ID:nao20010128nao,項目名稱:FiredNubesco,代碼行數:29,代碼來源:PluginMain.php

示例4: onBlockBreak

 public function onBlockBreak(BlockBreakEvent $event)
 {
     if ($event->isCancelled()) {
         return;
     }
     if ($this->chopTree($event->getPlayer(), $event->getBlock(), $event->getItem(), self::TYPE_BREAK)) {
         $event->setCancelled(true);
     }
 }
開發者ID:nesgohood,項目名稱:PMMP-Plugins,代碼行數:9,代碼來源:ChopTree.php

示例5: onBlockBreak

 public function onBlockBreak(BlockBreakEvent $event)
 {
     $key = $event->getBlock()->x . "." . $event->getBlock()->y . "." . $event->getBlock()->z;
     foreach ($this->crops as $crop) {
         if ($event->getItem()->getId() == $crop["item"] and isset($this->farmData[$key])) {
             unset($this->farmData[$key]);
         }
     }
 }
開發者ID:pilock,項目名稱:Farms,代碼行數:9,代碼來源:Farms.php

示例6: onBlockBreak

 public function onBlockBreak(BlockBreakEvent $event)
 {
     if ($event->isCancelled()) {
         return;
     } else {
         $event->setCancelled();
     }
     foreach ($event->getBlock()->getDrops($event->getItem()) as $i) {
         $event->getPlayer()->getInventory()->addItem(Item::get(...$i));
     }
 }
開發者ID:stoastye85,項目名稱:Plugins,代碼行數:11,代碼來源:BlockPickUp.php

示例7: onBreak

 public function onBreak(BlockBreakEvent $event)
 {
     $block = $event->getBlock();
     if ($block instanceof Crops and !$event->getItem()->isHoe()) {
         if ($block->getId() === Block::PUMPKIN_STEM or $block->getId() === Block::MELON_STEM) {
             $event->setCancelled();
         } else {
             $this->blocks[microtime(true) + mt_rand(1, 5) . "." . mt_rand(0, 5)] = $block;
             $this->runTask();
         }
     }
 }
開發者ID:thebigsmileXD,項目名稱:PocketMine-MP-Plugins,代碼行數:12,代碼來源:MainClass.php

示例8: onBreak

 public function onBreak(BlockBreakEvent $event)
 {
     if ($event->isCancelled()) {
         return;
     }
     $player = $event->getPlayer();
     $block = $event->getBlock();
     $drops = $block->getDrops($event->getItem());
     $x = $block->x + 0.5;
     $y = $block->y + 0.5;
     $z = $block->z + 0.5;
     $tile = $block->getLevel()->getTile($block);
     if ($tile instanceof Chest) {
         return;
     }
     if ($event->getItem() instanceof Item) {
         $event->getItem()->useOn($block);
         if ($event->getItem()->isTool() and $event->getItem()->getDamage() >= $event->getItem()->getMaxDurability()) {
             $event->getPlayer()->getInventory()->setItemInHand(Item::get(Item::AIR, 0, 0));
         }
     }
     if (!$player instanceof Player) {
         foreach ($drops as $drop) {
             if ($drop[2] > 0) {
                 $event->getBlock()->getLevel()->dropItem($event->getBlock()->add(0.5, 0.5, 0.5), Item::get(...$drop));
             }
         }
     } else {
         if ($player->isSurvival()) {
             $this->breakQueue["{$block->x}:{$block->y}:{$block->z}"]["drop"] = $drops;
             $this->breakQueue["{$block->x}:{$block->y}:{$block->z}"]["player"] = $player;
             $this->itemQueue["{$x}:{$y}:{$z}"] = $drops;
         }
     }
 }
開發者ID:EmreTr1,項目名稱:rtr,代碼行數:35,代碼來源:ItemConsume.php

示例9: onBlockBreak

 public function onBlockBreak(BlockBreakEvent $event)
 {
     if ($event->isCancelled()) {
         return;
     }
     $b = $event->getBlock();
     foreach ($b->getDrops($event->getItem()) as $i) {
         $this->item[$i[0] . ":" . $i[1] . ":" . $i[2]] = true;
         for ($for = 0; $for < $this->getCount(); $for++) {
             $b->getLevel()->dropItem($b, Item::get($i[0], $i[1], $i[2]));
         }
     }
 }
開發者ID:Skull3x,項目名稱:MineBlock,代碼行數:13,代碼來源:DropCount.php

示例10: onBlockBreak

 public function onBlockBreak(BlockBreakEvent $event)
 {
     $block = $event->getBlock();
     $blockid = $block->getID();
     $itemid = $event->getItem()->getID();
     foreach ($this->growids as $index => $growid) {
         if ($itemid == $growid) {
             if (isset($this->farmdata[$block->x . "." . $block->y . "." . $block->z])) {
                 unset($this->farmdata[$block->x . "." . $block->y . "." . $block->z]);
             }
         }
     }
 }
開發者ID:EmreTr1,項目名稱:rtr,代碼行數:13,代碼來源:Farms.php

示例11: onBreak

 public function onBreak(BlockBreakEvent $event)
 {
     //ItemDamageBug
     $player = $event->getPlayer();
     $item = $event->getItem();
     if ($item->isTool() and !$event->isCancelled() and self::ENABLE_ITEM_DAMAGE_BUG) {
         if ($item->useOn($event->getBlock()) and $item->getDamage() >= $item->getMaxDurability()) {
             $player->getInventory()->setItemInHand(Item::get(Item::AIR, 0, 1));
         } else {
             $player->getInventory()->setItemInHand($item);
         }
     }
 }
開發者ID:thebigsmileXD,項目名稱:PocketMine-MP-Plugins,代碼行數:13,代碼來源:MainClass.php

示例12: 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

示例13: onBreak

 public function onBreak(BlockBreakEvent $event)
 {
     if (!$event->getPlayer()->hasPermission("TreeChopper")) {
         return;
     }
     if ($event->getBlock()->getId() == Block::LOG) {
         $block = $event->getBlock();
         $down = $block->getLevel()->getBlockIdAt($block->x, $block->y - 1, $block->z);
         if ($down != Block::GRASS and $down != Block::DIRT) {
             return;
         }
         $x = $block->x + 0.5;
         $y = $block->y + 0.5;
         $z = $block->z + 0.5;
         $drops = $block->getDrops($event->getItem());
         $this->breakQueue["{$block->x}:{$block->y}:{$block->z}"]["drop"] = $drops;
         $this->breakQueue["{$block->x}:{$block->y}:{$block->z}"]["player"] = $event->getPlayer();
         $this->itemQueue["{$x}:{$y}:{$z}"] = $drops;
     }
 }
開發者ID:EmreTr1,項目名稱:rtr,代碼行數:20,代碼來源:TreeChopper.php

示例14: onBreak

 public function onBreak(BlockBreakEvent $ev)
 {
     //echo __METHOD__.",".__LINE__."\n";//##DEBUG
     if ($ev->isCancelled()) {
         return;
     }
     $pl = $ev->getPlayer();
     if (!$this->getState($pl, false)) {
         return;
     }
     if ($ev->getBlock()->getId() == Block::AIR) {
         return;
     }
     if (!$pl->isCreative() || !$this->creative) {
         if ($this->items && !isset($this->items[$ev->getItem()->getId()])) {
             //echo "Not using an PickAxe\n"; //##DEBUG
             return;
         }
     }
     $ev->setInstaBreak(true);
 }
開發者ID:DWWf,項目名稱:pocketmine-plugins,代碼行數:21,代碼來源:PowerTool.php

示例15: snowShot

 public function snowShot(BlockBreakEvent $e)
 {
     $v3 = new Vector3($x, $y, $z);
     $player = $e->getPlayer();
     if ($e->getItem() == 256 && $this->isInArena($player)) {
         $this->spawnEnity = true;
     }
 }
開發者ID:andrewnoelcasper,項目名稱:Falcon-Spleef,代碼行數:8,代碼來源:index.php


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