Posted May 23, 20205 yr Hi there, I'm currently trying to inject an item into a loot table, so far my injection code is as follows: @SubscribeEvent public static void onLootLoad(LootTableLoadEvent event) { if (event.getName().equals(new ResourceLocation("minecraft", "underwater_ruin_small"))) { event.getTable().addPool(LootPool.builder().addEntry(TableLootEntry.builder(new ResourceLocation(MyMod.MODID, "underwater_ruin_small"))).build()); } } And my json file looks like this: { "pools": [ { "name": "main", "rolls": 1, "entries":[ { "type": "item", "weight": 5, "name": "mymod:myitem" }, { "type": "item", "weight": 75, "name": "minecraft:compass" } ] } ] } When I access the vanilla loot table using /setblock ~ ~ ~ chest{LootTable:"minecraft:chests/underwater_ruin_small"} My items are never in it. Any help would be greatly appreciated!
May 24, 20205 yr Author 17 hours ago, diesieben07 said: https://github.com/MinecraftForge/Documentation/pull/290 Thank you for your reply, how would I use this to inject into an existing chest loot table?
May 24, 20205 yr Author 6 minutes ago, diesieben07 said: You would create a global loot modifier. Then in the loot modifier you can get the world (LootContext#getWorld) and position (LootParameters.POSITION) from the loot context. From that you could get the chest at that location (if it is a chest). If so, you can get it's loot table (LockableLootTileEntity#lootTable, you'll need reflection). Thanks for the explanation!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.