So I'm just messing around in Minecraft with friends, and I want to make different named snowballs do different things, i.e. a snowball called 'Lightning' that, when thrown, summons lightning as it flies.
I've thrown this command together, but it's not working:

/execute @e[type=snowball] {display:{Name:example}} ~ ~ ~ /summon cow ~ ~10 ~

Any help?

EDIT: Sorry, the error message is '@e[type=snowball]' found nothing', but that probably is happening because it's on a repeating command block. I tried putting a button on an impulse command block with the command in it, but even when I pressed the button and threw the snowball it wouldn't work.
By the way, my intentions were for the cows to spew out of the snowball :)

EDIT2: Oh, I've got a new error message from the command:
'{display:{Name:example}}' is not a valid number. Obviously point out that it thinks that {display:{Name:example}} is a coordinate.

  • you will need to do better than that. have a go a forming the command yourself and report the errors you receive. We aren't a full-solution service! you need to do SOME of the work! ;) – Stese Oct 4 '17 at 9:08
  • You've told us your overall idea, but not what this exact command is supposed to do. The only thing I can see it doing right now is spewing cows all over the place, because it would summon one in every tick the snowmall flies. Also: Error message, please! They are there to help. – Fabian Röling Oct 4 '17 at 9:20
  • You're probably getting an error for the NBT part. /execute has no NBT functionality. You can't just randomly add something to your command and hope it'll work, look up the syntax! The error message will probably even tell you the syntax. – Fabian Röling Oct 4 '17 at 9:22
  • I don't believe thrown snowball projectiles contain any of the NBT data. You would have to target the person holding the custom snowball so you could detect and tag any snowball they threw. Also, as Fabian described, a command similar to yours that would succeed would produce a lot of cows along the path of the flying snowball. Try execute @e[type=snowball] ~ ~ ~ summon cow ~ ~10 ~ to see for yourself, a whole lot of dead cows. – IronAnvil Oct 4 '17 at 15:41
  • I have answered a few questions that might help. Try this one and this one. The upside to using a bow over snowballs, they can be detected when in the ground so you could summon a cow where the arrow lands. You can also use scoreboard with stat.useItem.minecraft.arrow (or snowball) to be more specific with your targeting. – IronAnvil Oct 4 '17 at 15:42

Using the execute command is the correct way to do this, but you can not use nbt data in the execute command.

From the command wiki the execute command syntax:

execute <entity> <x> <y> <z> <command …>

There is no argument for data tag information with the execute command. This is why you got the error that stated {display:{Name:example}} is not a number. Look at testfor to see a command with the data tag argument. You will have to use a different method of targeting the entity within the execute command.

This solution uses four command blocks. These command blocks need to be in loaded chunks in order to function properly. If placed in the spawn chunks, they will always remain loaded.

I also recommend you silence command block output to prevent chat spam. Use command:

/gamerule commandBlockOutput false


The first command block adds the tag HoldingMoo to the player holding a snowball named Moo. It is Repeat Unconditional Always Active and its command is:

scoreboard players tag @a add HoldingMoo {SelectedItem:{id:"minecraft:snowball",tag:{display:{Name:"Moo"}}}}

The second command block adds the tag Moo to any snowball within a radius of 3 from a player tagged HoldingMoo. It is Chain Conditional Always Active and its command is:

execute @a[tag=HoldingMoo] ~ ~ ~ scoreboard players tag @e[type=snowball,r=3] add Moo

The third command block removes the tag HoldingMoo from all players. This is for when a player is no longer holding the named snowball. It is Chain Unconditional Always Active and its command is:

scoreboard players tag @a remove HoldingMoo

The final command block is not apart of the chain. It is where you run the summon command. It is Repeat Unconditional Always Active and its command is:

execute @e[tag=Moo] ~ ~ ~ summon cow ~ ~10 ~

You could build a second copy of the same setup with a different set of tags for a different named snowball to do different things. I built a second set up using the tags HoldingBolt and Bolt to summon lightning. Here is the command I ran in the last command block:

execute @e[tag=Bolt] ~ ~ ~ summon lightning_bolt ~ ~ ~

Here is a picture of the cow carnage: Carnage

Here is a picture of the lightning snowball: Lightning

This solution is simple and will work for most needs but is not perfect. If a player were holding a snowball named Moo and another player threw a snowball at the first player, it might summon a few cows.

If you would like to be more specific, you can create an objective using useitem which will add one to the score every time a player throws a snowball. This will only tag a snowball within the radius of a player who is both holding a custom named snowball and has thrown a snowball.

Create the objective manually by typing this command into chat:

/scoreboard objectives add Thrown stat.useItem.minecraft.snowball

Then be more specific with the target selector by changing the first command block command. This will now only add the tag HoldingMoo to a player who is holding a snowball named Moo and has thrown a snowball. The modified command:

scoreboard players tag @a[score_Thrown_min=1] add HoldingMoo {SelectedItem:{id:"minecraft:snowball",tag:{display:{Name:"Moo"}}}}

This method will require one more command block on the chain, to make it four long. This extra command resets the score tracking how many snowballs each player has thrown. This command block is Chain Unconditional Always Active and its command is:

scoreboard players reset @a Thrown


| improve this answer | |

This command will summon lightning_bolt at any entity within 4 blocks of the snowball other than ones specified by type=!. It works for Bedrock and should also work for Java:

/execute @e[type=snowball] ~ ~ ~ execute @e[r=4,type=!lightning_bolt,type=!minecraft:item,type=!player,type=!snowball] ~ ~ ~ summon lightning_bolt ~ ~ ~

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.