Raycasting 1.6.4 [Bedrock Edition] [Most efficient] [Very accurate] Looping:
# Summons raycast entity when an entity holds the correct item, dirt named 'raycast pp 69 420'
execute if entity @e run execute as @e run execute at @e run execute if entity @s[distance=..1] run execute if entity @s[nbt={SelectedItem:{id:"minecraft:dirt",count:42b,tag:{display:{Name:'{"text":"raycast pp 69 420"}'}}} run summon armor_stand ~ ~ ~ {CustomName:'{"text":"Raycast"}',Invisible:1b,NoGravity:1b}
Raycast:
# Detects if there's a block here and kills itself if there's not
execute if entity @e run execute as @e run execute at @e run execute if entity @s[distance=..1] run execute if entity @s[type=armor_stand] run execute if entity @s[name=Raycast] run execute if block ~ ~ ~ minecraft:air run kill @s