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


PHP BlockBreakEvent::isCancelled方法代码示例

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


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

示例1: BlockBreakEvent

 public function BlockBreakEvent(BlockBreakEvent $ev)
 {
     $pos = $ev->getBlock();
     if ($ev->isCancelled() || $pos->getId() != Item::MONSTER_SPAWNER) {
         return;
     }
     if (isset(self::$spawn["{$pos->x}:{$pos->y}:{$pos->z}"])) {
         unset(self::$spawn["{$pos->x}:{$pos->y}:{$pos->z}"]);
     } elseif (isset(self::$spawn["{$pos->x}:{$pos->y}:{$pos->z}:{$pos->getLevel()->getFolderName()}"])) {
         unset(self::$spawn["{$pos->x}:{$pos->y}:{$pos->z}:{$pos->getLevel()->getFolderName()}"]);
     }
     if (($ev->getBlock()->getId() == Block::STONE or $ev->getBlock()->getId() == Block::STONE_BRICK or $ev->getBlock()->getId() == Block::STONE_WALL or $ev->getBlock()->getId() == Block::STONE_BRICK_STAIRS) && ($ev->getBlock()->getLightLevel() < 12 and mt_rand(1, 3) < 2)) {
         $entity = self::create("Silverfish", $pos);
         if ($entity != null) {
             $entity->spawnToAll();
         }
     }
 }
开发者ID:steveritter,项目名称:EntityManager,代码行数:18,代码来源:EntityManager.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: 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

示例4: onBreak

 public function onBreak(BlockBreakEvent $ev)
 {
     $player = $ev->getPlayer();
     $cfg = $this->config->getAll();
     if ($ev->isCancelled()) {
         $player->setHeatlh($player->getHealth() - $cfg["Damage"]);
         return;
     }
 }
开发者ID:Skull3x,项目名称:DamageOnBreak,代码行数:9,代码来源:Main.php

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

示例6: onBreak

 /**
  * @param BlockBreakEvent $event
  *
  * @priority HIGHEST
  */
 public function onBreak(BlockBreakEvent $event)
 {
     if ($event->isCancelled()) {
         $p = $event->getPlayer();
         if (isset($this->positions[$p->getName()])) {
             $pos = $this->positions[$p->getName()];
             $this->revert($p, $pos, $pos->yaw, $pos->pitch);
         }
     }
 }
开发者ID:diamond-gold,项目名称:BlockBreakClimbingFix,代码行数:15,代码来源:Main.php

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

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

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

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

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

示例13: onBlockBreak

 public function onBlockBreak(BlockBreakEvent $event)
 {
     if (!$event->isCancelled()) {
         $this->checkArea($event);
     }
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:6,代码来源:ProtectArea.php

示例14: onBlockBreak

 public function onBlockBreak(BlockBreakEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     $bl = $ev->getBlock();
     $world = $bl->getLevel()->getName();
     if (!isset($this->wcfg[$world])) {
         return;
     }
     if (!isset($this->wcfg[$world][$bl->getId()])) {
         return;
     }
     $pl = $ev->getPlayer();
     $pl->sendMessage(mc::_("It can not be broken!"));
     $ev->setCancelled();
 }
开发者ID:Gabriel865,项目名称:pocketmine-plugins,代码行数:17,代码来源:Unbreakable.php

示例15: onBlockBreak

 public function onBlockBreak(BlockBreakEvent $event)
 {
     if ($event->isCancelled()) {
         return;
     }
     $b = $event->getBlock();
     $key = $this->getKey($b);
     if (!isset($this->mb[$key])) {
         return;
     }
     if (!$event->getPlayer()->hasPermission("debe.mineblock.break")) {
         return $event->setCancelled();
     }
     $mb = $this->mb[$key];
     $rand = $this->rand[$key];
     foreach ($b->getDrops($event->getItem()) as $i) {
         $this->item[$i[0] . ":" . $i[1] . ":" . $i[2]] = true;
     }
     if ($mb[0] == true) {
         $this->getServer()->getScheduler()->scheduleDelayedTask(new CallbackTask([$this, "mineRegen"], [clone $b]), $this->randStr($mb[1]));
     }
     for ($for = 0; $for < $this->randStr($mb[2]); $for++) {
         $b->getLevel()->dropItem($b, $this->getDrop($mb, $rand));
     }
     $event->setCancelled();
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:26,代码来源:MineBlock.php


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