I want to execute a command to an armor stand if the nearest pig has a specific tag.
The commands that I have tried so far...
execute as @e[type=armor_stand] at @s if entity @e[type=pig,limit=1,sort=nearest,tag=carrot] run <command>
does not work because it checks if "carrot"-pig exists.
Having a pig with no tag "carrot" between the armor stand and the "carrot"-pig will just result to test passed.
execute as @e[type=armor_stand] at @s as @e[type=pig,limit=1,sort=nearest] if entity @s[tag=carrot] run <command>
might have worked but it changed the selector.