What command could I use to limit the number of a specific item?
For example, the gold that spawns would be limited to 30, even if you left it running (unless you pick it up - then it can spawn up to 30 again).

  • 1
    Hi tanner, could you be more specific? You want to limit the spawning of items in the world? Under what conditions? If you left what running?
    – Joachim
    Sep 17, 2019 at 9:14
  • 1
    In bedwars resources spawn in generators. Only a certain amount of resources can spawn to a certain amount. I believe it's 70 iron, 10 gold, 8 diamonds, and 2 emeralds. No more resources will spawn until you pick them up. @Joachim
    – Robbie
    Sep 17, 2019 at 11:04
  • Bed Wars as in the map or the Hypixel minigame or what?
    – aytimothy
    Sep 27, 2019 at 1:06

1 Answer 1


In order to do this you basically need to be able to count every item in an area or in the entire minecraft map, which can be accomplished in multiple steps:

  1. Create a scoreboard objective which will hold your item count for different kinds of items, I recommend displaying it on the sidebar to see it easier.
/scoreboard objectives add itemCount dummy
  1. Create a function that can be run which stores an item's "Count" data into a variable and adds that variable to a fake player's itemCount score
# Function commands
execute store result score Item itemCount run data get entity @s Item.Count
scoreboard players operation Total itemCount += Item itemCount
  1. Then, every time you want to count a particular set of items, reset the Total itemCount score and execute the function on all items you want to count
/scoreboard players set Total itemCount 0
/execute as @e[type=item,name=Andesite] run function namespace:function

Then, after you've run these commands, you can choose to only run your item-summoning generator when "Total"s "itemCount" score is below a certain number. I also recommend changing the commands to more closely fit what you want to count.

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