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


PHP Math::ceilFloat方法代码示例

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


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

示例1: getBlocksAround

 public function getBlocksAround()
 {
     if ($this->blocksAround === null) {
         $minX = Math::floorFloat($this->boundingBox->minX);
         $minY = Math::floorFloat($this->boundingBox->minY);
         $minZ = Math::floorFloat($this->boundingBox->minZ);
         $maxX = Math::ceilFloat($this->boundingBox->maxX);
         $maxY = Math::ceilFloat($this->boundingBox->maxY);
         $maxZ = Math::ceilFloat($this->boundingBox->maxZ);
         $this->blocksAround = [];
         for ($z = $minZ; $z <= $maxZ; ++$z) {
             for ($x = $minX; $x <= $maxX; ++$x) {
                 for ($y = $minY; $y <= $maxY; ++$y) {
                     $block = $this->level->getBlock($this->temporalVector->setComponents($x, $y, $z));
                     if ($block->hasEntityCollision()) {
                         $this->blocksAround[] = $block;
                     }
                 }
             }
         }
     }
     return $this->blocksAround;
 }
开发者ID:NewDelion,项目名称:PocketMine-0.13.x,代码行数:23,代码来源:Entity.php

示例2: getNearbyEntities

 /**
  * Returns the entities near the current one inside the AxisAlignedBB
  *
  * @param AxisAlignedBB $bb
  * @param Entity        $entity
  *
  * @return Entity[]
  */
 public function getNearbyEntities(AxisAlignedBB $bb, Entity $entity = null)
 {
     $nearby = [];
     $minX = Math::floorFloat(($bb->minX - 2) / 16);
     $maxX = Math::ceilFloat(($bb->maxX + 2) / 16);
     $minZ = Math::floorFloat(($bb->minZ - 2) / 16);
     $maxZ = Math::ceilFloat(($bb->maxZ + 2) / 16);
     for ($x = $minX; $x <= $maxX; ++$x) {
         for ($z = $minZ; $z <= $maxZ; ++$z) {
             foreach ($this->getChunkEntities($x, $z) as $ent) {
                 if ($ent !== $entity and $ent->boundingBox->intersectsWith($bb)) {
                     $nearby[] = $ent;
                 }
             }
         }
     }
     return $nearby;
 }
开发者ID:robozeri,项目名称:Yuriko-MP,代码行数:26,代码来源:Level.php

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

示例4: checkBlockCollision

 protected function checkBlockCollision()
 {
     $minX = Math::floorFloat($this->boundingBox->minX + 0.001);
     $minY = Math::floorFloat($this->boundingBox->minY + 0.001);
     $minZ = Math::floorFloat($this->boundingBox->minZ + 0.001);
     $maxX = Math::ceilFloat($this->boundingBox->maxX - 0.001);
     $maxY = Math::ceilFloat($this->boundingBox->maxY - 0.001);
     $maxZ = Math::ceilFloat($this->boundingBox->maxZ - 0.001);
     $vector = new Vector3(0, 0, 0);
     $v = new Vector3(0, 0, 0);
     for ($v->z = $minZ; $v->z <= $maxZ; ++$v->z) {
         for ($v->x = $minX; $v->x <= $maxX; ++$v->x) {
             for ($v->y = $minY; $v->y <= $maxY; ++$v->y) {
                 $block = $this->level->getBlock($v);
                 if ($block->hasEntityCollision()) {
                     $block->onEntityCollide($this);
                     if (!$this instanceof Player) {
                         $block->addVelocityToEntity($this, $vector);
                     }
                 }
             }
         }
     }
     if (!$this instanceof Player and $vector->length() > 0) {
         $vector = $vector->normalize();
         $d = 0.014;
         $this->motionX += $vector->x * $d;
         $this->motionY += $vector->y * $d;
         $this->motionZ += $vector->z * $d;
     }
 }
开发者ID:TylerGames,项目名称:PocketMine-MP,代码行数:31,代码来源:Entity.php

示例5: getNearestRail

 /**
  * @return Rail
  */
 public function getNearestRail()
 {
     $minX = Math::floorFloat($this->boundingBox->minX);
     $minY = Math::floorFloat($this->boundingBox->minY);
     $minZ = Math::floorFloat($this->boundingBox->minZ);
     $maxX = Math::ceilFloat($this->boundingBox->maxX);
     $maxY = Math::ceilFloat($this->boundingBox->maxY);
     $maxZ = Math::ceilFloat($this->boundingBox->maxZ);
     $rails = [];
     for ($z = $minZ; $z <= $maxZ; ++$z) {
         for ($x = $minX; $x <= $maxX; ++$x) {
             for ($y = $minY; $y <= $maxY; ++$y) {
                 $block = $this->level->getBlock($this->temporalVector->setComponents($x, $y, $z));
                 if (in_array($block->getId(), [Block::RAIL, Block::ACTIVATOR_RAIL, Block::DETECTOR_RAIL, Block::POWERED_RAIL])) {
                     $rails[] = $block;
                 }
             }
         }
     }
     $minDistance = PHP_INT_MAX;
     $nearestRail = null;
     foreach ($rails as $rail) {
         $dis = $this->distance($rail);
         if ($dis < $minDistance) {
             $nearestRail = $rail;
             $minDistance = $dis;
         }
     }
     return $nearestRail;
 }
开发者ID:yungtechboy1,项目名称:Genisys,代码行数:33,代码来源:Minecart.php

示例6: checkBlockCollision

 protected function checkBlockCollision()
 {
     $minX = Math::ceilFloat($this->boundingBox->minX);
     $minY = Math::ceilFloat($this->boundingBox->minY);
     $minZ = Math::ceilFloat($this->boundingBox->minZ);
     $maxX = Math::floorFloat($this->boundingBox->maxX);
     $maxY = Math::floorFloat($this->boundingBox->maxY);
     $maxZ = Math::floorFloat($this->boundingBox->maxZ);
     $blocksInside = [];
     for ($z = $minZ; $z <= $maxZ; ++$z) {
         for ($x = $minX; $x <= $maxX; ++$x) {
             for ($y = $minY; $y <= $maxY; ++$y) {
                 $block = $this->level->getBlock($this->temporalVector->setComponents($x, $y, $z));
                 if ($block->hasEntityCollision()) {
                     $blocksInside[Level::blockHash($block->x, $block->y, $block->z)] = $block;
                 }
             }
         }
     }
     foreach ($blocksInside as $block) {
         $block->onEntityCollide($this);
     }
 }
开发者ID:robske110,项目名称:ClearSky,代码行数:23,代码来源:Player.php

示例7: getCollisionCubes

 /**
  * @param AxisAlignedBB $bb
  *
  * @return Block[]|Entity[]
  */
 public function getCollisionCubes(AxisAlignedBB $bb)
 {
     $minX = Math::floorFloat($bb->minX);
     $minY = Math::floorFloat($bb->minY);
     $minZ = Math::floorFloat($bb->minZ);
     $maxX = Math::ceilFloat($bb->maxX);
     $maxY = Math::ceilFloat($bb->maxY);
     $maxZ = Math::ceilFloat($bb->maxZ);
     $collides = [];
     $v = new Vector3();
     for ($v->z = $minZ; $v->z <= $maxZ; ++$v->z) {
         for ($v->x = $minX; $v->x <= $maxX; ++$v->x) {
             for ($v->y = $minY - 1; $v->y <= $maxY; ++$v->y) {
                 $block = $this->level->getBlock($v);
                 if ($block->getBoundingBox() !== null) {
                     $collides[] = $block;
                 }
             }
         }
     }
     return $collides;
 }
开发者ID:Cybertechpp,项目名称:EntityManager,代码行数:27,代码来源:BaseEntity.php


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