本文整理汇总了PHP中Position::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Position::add方法的具体用法?PHP Position::add怎么用?PHP Position::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Position
的用法示例。
在下文中一共展示了Position::add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: W_sphere
private function W_sphere(Position $pos, $blocks, $radiusX, $radiusY, $radiusZ, $filled = true, &$output = null)
{
$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->level->setBlockRaw($pos->add($x, $y, $z), $blocks[mt_rand(0, $bcnt)]->getBlock(), false);
$count += (int) $pos->level->setBlockRaw($pos->add(-$x, $y, $z), $blocks[mt_rand(0, $bcnt)]->getBlock(), false);
$count += (int) $pos->level->setBlockRaw($pos->add($x, -$y, $z), $blocks[mt_rand(0, $bcnt)]->getBlock(), false);
$count += (int) $pos->level->setBlockRaw($pos->add($x, $y, -$z), $blocks[mt_rand(0, $bcnt)]->getBlock(), false);
$count += (int) $pos->level->setBlockRaw($pos->add(-$x, -$y, $z), $blocks[mt_rand(0, $bcnt)]->getBlock(), false);
$count += (int) $pos->level->setBlockRaw($pos->add($x, -$y, -$z), $blocks[mt_rand(0, $bcnt)]->getBlock(), false);
$count += (int) $pos->level->setBlockRaw($pos->add(-$x, $y, -$z), $blocks[mt_rand(0, $bcnt)]->getBlock(), false);
$count += (int) $pos->level->setBlockRaw($pos->add(-$x, -$y, -$z), $blocks[mt_rand(0, $bcnt)]->getBlock(), false);
}
}
}
$output .= "{$count} block(s) have been changed.\n";
return true;
}
示例2: create
public function create()
{
$obj = new Position($this->db);
echo json_encode($obj->add($this->f3->get("POST.postdata")));
}