mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 16:49:53 +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 = [];
|
$blocks = [];
|
||||||
|
$nextIndex = 0;
|
||||||
|
|
||||||
$itr = new BlockIterator($this->level, $this->getPosition(), $this->getDirectionVector(), $this->getEyeHeight(), $maxDistance);
|
$itr = new BlockIterator($this->level, $this->getPosition(), $this->getDirectionVector(), $this->getEyeHeight(), $maxDistance);
|
||||||
|
|
||||||
while($itr->valid()){
|
while($itr->valid()){
|
||||||
$itr->next();
|
$itr->next();
|
||||||
$block = $itr->current();
|
$block = $itr->current();
|
||||||
$blocks[] = $block;
|
$blocks[$nextIndex++] = $block;
|
||||||
|
|
||||||
if($maxLength !== 0 and count($blocks) > $maxLength){
|
if($maxLength !== 0 and count($blocks) > $maxLength){
|
||||||
array_shift($blocks);
|
array_shift($blocks);
|
||||||
|
--$nextIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $block->getID();
|
$id = $block->getID();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user