I just wanted to know if there is a way to get a random item without hundreds of commands.
1 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.
-
-
@JamesRead I will automate it for you sometime later. You're welcome. Nov 17, 2020 at 21:10
-
-
Just curious, what do you mean by “automate it with a programming language”? Do you just mean quick whip up an EXE to write the loot table file? or something to interact with the game, because that would require mods.– PenguinNov 17, 2020 at 22:55
-