本文整理汇总了PHP中pocketmine\math\Vector3::getSide方法的典型用法代码示例。如果您正苦于以下问题:PHP Vector3::getSide方法的具体用法?PHP Vector3::getSide怎么用?PHP Vector3::getSide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\math\Vector3
的用法示例。
在下文中一共展示了Vector3::getSide方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSafeSpawn
/**
* @param Vector3 $spawn default null
*
* @return bool|Position
*/
public function getSafeSpawn($spawn = null)
{
if (!$spawn instanceof Vector3) {
$spawn = $this->getSpawn();
}
if ($spawn instanceof Vector3) {
$x = (int) round($spawn->x);
$y = (int) round($spawn->y);
$z = (int) round($spawn->z);
for (; $y > 0; --$y) {
$v = new Vector3($x, $y, $z);
$b = $this->getBlock($v->getSide(0));
if ($b === false) {
return $spawn;
} elseif (!$b instanceof Air) {
break;
}
}
for (; $y < 128; ++$y) {
$v = new Vector3($x, $y, $z);
if ($this->getBlock($v->getSide(1)) instanceof Air) {
if ($this->getBlock($v) instanceof Air) {
return new Position($x, $y, $z, $this);
}
} else {
++$y;
}
}
return new Position($x, $y, $z, $this);
}
return false;
}
示例2: getSide
/**
* Returns a side Vector
*
* @param int $side
* @param int $step
*
* @return Position
*
* @throws LevelException
*/
public function getSide($side, $step = 1)
{
if (!$this->isValid()) {
throw new LevelException("Undefined Level reference");
}
return Position::fromObject(parent::getSide($side, $step), $this->level);
}
示例3: getSide
/**
* Returns the Block on the side $side, works like Vector3::side()
*
* @param int $side
* @param int $step
*
* @return Block
*/
public function getSide($side, $step = 1)
{
if ($this->isValid()) {
return $this->getLevel()->getBlock(Vector3::getSide($side, $step));
}
return Block::get(Item::AIR, 0, Position::fromObject(Vector3::getSide($side, $step)));
}
示例4: 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;
}
示例5: getSide
/**
* Returns a side Vector
*
* @param int $side
* @param int $step
*
* @return Position
*
* @throws LevelException
*/
public function getSide($side, $step = 1)
{
assert($this->isValid());
return Position::fromObject(parent::getSide($side, $step), $this->level);
}
示例6: getSide
/**
* Returns the Block on the side $side, works like Vector3::side()
*
* @param int $side
* @param int $step
*
* @return Block
*/
public function getSide($side, $step = 1)
{
if ($this->isValid()) {
return $this->getLevel()->getBlock(Vector3::getSide($side, $step));
}
return Block::get(Item::AIR, 0, new Position($v->x, $v->y, $v->z, null));
}