mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Use proper indexes on Living->getLineOfSight() when a max length is set
This commit is contained in:
parent
263bff01c8
commit
3b9a9bcd5d
@ -197,15 +197,18 @@ abstract class Living extends Entity implements Damageable{
|
||||
}
|
||||
|
||||
$blocks = [];
|
||||
$nextIndex = 0;
|
||||
|
||||
$itr = new BlockIterator($this->level, $this->getPosition(), $this->getDirectionVector(), $this->getEyeHeight(), $maxDistance);
|
||||
|
||||
while($itr->valid()){
|
||||
$itr->next();
|
||||
$block = $itr->current();
|
||||
$blocks[] = $block;
|
||||
$blocks[$nextIndex++] = $block;
|
||||
|
||||
if($maxLength !== 0 and count($blocks) > $maxLength){
|
||||
array_shift($blocks);
|
||||
--$nextIndex;
|
||||
}
|
||||
|
||||
$id = $block->getID();
|
||||
|
Loading…
x
Reference in New Issue
Block a user