Hope you are all doing well, i trying to figure out how i can test if an entity can see a player in it's view atm i am using code below;
execute as @e[type=minecraft:villager,tag=Path,tag=Villager10] at @s anchored eyes facing entity @e[sort=nearest,limit=1,type=player] eyes anchored feet positioned ^ ^ ^1 rotated as @s positioned ^ ^ ^-1 if entity @s[distance=..0.1] run say Success
This code runs along side a villager with the tags path and Villager10. (side not i have removed AI for the villager so it wont move around)
This code works however it doesn't take into consideration if there are blocks in the way.
Dose anyone know if i am using the right method to do such a thing and if so how. Fairly new to commands like so.
Many Thanks. Dave