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


PHP Position::add方法代码示例

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


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

示例1: operate

 public function operate(Position $anchor)
 {
     if (is_int($this->delta)) {
         throw new \BadMethodCallException("MacroOperation is of type TRUE (wait) not FALSE (operate) thus cannot be operated");
     }
     $anchor->getLevel()->setBlock($anchor->add($this->delta), $this->block, false, true);
     // update
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:8,代码来源:MacroOperation.php

示例2: createFromPos_Rot

 public static function createFromPos_Rot(Position $pos, $yaw, $pitch)
 {
     $y = -sin(deg2rad($pitch));
     $xz = cos(deg2rad($pitch));
     $x = -$xz * sin(deg2rad($yaw));
     $z = $xz * cos(deg2rad($yaw));
     // CREDIT partially copied from PocketMine Entity.php source because I am too lazy to do those trigo :P
     $newPos = $pos->add($x, $y, $z);
     return new CuboidSpace($pos, $newPos);
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:10,代码来源:CuboidSpace.php

示例3: W_sphere

 private function W_sphere(Position $pos, $blocks, $radiusX, $radiusY, $radiusZ, $filled = true)
 {
     $count = 0;
     $radiusX += 0.5;
     $radiusY += 0.5;
     $radiusZ += 0.5;
     $invRadiusX = 1 / $radiusX;
     $invRadiusY = 1 / $radiusY;
     $invRadiusZ = 1 / $radiusZ;
     $ceilRadiusX = (int) ceil($radiusX);
     $ceilRadiusY = (int) ceil($radiusY);
     $ceilRadiusZ = (int) ceil($radiusZ);
     $bcnt = count($blocks) - 1;
     $nextXn = 0;
     $breakX = false;
     for ($x = 0; $x <= $ceilRadiusX and $breakX === false; ++$x) {
         $xn = $nextXn;
         $nextXn = ($x + 1) * $invRadiusX;
         $nextYn = 0;
         $breakY = false;
         for ($y = 0; $y <= $ceilRadiusY and $breakY === false; ++$y) {
             $yn = $nextYn;
             $nextYn = ($y + 1) * $invRadiusY;
             $nextZn = 0;
             $breakZ = false;
             for ($z = 0; $z <= $ceilRadiusZ; ++$z) {
                 $zn = $nextZn;
                 $nextZn = ($z + 1) * $invRadiusZ;
                 $distanceSq = WorldEditor::lengthSq($xn, $yn, $zn);
                 if ($distanceSq > 1) {
                     if ($z === 0) {
                         if ($y === 0) {
                             $breakX = true;
                             $breakY = true;
                             break;
                         }
                         $breakY = true;
                         break;
                     }
                     break;
                 }
                 if ($filled === false) {
                     if (WorldEditor::lengthSq($nextXn, $yn, $zn) <= 1 and WorldEditor::lengthSq($xn, $nextYn, $zn) <= 1 and WorldEditor::lengthSq($xn, $yn, $nextZn) <= 1) {
                         continue;
                     }
                 }
                 $count += (int) $pos->getLevel()->setBlock($pos->add($x, $y, $z), $blocks[mt_rand(0, $bcnt)]->getBlock(), false);
                 $count += (int) $pos->getLevel()->setBlock($pos->add(-$x, $y, $z), $blocks[mt_rand(0, $bcnt)]->getBlock(), false);
                 $count += (int) $pos->getLevel()->setBlock($pos->add($x, -$y, $z), $blocks[mt_rand(0, $bcnt)]->getBlock(), false);
                 $count += (int) $pos->getLevel()->setBlock($pos->add($x, $y, -$z), $blocks[mt_rand(0, $bcnt)]->getBlock(), false);
                 $count += (int) $pos->getLevel()->setBlock($pos->add(-$x, -$y, $z), $blocks[mt_rand(0, $bcnt)]->getBlock(), false);
                 $count += (int) $pos->getLevel()->setBlock($pos->add($x, -$y, -$z), $blocks[mt_rand(0, $bcnt)]->getBlock(), false);
                 $count += (int) $pos->getLevel()->setBlock($pos->add(-$x, $y, -$z), $blocks[mt_rand(0, $bcnt)]->getBlock(), false);
                 $count += (int) $pos->getLevel()->setBlock($pos->add(-$x, -$y, -$z), $blocks[mt_rand(0, $bcnt)]->getBlock(), false);
             }
         }
     }
     return $count . " block(s) have been changed.";
 }
开发者ID:applqpak,项目名称:plugin-remakes,代码行数:59,代码来源:WorldEditor.php

示例4: removeBlockWithRange

 public function removeBlockWithRange(Position $pos)
 {
     $halfRange = (self::RANGE - 1) / 2;
     for ($x = 0; $x <= self::RANGE; $x++) {
         for ($z = 0; $z <= self::RANGE; $z++) {
             $this->removeBlockWithAnim($pos->add($halfRange - $x, 0, $halfRange - $z));
         }
     }
 }
开发者ID:HelloWorld017,项目名称:SkyFall,代码行数:9,代码来源:WorldManager.php

示例5: __construct

 public function __construct(Position $pos, $fromData, $toData)
 {
     $this->pos = $pos;
     $this->packets = [$this->getTextPacket($pos->add(0.5, 1.25, 0.5), TextFormat::GOLD . $fromData["name"] . "\n" . ExchangeItem::getTranslation("TO") . "\n" . TextFormat::AQUA . $toData["name"])];
     $this->spawnToAll();
 }
开发者ID:HelloWorld017,项目名称:xChange,代码行数:6,代码来源:EntityItemCase.php


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