tag @e[r=6,family=mob] add PlayerGardenerTarget
tag @e[r=6,family=goat] add PlayerGardenerTarget
tag @e[r=6,family=fish] add PlayerGardenerTarget
tag @e[r=6,family=panda] add PlayerGardenerTarget
tag @e[r=6,family=piglin] add PlayerGardenerTarget
tag @e[r=6,family=monster] add PlayerGardenerTarget
tag @e[r=6,family=ender] add PlayerGardenerTarget
tag @s remove PlayerGardenerTarget
## tags any mob near projectile

execute at @s if entity @e[r=6,tag=PlayerGardenerTarget] run tag @s add PlayerGardenerReady
execute at @s unless entity @p[r=12] run tag @s add PlayerGardenerReady
execute at @s unless block ~ ~ ~ air run tag @s add PlayerGardenerReady
## tags itself if it finds a mob, enters a block, or leaves player range

execute as @s[tag=PlayerGardenerReady] run function endermen/ender_gardener/attack
tag @e remove PlayerGardenerTarget
tp @s[tag=PlayerGardenerReady] ~ ~-3 ~
event entity @s[tag=PlayerGardenerReady] despawn
## runs attack function on mob and despawns

tp @s[tag=!PlayerGardenerReady] ^ ^ ^0.1
execute as @s[tag=!PlayerGardenerReady] run function endermen/ender_gardener/test_for_mob
## tps itself forwards and loops until end condtion is met