-2

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).

closed as unclear what you're asking by Fabian Röling, Joachim, galacticninja, Ivo Coumans, Dragonrage Sep 17 at 17:04

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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 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 at 11:04
  • Bed Wars as in the map or the Hypixel minigame or what? – aytimothy Sep 27 at 1:06
2

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 or ask your own question.