I have been making a special snowball that when you throw it, it will deal damage to mobs. It does this with an /effect @e[r=1] command but in survival, it will kill the player. I want to give a score to the player holding the snowball. Currently, I use a testfor command to test if the player would have the snowball which means when he or she throws it there is an entity data command which gives the snowball a tag which a execute command executes an effect tag. Does anyone know how to do this?


1 Answer 1


This is a good place to use scoreboard tags as opposed to a scoreboard objective. This will allow you to tag any player holding a snowball and use that tag to target them in a command without having to setup an objective to track a score.

Use 2 command blocks in a chain. The first command block removes the tag from all players. The second command block tags any player holding a snowball. These command blocks have to remain loaded. I recommend putting them in the spawn chunk. I recommend silencing command block output to prevent chat spam for op's. Use command:

/gamerule commandBlockOutput false

The first command block is RepeatUnconditionalAlways Active with command:

scoreboard players tag @a remove Holding

The second command block is ChainUnconditionalAlways Active with command:

scoreboard players tag @a add Holding {SelectedItem:{id:"minecraft:snowball"}}

Now you can use this tag within the target selector to exclude the players who are currently holding a snowball. In your case possibly:

/effect @e[r=1,tag=!Holding]

If you still want to give a player a score instead of a tag, it would be the same solution as above except the commands would be:

scoreboard players set @a Holding 0


scoreboard players set @a Holding 1 {SelectedItem:{id:"minecraft:snowball"}}

Also to note, if the snowball is custom named or special in some other way, you can probably use parts of the data tag portion of your current testfor command in the data tag of the 2nd command block command.

Not the answer you're looking for? Browse other questions tagged .