pocketmine\entity\Living::getTargetBlock PHP Method

getTargetBlock() public method

public getTargetBlock ( integer $maxDistance, array $transparent = [] ) : Block
$maxDistance integer
$transparent array
return pocketmine\block\Block
    public function getTargetBlock($maxDistance, array $transparent = [])
    {
        try {
            $block = $this->getLineOfSight($maxDistance, 1, $transparent)[0];
            if ($block instanceof Block) {
                return $block;
            }
        } catch (\ArrayOutOfBoundsException $e) {
        }
        return null;
    }