How to make a sword that shoots particles that do damage?

I want to make this sword that, when you right/left click it, it summons particles that go in a straight line and deal damage to anything they touch. I have only basic knowledge on stuff like this, and I think the first step would be making a scoreboard that detects when the player right clicks with the sword. However, I do not know the rest. Does anyone have an idea on how this is done in java 1.16? Thanks!


Solution 1:

According to MCreator, this is the steps for the command to make a sword shoot fireballs:

  • Make the item when right clicked (sword).

  • Select "execute command".

  • Put /summon Fireball ~ ~2 ~ {ExplosionPower:2,direction:[0.0,0.0,0.0]} in the blank area.

Something to notice though, when the command is executed, the fireballs will be summon on top of the player's head and it will stay there until the player hit the fireball, like when you punch the fireball back at Ghast. Another thing to notice is that the explosion power can be change to any number, but I'd suggest you to keep the number small, don't make it bigger than 5 or else your computer will lag (if you don't have a good computer)

So, you should make a sword and execute that command, which will throw a fireball when right clicked when sword is equipped.