How to make loot table for chest in custom structures

Started by Hoyaki on

Topic category: Help with Minecraft modding (Java Edition)

Last seen on 14:15, 26. Oct 2024
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to make loot table for chest in custom structures

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.

Last seen on 19:46, 25. Oct 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
MCreator has a custom loot…
Sun, 10/29/2023 - 14:04

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

/loot give dev loot superiorstructures:chests/mansion_treasure

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:

/setblock ~ ~1 ~ barrel{LootTable:"superiorstructures:chests/mineshaft_smelter"} destroy

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