Architectury API (Fabric/Forge/NeoForge)

Architectury API (Fabric/Forge/NeoForge)

158M Downloads

Loot Table injecting

MaxNeedsSnacks opened this issue ยท 6 comments

commented

We need to be able to inject into vanilla (or other modded) loot tables using some sort of event or by offering some special JSON file syntax.

This would be used by most mods that add loot to stuff like dungeon chests, or that want to add to things like block drops (e.g. extra seeds from grass)

commented

Probably Forge's LootTableLoadEvent and Fabric API's LootTableLoadingCallback could be used here. One possible problem is that FAPI uses a subclass of LootTable.Builder while Forge uses LootTable directly (with some mutators patched in).

commented

We could theoretically also ignore Forge's LoadTableLoadEvent like we have for lightning strikes if we find too many functional differences to properly bridge the two, shouldn't make a difference in the end as we'd encourage API users to use our cross platform events anyways

commented

Another thing to note:
https://github.com/MinecraftForge/MinecraftForge/blob/ba15737fe3d3c6286cfb90c0dca96e2381914245/src/main/java/net/minecraftforge/event/LootTableLoadEvent.java#L31

Forge only allows you to inject into "non-custom" loot tables, while Fabric as far as I can tell will allow you to modify theoretically any table.

Also worth noting is that Forge freezes tables after this event is fired...

commented

The table freezing isn't really important of a detail - it's only useful on Forge since loot tables are actually immutable in vanilla.

And yeah, FAPI allows the modification of all loot tables using the loot table builder. Forge does have a point there with the restrictions on local tables, but allowing full modification is more flexible for an API.

commented

We could perhaps abstract the whole thing (is it possible?), like what I did with biome modification.

commented

This sort of minimal interface would work technically:

interface LootTableThingy {
    void addPool(LootPool pool);
}

(Can be implemented easily both for Forge's mutable loot tables and loot table builders)