I am trying to use the xp bar as a shot reloader where it gives a player a snowball when it reaches 1 xp level. It then stops adding xp points until the player throws the snowball, after which it will be set back to 0 xp. After that, it will load until it reaches 1 xp and give the player another snowball. The command sequence I'm using is:

Command block 1, impulse, activated by redstone circuit:

xp add @p[level=0] 1 points

Command block 2, impulse, always active:

give @p[level=1] snowball

Command block 3, impulse, always active:

xp set @p[nbt={Inventory:[{id:"minecraft:snowball",Count:0b}]}] 0 level

It works until the player throws the snowball. Once the snowball is thrown the xp level won't be set back to zero, meaning the player can't get snowballs again.

  • What does "it doesn't work" mean? Error message? Computer explodes? Chickens everywhere? Also, can you please reword the first paragraph? It's a bit hard to understand with its 61 words and three "and". Mar 16, 2019 at 22:04
  • Sorry for the confusion, I changed it and hope it's easier to understand now. Mar 17, 2019 at 1:35

1 Answer 1


You're testing for a stack size of 0. That can't ever happen. Change it to Count:1b.

  • That would make it work but I don't want the bar to reload until the player has thrown the snowball. Mar 18, 2019 at 11:22
  • I think I figured out how to make it work, I just need to add a scoreboard objective once the player throws the snowball, the objective resets if the player throws the snowball and only players who don't have that objective have their xp bar refilled. Mar 18, 2019 at 11:25
  • You're old solution should work without that, but your new solution is better. Mar 18, 2019 at 14:55

You must log in to answer this question.

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