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


PHP BlockUpdateEvent::getBlock方法代码示例

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


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

示例1: onBlockUpdate

 public function onBlockUpdate(BlockUpdateEvent $event)
 {
     /*
      * Disables water and lava flow as a temporary solution.
      */
     $levelName = $event->getBlock()->getLevel()->getName();
     if ($this->plugin->isLevelLoaded($levelName)) {
         $event->setCancelled(true);
     }
     if ($event->getBlock() instanceof Water or $event->getBlock() instanceof Lava) {
         $event->setCancelled(true);
     }
 }
开发者ID:kdani1,项目名称:PEPlot,代码行数:13,代码来源:EventListener.php

示例2: onWaterFlow

 public function onWaterFlow(BlockUpdateEvent $event)
 {
     if ($event->getBlock() instanceof Water) {
         $event->setCancelled();
         $this->dryArea();
     }
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:7,代码来源:Sponge.php

示例3: onBlockUpdate

 /**
  * @priority HIGHEST
  */
 public function onBlockUpdate(BlockUpdateEvent $event)
 {
     if (!$event->isCancelled()) {
         $block = $event->getBlock();
         if (isset($this->levelTickBlocks[$levelName = $block->getLevel()->getFolderName()]) && isset($this->randomTickBlocks[$levelName])) {
             if (in_array($block->getID(), $this->randomTickBlocks[$levelName]) && $block->getID() !== Block::GLASS && !isset($this->levelTickBlocks[$levelName][$posKey = $block->x . ":" . $block->y . ":" . $block->z])) {
                 $this->levelTickBlocks[$levelName][$posKey] = new Position($block->x, $block->y, $block->z, $block->level);
             }
         }
     }
 }
开发者ID:organization,项目名称:AutoGrow,代码行数:14,代码来源:AutoGrow.php

示例4: onSapling

 public function onSapling(BlockUpdateEvent $event)
 {
     if ($event->isCancelled()) {
         return;
     }
     if ($event->getBlock() instanceof Sapling) {
         Tree::growTree($event->getBlock()->getLevel(), $event->getBlock()->x, $event->getBlock()->y, $event->getBlock()->z, new Random(\mt_rand()), $event->getBlock()->getDamage() & 0x7);
     }
 }
开发者ID:nesgohood,项目名称:PMMP-Plugins,代码行数:9,代码来源:GreenBelt.php

示例5: onSapling

 public function onSapling(BlockUpdateEvent $event)
 {
     if ($event->isCancelled()) {
         return;
     }
     if ($event->getBlock()->getId() == Block::SAPLING) {
         $this->growTree($event->getBlock()->getLevel(), $event->getBlock()->x, $event->getBlock()->y, $event->getBlock()->z, new Random(\mt_rand()), $event->getBlock()->getDamage() & 0x7);
     }
 }
开发者ID:EmreTr1,项目名称:rtr,代码行数:9,代码来源:GreenBelt.php

示例6: onAir

 public function onAir(BlockUpdateEvent $event)
 {
     $block = $event->getBlock();
     if (isset($this->breakQueue["{$block->x}:{$block->y}:{$block->z}"])) {
         if ($block->getId() == Block::AIR) {
             foreach ($this->breakQueue["{$block->x}:{$block->y}:{$block->z}"]["drop"] as $drop) {
                 if ($drop[2] > 0) {
                     if (isset($this->breakQueue["{$block->x}:{$block->y}:{$block->z}"]["player"])) {
                         $this->breakQueue["{$block->x}:{$block->y}:{$block->z}"]["player"]->getInventory()->addItem(Item::get(...$drop));
                     }
                     unset($this->breakQueue["{$block->x}:{$block->y}:{$block->z}"]);
                     return;
                 }
             }
         }
     }
     $x = $block->x + 0.5;
     $y = $block->y + 0.5;
     $z = $block->z + 0.5;
     unset($this->itemQueue["{$x}:{$y}:{$z}"]);
 }
开发者ID:EmreTr1,项目名称:rtr,代码行数:21,代码来源:ItemConsume.php

示例7: setBlock

 /**
  * Sets on Vector3 the data from a Block object,
  * does block updates and puts the changes to the send queue.
  *
  * If $direct is true, it'll send changes directly to players. if false, it'll be queued
  * and the best way to send queued changes will be done in the next tick.
  * This way big changes can be sent on a single chunk update packet instead of thousands of packets.
  *
  * If $update is true, it'll get the neighbour blocks (6 sides) and update them.
  * If you are doing big changes, you might want to set this to false, then update manually.
  *
  * @param Vector3 $pos
  * @param Block   $block
  * @param bool    $direct
  * @param bool    $update
  *
  * @return bool Whether the block has been updated or not
  */
 public function setBlock(Vector3 $pos, Block $block, $direct = false, $update = true)
 {
     if ($pos->y < 0 or $pos->y >= 128) {
         return false;
     }
     unset($this->blockCache[$index = PHP_INT_SIZE === 8 ? ($pos->x & 0xfffffff) << 35 | ($pos->y & 0x7f) << 28 | $pos->z & 0xfffffff : $pos->x . ":" . $pos->y . ":" . $pos->z]);
     if ($this->getChunk($pos->x >> 4, $pos->z >> 4, true)->setBlock($pos->x & 0xf, $pos->y & 0x7f, $pos->z & 0xf, $block->getId(), $block->getDamage())) {
         if (!$pos instanceof Position) {
             $pos = $this->temporalPosition->setComponents($pos->x, $pos->y, $pos->z);
         }
         $block->position($pos);
         $index = PHP_INT_SIZE === 8 ? ($pos->x >> 4 & 4294967295.0) << 32 | $pos->z >> 4 & 4294967295.0 : ($pos->x >> 4) . ":" . ($pos->z >> 4);
         if (ADVANCED_CACHE == true) {
             Cache::remove("world:" . $this->getId() . ":" . $index);
         }
         if ($direct === true) {
             $pk = new UpdateBlockPacket();
             $pk->x = $pos->x;
             $pk->y = $pos->y;
             $pk->z = $pos->z;
             $pk->block = $block->getId();
             $pk->meta = $block->getDamage();
             Server::broadcastPacket($this->getUsingChunk($pos->x >> 4, $pos->z >> 4), $pk);
         } else {
             if (!$pos instanceof Position) {
                 $pos = $this->temporalPosition->setComponents($pos->x, $pos->y, $pos->z);
             }
             $block->position($pos);
             if (!isset($this->changedBlocks[$index])) {
                 $this->changedBlocks[$index] = [];
                 $this->changedCount[$index] = 0;
             }
             $Y = $pos->y >> 4;
             if (!isset($this->changedBlocks[$index][$Y])) {
                 $this->changedBlocks[$index][$Y] = [];
                 $this->changedCount[$index] |= 1 << $Y;
             }
             $this->changedBlocks[$index][$Y][] = clone $block;
         }
         if ($update === true) {
             $this->updateAllLight($block);
             $this->server->getPluginManager()->callEvent($ev = new BlockUpdateEvent($block));
             if (!$ev->isCancelled()) {
                 $ev->getBlock()->onUpdate(self::BLOCK_UPDATE_NORMAL);
                 foreach ($this->getNearbyEntities(new AxisAlignedBB($block->x - 1, $block->y - 1, $block->z - 1, $block->x + 2, $block->y + 2, $block->z + 2)) as $entity) {
                     $entity->scheduleUpdate();
                 }
             }
             $this->updateAround($pos);
         }
         return true;
     }
     return false;
 }
开发者ID:RedstoneAlmeida,项目名称:Steadfast2,代码行数:72,代码来源:Level.php

示例8: setBlock

 /**
  * Sets on Vector3 the data from a Block object,
  * does block updates and puts the changes to the send queue.
  *
  * If $direct is true, it'll send changes directly to players. if false, it'll be queued
  * and the best way to send queued changes will be done in the next tick.
  * This way big changes can be sent on a single chunk update packet instead of thousands of packets.
  *
  * If $update is true, it'll get the neighbour blocks (6 sides) and update them.
  * If you are doing big changes, you might want to set this to false, then update manually.
  *
  * @param Vector3 $pos
  * @param Block   $block
  * @param bool    $direct @deprecated
  * @param bool    $update
  * @param bool     $extended
  *
  * @return bool Whether the block has been updated or not
  */
 public function setBlock(Vector3 $pos, Block $block, $direct = false, $update = true, $extended = false)
 {
     if ($pos->y < 0 or $pos->y >= 128) {
         return false;
     }
     if ($this->getChunk($pos->x >> 4, $pos->z >> 4, true)->setBlock($pos->x & 0xf, $pos->y & 0x7f, $pos->z & 0xf, $block->getId(), $block->getDamage())) {
         if (!$pos instanceof Position) {
             $pos = $this->temporalPosition->setComponents($pos->x, $pos->y, $pos->z);
         }
         $block->position($pos);
         unset($this->blockCache[Level::blockHash($pos->x, $pos->y, $pos->z)]);
         $index = Level::chunkHash($pos->x >> 4, $pos->z >> 4);
         if ($direct === true) {
             $this->sendBlocks($this->getChunkPlayers($pos->x >> 4, $pos->z >> 4), [$block], UpdateBlockPacket::FLAG_ALL_PRIORITY);
             unset($this->chunkCache[$index]);
         } else {
             if (!isset($this->changedBlocks[$index])) {
                 $this->changedBlocks[$index] = [];
             }
             $this->changedBlocks[$index][Level::blockHash($block->x, $block->y, $block->z)] = clone $block;
         }
         foreach ($this->getChunkLoaders($pos->x >> 4, $pos->z >> 4) as $loader) {
             $loader->onBlockChanged($block);
         }
         if ($update === true) {
             $this->updateAllLight($block);
             $this->server->getPluginManager()->callEvent($ev = new BlockUpdateEvent($block));
             if (!$ev->isCancelled()) {
                 foreach ($this->getNearbyEntities(new AxisAlignedBB($block->x - 1, $block->y - 1, $block->z - 1, $block->x + 1, $block->y + 1, $block->z + 1)) as $entity) {
                     $entity->scheduleUpdate();
                 }
                 $ev->getBlock()->onUpdate(self::BLOCK_UPDATE_NORMAL);
                 $ev->getBlock()->onUpdate(self::BLOCK_UPDATE_REDSTONE);
             }
             $this->updateAround($pos, $extended);
         }
         return true;
     }
     return false;
 }
开发者ID:robozeri,项目名称:Yuriko-MP,代码行数:59,代码来源:Level.php

示例9: explodeB

 public function explodeB()
 {
     $send = [];
     $updateBlocks = [];
     $source = (new Vector3($this->source->x, $this->source->y, $this->source->z))->floor();
     $yield = 1 / $this->size * 100;
     if ($this->what instanceof Entity) {
         $this->level->getServer()->getPluginManager()->callEvent($ev = new EntityExplodeEvent($this->what, $this->source, $this->affectedBlocks, $yield));
         if ($ev->isCancelled()) {
             return \false;
         } else {
             $yield = $ev->getYield();
             $this->affectedBlocks = $ev->getBlockList();
         }
     }
     $explosionSize = $this->size * 2;
     $minX = Math::floorFloat($this->source->x - $explosionSize - 1);
     $maxX = Math::ceilFloat($this->source->x + $explosionSize + 1);
     $minY = Math::floorFloat($this->source->y - $explosionSize - 1);
     $maxY = Math::ceilFloat($this->source->y + $explosionSize + 1);
     $minZ = Math::floorFloat($this->source->z - $explosionSize - 1);
     $maxZ = Math::ceilFloat($this->source->z + $explosionSize + 1);
     $explosionBB = new AxisAlignedBB($minX, $minY, $minZ, $maxX, $maxY, $maxZ);
     $list = $this->level->getNearbyEntities($explosionBB, $this->what instanceof Entity ? $this->what : \null);
     foreach ($list as $entity) {
         $distance = $entity->distance($this->source) / $explosionSize;
         if ($distance <= 1) {
             $motion = $entity->subtract($this->source)->normalize();
             $impact = (1 - $distance) * ($exposure = 1);
             $damage = (int) (($impact * $impact + $impact) / 2 * 8 * $explosionSize + 1);
             if ($this->what instanceof Entity) {
                 $ev = new EntityDamageByEntityEvent($this->what, $entity, EntityDamageEvent::CAUSE_ENTITY_EXPLOSION, $damage);
             } elseif ($this->what instanceof Block) {
                 $ev = new EntityDamageByBlockEvent($this->what, $entity, EntityDamageEvent::CAUSE_BLOCK_EXPLOSION, $damage);
             } else {
                 $ev = new EntityDamageEvent($entity, EntityDamageEvent::CAUSE_BLOCK_EXPLOSION, $damage);
             }
             $entity->attack($ev->getFinalDamage(), $ev);
             $entity->setMotion($motion->multiply($impact));
         }
     }
     $air = Item::get(Item::AIR);
     foreach ($this->affectedBlocks as $block) {
         if ($block->getId() === Block::TNT) {
             $mot = (new Random())->nextSignedFloat() * M_PI * 2;
             $tnt = Entity::createEntity("PrimedTNT", $this->level->getChunk($block->x >> 4, $block->z >> 4), new Compound("", ["Pos" => new Enum("Pos", [new Double("", $block->x + 0.5), new Double("", $block->y), new Double("", $block->z + 0.5)]), "Motion" => new Enum("Motion", [new Double("", -\sin($mot) * 0.02), new Double("", 0.2), new Double("", -\cos($mot) * 0.02)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)]), "Fuse" => new Byte("Fuse", \mt_rand(10, 30))]));
             $tnt->spawnToAll();
         } elseif (\mt_rand(0, 100) < $yield) {
             foreach ($block->getDrops($air) as $drop) {
                 $this->level->dropItem($block->add(0.5, 0.5, 0.5), Item::get(...$drop));
             }
         }
         $this->level->setBlockIdAt($block->x, $block->y, $block->z, 0);
         $pos = new Vector3($block->x, $block->y, $block->z);
         for ($side = 0; $side < 5; $side++) {
             $sideBlock = $pos->getSide($side);
             if (!isset($this->affectedBlocks[$index = ($sideBlock->x & 0xfffffff) << 35 | ($sideBlock->y & 0x7f) << 28 | $sideBlock->z & 0xfffffff]) and !isset($updateBlocks[$index])) {
                 $this->level->getServer()->getPluginManager()->callEvent($ev = new BlockUpdateEvent($this->level->getBlock($sideBlock)));
                 if (!$ev->isCancelled()) {
                     $ev->getBlock()->onUpdate(Level::BLOCK_UPDATE_NORMAL);
                 }
                 $updateBlocks[$index] = \true;
             }
         }
         $send[] = new Vector3($block->x - $source->x, $block->y - $source->y, $block->z - $source->z);
     }
     $pk = new ExplodePacket();
     $pk->x = $this->source->x;
     $pk->y = $this->source->y;
     $pk->z = $this->source->z;
     $pk->radius = $this->size;
     $pk->records = $send;
     $this->level->addChunkPacket($source->x >> 4, $source->z >> 4, $pk);
     return \true;
 }
开发者ID:ken77731,项目名称:PocketMine-0.13.0,代码行数:75,代码来源:Explosion__64bit.php

示例10: onBlockUpdate

 /**
  * @param BlockUpdateEvent $event
  */
 public function onBlockUpdate(BlockUpdateEvent $event)
 {
     if ($this->getPlugin()->isBlockSpecified($event->getBlock())) {
         $event->setCancelled(true);
     }
 }
开发者ID:Artide,项目名称:PocketMine-Plugins,代码行数:9,代码来源:BlockFreezerListener.php

示例11: onBlockUpdate

 public function onBlockUpdate(BlockUpdateEvent $event)
 {
     if ($this->isBlockLiquid($event->getBlock())) {
         $event->setCancelled(true);
     }
 }
开发者ID:pid011,项目名称:PMMP-Plugins,代码行数:6,代码来源:StopBlock.php

示例12: onAir

 public function onAir(BlockUpdateEvent $event)
 {
     $block = $event->getBlock();
     if (isset($this->breakQueue["{$block->x}:{$block->y}:{$block->z}"])) {
         if ($block->getId() == Block::AIR) {
             $event->getBlock()->getLevel()->setBlock($block, $this->breakQueue["{$block->x}:{$block->y}:{$block->z}"], false, true);
             unset($this->breakQueue["{$block->x}:{$block->y}:{$block->z}"]);
         }
     }
 }
开发者ID:EmreTr1,项目名称:rtr,代码行数:10,代码来源:InfiniteBlock.php

示例13: onBlockUpdate

 /**
  * @param BlockUpdateEvent $event
  * @priority HIGHEST
  * @ignoreCancelled true
  */
 public function onBlockUpdate(BlockUpdateEvent $event)
 {
     if ($this->plugin->isFreezable($event->getBlock())) {
         $event->setCancelled(true);
     }
 }
开发者ID:NameNoOne100,项目名称:PocketMine-Plugins,代码行数:11,代码来源:BlockFreezerListener.php

示例14: onBlockUpdate

 public function onBlockUpdate(BlockUpdateEvent $event)
 {
     $b = $event->getBlock();
     if (in_array($b->getID(), [8, 9, 10, 11])) {
         $event->setCancelled();
     }
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:7,代码来源:MineFarm.php


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