public function getLineOfSight($maxDistance, $maxLength = 0, array $transparent = [])
{
if ($maxDistance > 120) {
$maxDistance = 120;
}
if (count($transparent) === 0) {
$transparent = null;
}
$blocks = [];
$nextIndex = 0;
$itr = new BlockIterator($this->level, $this->getPosition(), $this->getDirectionVector(), $this->getEyeHeight(), $maxDistance);
while ($itr->valid()) {
$itr->next();
$block = $itr->current();
$blocks[$nextIndex++] = $block;
if ($maxLength !== 0 and count($blocks) > $maxLength) {
array_shift($blocks);
--$nextIndex;
}
$id = $block->getId();
if ($transparent === null) {
if ($id !== 0) {
break;
}
} else {
if (!isset($transparent[$id])) {
break;
}
}
}
return $blocks;
}