Use proper indexes on Living->getLineOfSight() when a max length is set

This commit is contained in:
Shoghi Cervantes 2014-11-06 12:23:45 +01:00
parent 263bff01c8
commit 3b9a9bcd5d

View File

@ -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();