Loot tables not working with custom blocks

Published by Ryorama on
Issue description

I created a loot table with the latest snapshot version of mcreator and I cannot figure out how to apply it to anything.

Issue comments

You can apply it to custom blocks or entities by using mod namespace and same registry name as the registry name of the element, or use minecraft namespace to override existing loot tables.

And the loot table name needs to be all-lowercase. If this is 1.14.4, this would be my guess for the problem.

Export your workspace to shareable ZIP and attach it to this ticket so I can import it and see it myself.

I can confirm this bug. Loot tables do not work with custom blocks. I will fix this bug in the next snapshot/release.

You are welcome! I am glad I could help :) If you like what we do, consider donating to us to help us keep this project up.

I still have this in 1.15.2 2020.3, and I'm pretty sure I've got the registry name and namespace correct. venomglider_net connects to blocks/venomglider_net, which is type "Block," and I've got tileDrops on in the world, yet nothing happens.

That's what's in the example, and is there any way to change it? Further clarification (I phrased it poorly): the block is venomglider_net, the loot table registry is blocks/venomglider_net, namespace Mod, type Block.

I just tested it, you need blocks/registryname, mod namespace, and block type.

If it still does not work, open a new ticket and attach a minimal reproducible example (workspace with one block and one loot table) to demonstrate the bug.

what do you mean by:

blocks/registryname, mod namespace, and block type.

because i tried this and it doesn't work, but maybe i'm doing it wrong.

would you mind explaining it again but with picture?

 

https://mcreator.net/forum/64252/how-make-block-drop-items-loot-table

If you go inside the Loot Table element, the very top input slot says "Loot table registry name:". You first need to set that input to the "blocks/stone" in the drop-down box.

Next, delete everything after the "/", leaving only "blocks/".

Finally, leaving the "blocks/" untouched, add the ENTIRE name of your block to the end, with all the uppercase letters lowercase, and a "_" before each of where the uppercase letters were (except if the first letter was uppercase. don't put a underscore before that). This step is the problematic one.

For example, my leaf block element was named "BlockJoltLeaves" (as in that's what the name showed up as on the main workspace screen, not the in-game gui name), so to get this to work for my leaf block, that top input slot had to say "blocks/block_jolt_leaves". Note that I had to add "block" after the "/", because that was what my element's name started with, and I put a "_" before where each of the uppercase letters had been (except the first "b" of course).

Also, the other two drop down slots are set to "mod" and "block".

I have a similar problem, I can't put a loot table into a custom chest. While I just open the chest, it's just empty, but if I try to put an item into this custom chest, the game crashes.

Is the loot table bug patched for sure? I feel like it's still around in 2021.2, because I can't get any custom loot tables to work for my modded blocks.

I'm still having the same problem.  All they do is tell you to cookie cutter helpdesk questions that have already been asked, and then stop responding when the problem isn't fixed and they are out of ideas.

For 1.12.2, he solution is very simple:

1 - Open the code of your custom chest

2 - Go to the very bottom to this method:
  @Override
 public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) {
  return new GuiContainergui.GuiContainerMod(this.getWorld(), this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), playerIn);
 } 

3 - Add this before the return:
this.fillWithLoot(playerIn);
(it should look like this)
  @Override
 public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) {
  this.fillWithLoot(playerIn);
  return new GuiContainergui.GuiContainerMod(this.getWorld(), this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), playerIn);
 } 
4 - Lock the code and save

5 - Profit


Note: This extra line is inserted when the code for recovering items from the container is initialized and tries to fill the container accordingly to the loot table in its NBT data like the vanilla chest. You can find the same line in TileEntityChest.java at line 433.