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


PHP Position::setComponents方法代码示例

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


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

示例1: onDeath

 /**
  * @priority high
  */
 public function onDeath(PlayerRespawnEvent $event)
 {
     $level = $event->getPlayer()->getLevel();
     $pillarPos = new Position($event->getPlayer()->x, $event->getPlayer()->y, $event->getPlayer()->z, $level);
     for ($h = 1; $h <= 30; $h++) {
         $pillarPos->setComponents($pillarPos->x, ++$pillarPos->y, $pillarPos->z);
         $level->addParticle(new RedstoneParticle($pillarPos, 10));
     }
     $pillarPos->setComponents($pillarPos->x, $pillarPos->y - 10, $pillarPos->z);
     $headPos = new Position($pillarPos->x, $pillarPos->y, $pillarPos->z, $level);
     for ($r = -5; $r <= 5; $r++) {
         $headPos->setComponents($pillarPos->x + $r, $pillarPos->y, $pillarPos->z);
         $level->addParticle(new ExplodeParticle($headPos));
         $p = new RedstoneParticle($headPos, 10);
         $level->addParticle($p);
     }
 }
开发者ID:nesgohood,项目名称:PMMP-Plugins,代码行数:20,代码来源:deadMarker.php

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

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

示例4: heatwave

 public function heatwave(Player $player)
 {
     $pos = new Position($player->x, $player->y, $player->z, $player->getLevel());
     for ($x = -15; $x <= 15; $x++) {
         for ($z = -15; $z <= 15; $z++) {
             $dx = $player->x + $x;
             $dz = $player->z + $z;
             $dy = $player->getLevel()->getHighestBlockAt($dx, $dz);
             $this->destructSnowLayer($pos->setComponents($dx, $dy, $dz));
         }
     }
 }
开发者ID:JiangsNetworkAlpha,项目名称:Helpin-8D,代码行数:12,代码来源:snow.php

示例5: fire

 public function fire()
 {
     foreach ($this->getServer()->getLevels() as $level) {
         if (!$level instanceof Level) {
             continue;
         }
         if (!isset($this->db["Sparklers"][$level->getFolderName()])) {
             continue;
         }
         foreach ($this->db["Sparklers"][$level->getFolderName()] as $keyPos => $keyValue) {
             $explode = explode(".", $keyPos);
             if (!isset($explode[2])) {
                 break;
             }
             // WRONG DATA
             $pillarPos = new Position($explode[0], $explode[1], $explode[2], $level);
             $players = [];
             foreach ($this->getServer()->getOnlinePlayers() as $player) {
                 if ($pillarPos->distance($player) < 25) {
                     $players[] = $player;
                 }
             }
             if (count($players) == 0) {
                 continue;
             }
             $level->addSound(new PopSound($pillarPos), $players);
             for ($h = 1; $h <= 11; $h++) {
                 $pillarPos->setComponents($pillarPos->x, ++$pillarPos->y, $pillarPos->z);
                 $level->addParticle(new DustParticle($pillarPos, 255, 255, 255, 255), $players);
             }
             $headPos = new Position($pillarPos->x, $pillarPos->y - 10, $pillarPos->z, $level);
             $r = mt_rand(0, 255);
             $g = mt_rand(0, 255);
             $b = mt_rand(0, 255);
             for ($r = 1; $r <= 5; $r++) {
                 $headPos->setComponents($pillarPos->x + mt_rand(-3, 3), $pillarPos->y + mt_rand(-3, 3), $pillarPos->z + mt_rand(-3, 3));
                 $level->addParticle(new DustParticle($headPos, $r, $g, $b, 255), $players);
                 // WHITE
             }
             $r = mt_rand(0, 255);
             $g = mt_rand(0, 255);
             $b = mt_rand(0, 255);
             for ($r = 1; $r <= 5; $r++) {
                 $headPos->setComponents($pillarPos->x + mt_rand(-3, 3), $pillarPos->y + mt_rand(-3, 3), $pillarPos->z + mt_rand(-3, 3));
                 $level->addParticle(new DustParticle($headPos, $r, $g, $b, 255), $players);
                 // GREEN
             }
             $r = mt_rand(0, 255);
             $g = mt_rand(0, 255);
             $b = mt_rand(0, 255);
             for ($r = 1; $r <= 5; $r++) {
                 $headPos->setComponents($pillarPos->x + mt_rand(-3, 3), $pillarPos->y + mt_rand(-3, 3), $pillarPos->z + mt_rand(-3, 3));
                 $level->addParticle(new DustParticle($headPos, $r, $g, $b, 255), $players);
                 // PINK
             }
             $r = mt_rand(0, 255);
             $g = mt_rand(0, 255);
             $b = mt_rand(0, 255);
             for ($r = 1; $r <= 5; $r++) {
                 $headPos->setComponents($pillarPos->x + mt_rand(-3, 3), $pillarPos->y + mt_rand(-3, 3), $pillarPos->z + mt_rand(-3, 3));
                 $level->addParticle(new DustParticle($headPos, $r, $g, $b, 255), $players);
                 // ORANGE
             }
             $r = mt_rand(0, 255);
             $g = mt_rand(0, 255);
             $b = mt_rand(0, 255);
             for ($r = 1; $r <= 5; $r++) {
                 $headPos->setComponents($pillarPos->x + mt_rand(-3, 3), $pillarPos->y + mt_rand(-3, 3), $pillarPos->z + mt_rand(-3, 3));
                 $level->addParticle(new DustParticle($headPos, $r, $g, $b, 255), $players);
                 // BLUE
             }
         }
     }
 }
开发者ID:nesgohood,项目名称:PMMP-Plugins,代码行数:74,代码来源:Sparklers.php


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