tag @e[tag=check,sort=nearest,limit=1] add mrcd_target
tag @e[tag=mrcd_target,limit=1] remove check

tp @s ~ ~ ~ facing entity @e[tag=mrcd_target,limit=1] feet
scoreboard players set rot_times ec_calc 5
execute if entity @e[tag=mrcd_target,tag=!mrcd_target_entity,limit=1] at @s run function items:obj/electric_charge/electrocute/check_loop

execute at @s anchored eyes run tp @s ~ ~ ~ ~ ~4
execute if entity @e[tag=mrcd_target,tag=mrcd_target_entity,limit=1] at @s run function items:obj/electric_charge/electrocute/ray_cast

tag @e[tag=mrcd_target] remove mrcd_target

execute if entity @e[tag=check,limit=1] run function items:obj/electric_charge/electrocute/main
