当前位置: 首页>>代码示例>>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;未经允许,请勿转载。