This commit is contained in:
Shoghi Cervantes 2014-12-12 12:05:15 +01:00
parent 312e064b07
commit 2752393c42

View File

@ -252,10 +252,14 @@ abstract class Living extends Entity implements Damageable{
* @return Block * @return Block
*/ */
public function getTargetBlock($maxDistance, array $transparent = []){ public function getTargetBlock($maxDistance, array $transparent = []){
$block = array_shift($this->getLineOfSight($maxDistance, 1, $transparent)); try{
$block = $this->getLineOfSight($maxDistance, 1, $transparent)[0];
if($block instanceof Block){ if($block instanceof Block){
return $block; return $block;
} }
}catch (\ArrayOutOfBoundsException $e){
}
return null; return null;
} }