本文整理匯總了PHP中pocketmine\entity\Entity::getDirectionVector方法的典型用法代碼示例。如果您正苦於以下問題:PHP Entity::getDirectionVector方法的具體用法?PHP Entity::getDirectionVector怎麽用?PHP Entity::getDirectionVector使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pocketmine\entity\Entity
的用法示例。
在下文中一共展示了Entity::getDirectionVector方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getCrosshairTarget
public static function getCrosshairTarget(Entity $entity, $accuracy = 0.5, $max = PHP_INT_MAX)
{
$found = null;
$direction = $entity->getDirectionVector()->multiply($accuracy);
/** @var Vector3 $last */
for ($last = null, $pos = $entity->add($direction), $i = 1; $i * $accuracy <= $max; $last = $pos->floor(), $pos = $entity->add($direction->multiply(++$i))) {
if ($last instanceof Vector3) {
if ($last->x === $pos->getFloorX() and $last->y === $pos->getFloorY() and $last->z === $pos->getFloorZ()) {
continue;
}
if ($pos->y < 0) {
break;
}
$maxY = 127;
if (defined($path = "pemapmodder\\worldeditart\\MAX_WORLD_HEIGHT")) {
$maxY = constant($path);
}
if ($pos->y > $maxY + 1) {
break;
}
$block = $entity->getLevel()->getBlock($pos);
if (!$block instanceof Block) {
break;
}
if ($block instanceof Air) {
continue;
}
$found = $block;
break;
}
}
return $found;
}