If you want to override a vanilla loot table you can also make your own loot table (wich is a copy of the vanilla one + the items of your mod) and then in that event set your loot table as the table of the event. For example, i do this to override the vanilla mineshaft chest loot table. I create my own mineshaft chest loot table by doing this
public static ResourceLocation CHESTS_ABANDONED_MINESHAFT;
CHESTS_ABANDONED_MINESHAFT = LootTableList.register(new ResourceLocation(MW.MODID, "abandoned_mineshaft"));
and i call this from the init method in main mod file.
This will assume that in your assets folder you have a folder called "loot_tables" and inside that folder you have the loot table you're looking for (in this case "abandoned_mineshaft"). That will be the replaced loot table (so the game will load this instead of the vanilla one). For example look at this loot table
{
"pools": [
{
"name": "abandoned_mineshaft_1",
"rolls": 1,
"entries": [
{
"type": "item",
"entryName": "golden_apple",
"name": "minecraft:golden_apple",
"weight": 20
},
{
"type": "item",
"entryName": "enchanted_golden_apple",
"name": "minecraft:golden_apple",
"weight": 1,
"functions": [
{
"function": "set_data",
"data": 1
}
]
},
{
"type": "item",
"name": "minecraft:name_tag",
"weight": 30
},
{
"type": "item",
"name": "minecraft:book",
"weight": 10,
"functions": [
{
"function": "enchant_randomly"
}
]
},
{
"type": "item",
"name": "minecraft:iron_pickaxe",
"weight": 5
},
{
"type": "item",
"name": "mw:ruby",
"weight": 20,
"functions": [
{
"function": "set_count",
"count": {
"min": 1,
"max": 4
}
}
]
},
{
"type": "item",
"name": "mw:sapphire",
"weight": 20,
"functions": [
{
"function": "set_count",
"count": {
"min": 1,
"max": 4
}
}
]
},
{
"type": "empty",
"weight": 5
}
]
},
{
"name": "abandoned_mineshaft_2",
"rolls": {
"min": 2,
"max": 4
},
"entries": [
{
"type": "item",
"name": "minecraft:iron_ingot",
"functions": [
{
"function": "set_count",
"count": {
"min": 1,
"max": 5
}
}
],
"weight": 10
},
{
"type": "item",
"name": "minecraft:gold_ingot",
"functions": [
{
"function": "set_count",
"count": {
"min": 1,
"max": 3
}
}
],
"weight": 5
},
{
"type": "item",
"name": "minecraft:redstone",
"functions": [
{
"function": "set_count",
"count": {
"min": 4,
"max": 9
}
}
],
"weight": 5
},
{
"type": "item",
"name": "minecraft:dye",
"functions": [
{
"function": "set_data",
"data": 4
},
{
"function": "set_count",
"count": {
"min": 4,
"max": 9
}
}
],
"weight": 5
},
{
"type": "item",
"name": "minecraft:diamond",
"functions": [
{
"function": "set_count",
"count": {
"min": 1,
"max": 2
}
}
],
"weight": 3
},
{
"type": "item",
"name": "minecraft:coal",
"functions": [
{
"function": "set_count",
"count": {
"min": 3,
"max": 8
}
}
],
"weight": 10
},
{
"type": "item",
"name": "minecraft:bread",
"functions": [
{
"function": "set_count",
"count": {
"min": 1,
"max": 3
}
}
],
"weight": 15
},
{
"type": "item",
"name": "minecraft:melon_seeds",
"functions": [
{
"function": "set_count",
"count": {
"min": 2,
"max": 4
}
}
],
"weight": 10
},
{
"type": "item",
"name": "minecraft:pumpkin_seeds",
"functions": [
{
"function": "set_count",
"count": {
"min": 2,
"max": 4
}
}
],
"weight": 10
},
{
"type": "item",
"name": "minecraft:beetroot_seeds",
"functions": [
{
"function": "set_count",
"count": {
"min": 2,
"max": 4
}
}
],
"weight": 10
}
]
},
{
"name": "abandoned_mineshaft_3",
"rolls": 3,
"entries": [
{
"type": "item",
"name": "minecraft:rail",
"functions": [
{
"function": "set_count",
"count": {
"min": 4,
"max": 8
}
}
],
"weight": 20
},
{
"type": "item",
"name": "minecraft:golden_rail",
"functions": [
{
"function": "set_count",
"count": {
"min": 1,
"max": 4
}
}
],
"weight": 5
},
{
"type": "item",
"name": "minecraft:detector_rail",
"functions": [
{
"function": "set_count",
"count": {
"min": 1,
"max": 4
}
}
],
"weight": 5
},
{
"type": "item",
"name": "minecraft:activator_rail",
"functions": [
{
"function": "set_count",
"count": {
"min": 1,
"max": 4
}
}
],
"weight": 5
},
{
"type": "item",
"name": "minecraft:torch",
"functions": [
{
"function": "set_count",
"count": {
"min": 1,
"max": 16
}
}
],
"weight": 15
}
]
}
]
}
This is the vanilla abandoned_mineshaft loot table plus some rolls for my mod items, so in game in mineshafts i can find mod items too in chests. Finally, to load this table instead of the vanilla one you'll have to catch the LootTableLoadEvent and set the table to your own table.
public void onLootTableLoad(LootTableLoadEvent event) {
if(event.getName().equals(LootTableList.CHESTS_ABANDONED_MINESHAFT)) {
event.setTable(event.getLootTableManager().getLootTableFromLocation(MWLootTables.CHESTS_ABANDONED_MINESHAFT));
}
}
In game, when you'll open a mineshaft chest it will load your loot table (the one showed up) instead of the vanilla one and so yuour mod items will have a chance to be in that cehst. Hope this is clear :)