I have a scoreboard objective called ammoCount. That is how I am tracking the amount of ammo players have, but I would like to put some items in the players' inventories to show them how much ammo they have. So, if a player has 10 ammo, they will have 10 blocks in their inventory, if they have 64 ammo they will have a stack of blocks, and if they have 65 ammo they will have a full stack plus an extra. Is this possible?

  • I'm sure it's possible, but quickly thinking about it makes me think it would be very complicated.
    – MBraedley
    Dec 26, 2014 at 17:25
  • Somehow encode score into binary(youtube.com/watch?v=WehfW3JGpf0) and assign each digit to multiple objectives and give 1, 2, 4, 8, etc amount of item accordingly.
    – Q20
    Dec 28, 2014 at 3:32

1 Answer 1


There are two ways you could do this. The first method would involve one command block for each amount of ammo, but would be fast to update. The second method would be slower to update, but would work for any amount of ammo with just a few command blocks.


Say you're using iron blocks for ammo, you should set up any clock with this command first:

/clear @a iron_block

Which will clear the player's inventory of any iron blocks. Immediately after this on the clock, have one of these command blocks for each possible amount of ammo:

/give @a[score_ammoCount=1,score_ammoCount_min=1] iron_block 1
/give @a[score_ammoCount=2,score_ammoCount_min=2] iron_block 2

You could use an MCEdit filter such as this one to quickly create all of the command blocks you need. The faster the clock, the faster it will update. You can have it updating the player's inventory 20 times a second with a /fill clock.


The second method is to:

  • Create another objective, say "ammoCountTemp"

/scoreboard objectives add ammoCountTemp dummy

  • Set everyone's ammoCountTemp to their ammoCount

/execute @a ~ ~ ~ /scoreboard players operation @p ammoCountTemp = @p ammoCount

  • Give everyone with at least 1 ammoCountTemp an iron block

/give @a[score_ammoCountTemp_min=1] iron_block

  • Decrement everyone's ammoCountTemp

/scoreboard players remove @a ammoCountTemp 1

  • Repeat from step 3 until nobody is being given iron blocks

  • Wait a while, then start again from step 2

As I said, this is much slower. I'd only recommend this if you are going to be having huge amounts of ammo available.

  • Method 2 worked well, but I modified it a bit so that ammoCountTemp is modified when the player shoots/collects ammo, then ammoCount is updated to match it. As it is updated, blocks are added/subtracted. Dec 26, 2014 at 19:05
  • yep, about as complicated as I thought it would be.
    – MBraedley
    Dec 27, 2014 at 3:01

You must log in to answer this question.

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