#Summon Spell
summon marker ^ ^ ^.5 {Tags:["spell","init","unspellable","mrcd_bullet"],Duration:7400}
data modify entity @e[limit=1,sort=nearest,tag=spell,tag=init] Tags insert 0 from entity @s SelectedItem.tag.name
data modify entity @e[limit=1,sort=nearest,tag=spell,tag=init] Tags insert 0 from entity @s SelectedItem.tag.element

# Save speed and direction - Uses Minecraft-Ray-Collision-Detector-master datapack
execute as @e[limit=1,sort=nearest,tag=spell,tag=init] store result score @s mrcd_x0 run data get entity @s Pos[0] 1000
execute as @e[limit=1,sort=nearest,tag=spell,tag=init] store result score @s mrcd_y0 run data get entity @s Pos[1] 1000
execute as @e[limit=1,sort=nearest,tag=spell,tag=init] store result score @s mrcd_z0 run data get entity @s Pos[2] 1000

execute store result score #var0 mrcd_system run data get entity @s Pos[0] 1000
execute store result score #var1 mrcd_system run data get entity @s Pos[1] 1000
execute store result score #var2 mrcd_system run data get entity @s Pos[2] 1000

scoreboard players operation @e[limit=1,sort=nearest,tag=spell,tag=init] mrcd_x0 -= #var0 mrcd_system
scoreboard players operation @e[limit=1,sort=nearest,tag=spell,tag=init] mrcd_y0 -= #var1 mrcd_system
scoreboard players operation @e[limit=1,sort=nearest,tag=spell,tag=init] mrcd_z0 -= #var2 mrcd_system

execute at @s anchored eyes positioned ^ ^ ^1 run tp @e[limit=1,sort=nearest,tag=spell,tag=init] ~ ~ ~ ~ ~

# join_link
scoreboard players operation @e[limit=1,sort=nearest,tag=spell,tag=init] o_uuid = @s o_uuid

# Clear tag
tag @e[limit=1,sort=nearest,tag=spell,tag=init] remove init
