Question: Closest building block to an entity (like npc, animal,player)

Closest building block to an entity (like npc, animal,player) or Building block what is in the sight of the entity.
I'm looking for solution to have the ID/entity of the closest building block (or all blocks around within range is also fine) entity, or get all building block in the way of the Original Source (like npc, animal,player)  aim/sight.

Anybody has an already existing solution for this or any good interface/function suggestion?
I tried with some implementation from Human NPC plugin regarding the already existing NPC edit possibilite as viewed target, but not much lock to get the desired object, if the original source is not me, as a real player but an animal for examle.