Started by
Hoyaki
on
Topic category: Help with modding (Java Edition)
I want to add some structures having chest inside to my mod. but i want to make the chests have different stuff every generation. like the bones chest in Minecraft, everytime we create a new world with it, it has different stuffs.
MCreator has a custom loot tables element that works pretty much how you'd expect. You can make a custom loot table, and then if you assign it to a container, that container will have randomized contents until it's opened or interacted with.
I assume you just need help getting a chest with a loot table assigned to it to use in a structure, (which is totally fair, it's a weird set of commands.
You can test a custom loot table like this: (This command will run the loot table and set the results of it in your inventory. Good for making sure you've at least got the name right:)
Replacing 'superiorstructures' with your mod Id, and 'chests/mansion_treasure' with whatever you named your loot table. (All loot tables, including custom ones, should show up as autofill options if they were made correctly.)
If you instead want a command block that generates containers with your loot table, enter this command into the command block:
...Again replacing 'superiorstructures' and 'chests/mineshaft_smelter' with your own Mod ID and loot table name.
You can then use Ctrl + Middle Click to pick up a copy of the chest, with the NBT data still assigned. This means that every time you place down a chest obtained this way, it will have the loot table assigned to it, and will randomly generate its contents the first time it's opened or interacted with.