Jump to content

Recommended Posts

Posted

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!

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.