I just wanted to know if there is a way to get a random item without hundreds of commands.
Minecraft – ny way to get a random item without naming every item in minecraft
minecraft-commandsminecraft-java-edition
Related Topic
- Minecraft – way to use the glow tag on an item on an Armor Stand without the Armor Stand getting lit
- Minecraft Commands – Using /clone to Only Replace Air Blocks in Minecraft Java Edition
- Minecraft Java Edition Commands – How to Teleport Someone to the Nether in Version 1.14
- Minecraft Java Edition – How to Make Fireworks Deal No Damage in Version 1.15
- Minecraft Java Edition Commands – Why is Minecraft Registering a TAG_String Without Quotation Marks?
- Minecraft Commands – How to Create Random Item Names
Best Answer
If you can use datapacks, then the following method is a possibility. The method can take a lot of time to make, but requires a few commands to run. So in a datapack make a loot table with every item as a possibility. You can use misode.github.io as a generator. This loot table doesn't need to be a specific type of loot table, but if you want to get the item in a chest, I'm pretty you have to set it to a chest type. With a loot table you can add weight to make one item appear more often the others. If you don't want to spend the time creating this loot table , then if you know a programming language, you can automate it with an executable or a script. I know a programming language, so if you want me to automate it for you, I can. After you finished your loot table and properly installed it, then you have a few options. 1: Give a player a container with the item in it. 2: Give a player the item itself to the player. 3: Drop the item on the ground so the player can pick it up. I will start with number 1. For this method, use the command
give <player selector> chest{BlockEntityTag:{LootTable:"<your loot table>"}}
Next is number 2. For this method use the following command.
loot give <player selector> loot <your loot table>
The next and final method is number 3. For this method use the following command.
loot spawn <coordinates> loot <your loot table>
For filling up the spots I didn't put in, use the in game command line. If you need help with anything let me know.