mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Fixed #2392
This commit is contained in:
parent
312e064b07
commit
2752393c42
@ -252,9 +252,13 @@ abstract class Living extends Entity implements Damageable{
|
||||
* @return Block
|
||||
*/
|
||||
public function getTargetBlock($maxDistance, array $transparent = []){
|
||||
$block = array_shift($this->getLineOfSight($maxDistance, 1, $transparent));
|
||||
if($block instanceof Block){
|
||||
return $block;
|
||||
try{
|
||||
$block = $this->getLineOfSight($maxDistance, 1, $transparent)[0];
|
||||
if($block instanceof Block){
|
||||
return $block;
|
||||
}
|
||||
}catch (\ArrayOutOfBoundsException $e){
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user