

scoreboard objectives add Detected dummy
scoreboard players reset @s Detected
execute positioned ~-1.5 ~ ~-1.5 if entity @a[dx=2,dy=2,dz=2] run scoreboard players set @s Detected 1

#execute positioned ~-1 ~ ~-1 run setblock ~ ~ ~ glass