本文整理汇总了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();
}
}
}
示例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"));
}
}
}
示例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;
}
}
}
示例4: onBreak
public function onBreak(BlockBreakEvent $ev)
{
$player = $ev->getPlayer();
$cfg = $this->config->getAll();
if ($ev->isCancelled()) {
$player->setHeatlh($player->getHealth() - $cfg["Damage"]);
return;
}
}
示例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);
}
}
示例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);
}
}
}
示例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));
}
}
示例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);
}
}
}
示例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]));
}
}
}
示例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)));
}
}
}
示例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));
}
}
示例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);
}
示例13: onBlockBreak
public function onBlockBreak(BlockBreakEvent $event)
{
if (!$event->isCancelled()) {
$this->checkArea($event);
}
}
示例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();
}
示例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();
}