I'm trying to make a command block setup that will spawn a fireball above the player when a specific named sword is used. I'd also like to copy the players direction to the fireball. Finally, I'd also like to add some potion effects. I've got the following commands:
/scoreboard objectives add IsHolding dummy
/scoreboard objectives add InfinityBlade stat.useitem.minecraft.golden_sword
/scoreboard players set @a IsHolding 0
/scoreboard players set @a IsHolding 1 {SelectedItem:{tag:{display:{Name:"Infinity Blade"}}}}
/effect @a[score_IsHolding_min=1] minecraft:regeneration 1 1
/effect @a[score_IsHolding_min=1] minecraft:strength 1 1
/execute @a[score_IsHolding_min=1,score_InfinityBlade_min=1] ~ ~ ~ /summon Fireball ~ ~2 ~
/scoreboard players set @a InfinityBlade 0
The problems are that it's necessary to hit a mob in order to spawn the fireball, and that the fireball doesn't go in the direction that the sword is used.