当前位置: 首页>>代码示例>>PHP>>正文


PHP BlockBreakEvent::setInstaBreak方法代码示例

本文整理汇总了PHP中pocketmine\event\block\BlockBreakEvent::setInstaBreak方法的典型用法代码示例。如果您正苦于以下问题:PHP BlockBreakEvent::setInstaBreak方法的具体用法?PHP BlockBreakEvent::setInstaBreak怎么用?PHP BlockBreakEvent::setInstaBreak使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\event\block\BlockBreakEvent的用法示例。


在下文中一共展示了BlockBreakEvent::setInstaBreak方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

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

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

示例3: useBreakOn

 /**
  * Tries to break a block using a item, including Player time checks if available
  *
  * @param Vector3 $vector
  * @param Item    &$item (if null, can break anything)
  * @param Player  $player
  *
  * @return boolean
  */
 public function useBreakOn(Vector3 $vector, Item &$item = null, Player $player = null)
 {
     $target = $this->getBlock($vector);
     //TODO: Adventure mode checks
     if ($item === null) {
         $item = Item::get(Item::AIR, 0, 0);
     }
     if ($player instanceof Player) {
         $ev = new BlockBreakEvent($player, $target, $item, ($player->getGamemode() & 0x1) === 1 ? true : false);
         $lastTime = $player->lastBreak - 0.1;
         //TODO: replace with true lag
         if (($player->getGamemode() & 0x1) > 0) {
             $ev->setInstaBreak(true);
         } elseif ($lastTime + $target->getBreakTime($item) >= microtime(true)) {
             $ev->setCancelled();
         }
         if ($item instanceof Item and !$target->isBreakable($item) and $ev->getInstaBreak() === false) {
             $ev->setCancelled();
         }
         if (!$player->isOp() and ($distance = $this->server->getConfigInt("spawn-protection", 16)) > -1) {
             $t = new Vector2($target->x, $target->z);
             $s = new Vector2($this->getSpawn()->x, $this->getSpawn()->z);
             if ($t->distance($s) <= $distance) {
                 //set it to cancelled so plugins can bypass this
                 $ev->setCancelled();
             }
         }
         $this->server->getPluginManager()->callEvent($ev);
         if ($ev->isCancelled()) {
             return false;
         }
         $player->lastBreak = microtime(true);
     } elseif ($item instanceof Item and !$target->isBreakable($item)) {
         return false;
     }
     $level = $target->getLevel();
     if ($level instanceof Level) {
         $above = $level->getBlock(new Vector3($target->x, $target->y + 1, $target->z));
         if ($above instanceof Block) {
             if ($above->getID() === Item::FIRE) {
                 $level->setBlock($above, new Air(), true);
             }
         }
     }
     $drops = $target->getDrops($item);
     //Fixes tile entities being deleted before getting drops
     $target->onBreak($item);
     $tile = $this->getTile($target);
     if ($tile instanceof Tile) {
         if ($tile instanceof InventoryHolder) {
             if ($tile instanceof Chest) {
                 $tile->unpair();
             }
             foreach ($tile->getInventory()->getContents() as $item) {
                 $this->dropItem($target, $item);
             }
         }
         $tile->close();
     }
     if ($item instanceof Item) {
         $item->useOn($target);
         if ($item->isTool() and $item->getDamage() >= $item->getMaxDurability()) {
             $item = Item::get(Item::AIR, 0, 0);
         }
     }
     if (!$player instanceof Player or ($player->getGamemode() & 0x1) === 0) {
         foreach ($drops as $drop) {
             if ($drop[2] > 0) {
                 $this->dropItem($vector->add(0.5, 0.5, 0.5), Item::get($drop[0], $drop[1], $drop[2]));
             }
         }
     }
     return true;
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:83,代码来源:Level.php

示例4: onBlockBreak

 /**
  * OnBlockBreak
  *
  * @param BlockBreakEvent $event        	
  */
 public function onBlockBreak(BlockBreakEvent $event)
 {
     if (!$event->getPlayer()->isOp()) {
         $allow = $this->checkBlockBreakAndPlacementPermission($event->getPlayer(), $event->getBlock());
         $this->plugin->log("PlayerLobbyListener->onBlockBreak allow: " . $allow);
         if (!$allow) {
             $event->setCancelled(true);
             //$this->plugin->log("[HG] PlayerLobbyListener: onBlockBreak Cancelled for player " . $event->getPlayer ()->getName () );
         }
         if ($allow) {
             if ($event->getBlock()->getId() === Item::CHEST && !$event->getPlayer()->isOp()) {
                 $message = TextFormat::RED . "You are not allow break Chest";
                 $event->getPlayer()->sendPopup($message);
                 $event->setCancelled(true);
             } else {
                 $this->plugin->log("[HG] PlayerLobbyListener: onBlockBreak ALLOW | " . $event->getPlayer()->getGamemode() . "|" . $event->getPlayer()->getName() . "|" . $event->getPlayer()->getLevel()->getName());
                 $event->setInstaBreak(true);
                 $event->setCancelled(false);
             }
         }
     }
 }
开发者ID:robozeri,项目名称:SG,代码行数:27,代码来源:PlayerWelcomeListener.php

示例5: onBreak

 public function onBreak(BlockBreakEvent $event)
 {
     if ($this->active == false and isset($this->players[$event->getPlayer()->getName()])) {
         $event->setCancelled();
     }
     if (isset($this->players[$event->getPlayer()->getName()])) {
         if ($event->getBlock()->getID() != $this->plugin->getConfig()->get("surface")) {
             $event->setCancelled();
         } else {
             if ($this->active == true) {
                 $block = $event->getBlock();
                 $event->setInstaBreak(true);
                 $block = new Position($block->getX(), $block->getY(), $block->getZ(), $block->getLevel());
                 $this->broken[] = $block;
             }
         }
     }
 }
开发者ID:Skull3x,项目名称:WonderCore,代码行数:18,代码来源:Arena.php

示例6: onBreak

 public function onBreak(BlockBreakEvent $ev)
 {
     echo __METHOD__ . "," . __LINE__ . "\n";
     //##DEBUG
     if ($ev->isCancelled()) {
         return;
     }
     $pl = $ev->getPlayer();
     echo __METHOD__ . "," . __LINE__ . "\n";
     //##DEBUG
     if (($m = $this->getState($pl, false)) === false) {
         return;
     }
     echo __METHOD__ . "," . __LINE__ . ":: m={$m}\n";
     //##DEBUG
     if ($m === "insta-break") {
         $ev->setInstaBreak(true);
         return;
     }
     echo __METHOD__ . "," . __LINE__ . "\n";
     //##DEBUG
     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;
         }
     }
     if (substr($ev->getBlock()->getName(), -4) !== " Ore") {
         return;
     }
     // This is an ore...
     $ev->setInstaBreak(true);
     $pl->sendMessage(mc::_("Using VeinMinger"));
     $this->setState($pl, "insta-break");
     //prevents infinite loops...
     $c = $this->veinsearch($ev->getBlock(), $this->blocklimit, $pl, $this->sides);
     $this->setState($pl, true);
     if ($c && $this->broadcast) {
         $this->owner->getServer()->broadcastMessage(mc::n(mc::_("%1% used VeinMiner (one block affected)", $pl->getDisplayName()), mc::_("%1% used VeinMiner (%2% blocks affected)", $pl->getDisplayName(), $c), $c));
     }
 }
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:44,代码来源:VeinMiner.php

示例7: onBreak

 public function onBreak(BlockBreakEvent $ev)
 {
     $ev->setInstaBreak(true);
 }
开发者ID:AvivShopen,项目名称:bad-plugins,代码行数:4,代码来源:playerHack.php


注:本文中的pocketmine\event\block\BlockBreakEvent::setInstaBreak方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。