Minecraft – How To Make Bow / Snowball that shoots Custom Named Arrows / Snowballs

minecraft-commandsminecraft-java-edition

I decided to make a Snowball that summons lightning bolts along. Well I already did one half – With the @e[type=Snowball] (or Arrow, depending if I use a bow). But with @e I will target all the snowballs. So I wondered if a snowball could shoot named snowballs so I can use @e[name=RandomName].
Can anyone help?

Best Answer

Snowballs are a lot of fun aren't they? Well, this is simpler, since your requirements are that a particular sort of snowball will have an arc of lightning bolts across its trajectory, but the principal is the same.

For this, I used a series of 4 commands and 1 setup command. (well, and also /gamerule commandBlockOutput false) It works by setting a lightning score for snowball entities holding customly named snowballs, and then summoning a lightningbolt at each of those snowballs. And it's actually a neat little set of commands.

First, we need our scoreboard. You can set one up using /scoreboard objectives add lightning dummy. From here, we want to be able to perform commands on players holding customly named snowballs:

scoreboard players set @a lightning 1 {SelectedItem:{id:minecraft:snowball,tag:{display:{Name:"KABOOM"}}}}

Unfortunately there's no really clean way to invert this sort of command to reset this score, and resetting it for all items would also cause the last snowball in a stack to stop working, so I just reset it for players holding snowballs. As long as the commands execute at the same time, you shouldn't run into any problems, unless you're trying to build a PvP game around this, then you may want to reset this score for everyone just to be safe:

scoreboard players set @a lightning 0 {SelectedItem:{id:minecraft:snowball}}

From here, we can set the score of the snowball entities near these players using execute:

execute @a[score_lightning_min=1] ~ ~ ~ scoreboard players add @e[type=Snowball,r=10] lightning 0

Now you have a marked snowball. Just what we need! The final step to this equation is to slap a score_lightning_min=0 in the original "make lightning at every snowball entity" command, hook all 4 command blocks up to a clock of some sort (I recommend a /fill clock, but it's not entirely necessary as long as all of your commands are on the same line of redstone) and we should be set:

execute @e[type=Snowball,score_lightning_min=0] ~ ~ ~ summon LightningBolt ~ ~ ~

The results: Wholly satisfying:

enter image description here