From 3b9a9bcd5daff567481a1c368b5230ca99a1596f Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Thu, 6 Nov 2014 12:23:45 +0100 Subject: [PATCH] Use proper indexes on Living->getLineOfSight() when a max length is set --- src/pocketmine/entity/Living.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/entity/Living.php b/src/pocketmine/entity/Living.php index bc8af8bac..e89d3dd05 100644 --- a/src/pocketmine/entity/Living.php +++ b/src/pocketmine/entity/Living.php @@ -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();