I'm making a fun survival server in which the player has to keep adding items to the generator, or else the item dropper will lose power. This item dropper drops items needed to power the generator, and the only way to get regen is from potions dropped by dropper. I want to know if there is a way to make a random item from a list drop every so often in the air. The exact spot is -1181 32 -131 in case that helps.

I have tried to use an execute command for an armor stand, an invisible guy with his name visibly being ITEM DROP ZONE. this is the command for him: `

/summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoGravity:1b,CustomName:"ITEM DROP ZONE",CustomNameVisible:1b}

This shouldn't really change anything for an execute except the @e[type=.... stuff, but I need help with that part. How do I make 1) A chain of commands that allows me to do a random command out of like, lets say, 8 different commands I already have, and 2) a command to have as my guideline, like the working version of /execute @e[type=armor stand, name= ITEM DROP ZONE] /summon Dropped Item.... etc.


Solution 1:

You can create a loot table that contains all the different items you want the item dropper to drop.

Go to minecraft.tools/en/loots.php to create a loot table with all of the items you want in it. Because loot tables are random (you don’t get the same exact drops and amounts of those drops when you kill mobs), loot tables can be used to generate random drops, but can be controlled enough to decide probabilities and amounts if you so desire.

If you don’t know how to create loot tables, there are plenty of examples on the internet that explain how.

Once you create your loot table, copy it to your clipboard and go to your world saves folder (the world saves folder’s name is default to “world” on servers) and then navigate to the folder called data. Create a folder called loot_tables inside of it if it doesn’t already exist. Inside of that folder, create a folder called custom_drops. Inside of the custom_drops folder, create a folder called entities. Then in that folder create a text file called item_dropper.json with your loot table pasted inside of it.

In your minecraft world, use this command to summon the armor stand:

/summon armor_stand -1181 32 -131 {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoGravity:1b,CustomName:"item_dropper",CustomNameVisible:0b,DeathLootTable:”custom_drops:entities/item_dropper”}

Then kill the armor stand with the command /kill @e[type=armor_stand,name=item_dropper] right after you summon it (with chain command blocks you could do this on the same tick).

This will summon an armor stand with the loot table created, and then kill it to make it drop the items in the loot table.

Keep in mind that the mob loot gamerule must be on for this to work. Use /gamerule doMobLoot true to toggle mob loot to true.