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?