Jump to content

Recommended Posts

Posted (edited)

I'm new to modding and need a little help.

I'm wondering how can I override vanilla loot table/pools and NOT overriding any other pools added by other mods? 

I tried to add custom pool to vanilla loot table and remove vanilla pools during loot table load event. This worked fine alone, but once the mod is built and ran with other mods, appeared that it did not work if I remove the last pool from the vanilla loot table.

This is the code section of the loot table load event. I have a  "simple_dungeon.json" in the "resources/data/lootinjector/loot_tables/chests" folder. Note: vanilla simple_dungeon has 3 pools, it does not work with other mod if I remove "pool2".

@SubscribeEvent
public void onLootTableLoad(LootTableLoadEvent event) {
	//remove vanilla and and replacement pools
	if(event.getName().toString().startsWith("minecraft:chests/simple_dungeon")) {
		LOGGER.info("Adding Loot to Simple Dungeon...");
		LootTable tbl = event.getTable();
		tbl.addPool(buildPool("chests/simple_dungeon"));
		tbl.removePool("main");
		tbl.removePool("pool1");
		// Adding the following line will cause error
		// tbl.removePool("pool2");
    }
}
    
private static ResourceLocation res(String loc) {
	return new ResourceLocation(modid, loc);
}
//build LootPool from json
private static LootPool buildPool(final String pool) {
  	return LootPool.builder().addEntry(TableLootEntry.builder(res(pool))).build();
}

How do I fix this? 

Edited by stop_x13

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.