LootTables
Loot tables in AbyssalLib allow you to define complex, randomized item drops in code. These can be used in blocks, entities, containers, or anywhere else you want controlled loot logic.
You define loot tables using a clean, chainable API — no JSON required.
Step 1: Create a Loot Table
You can construct a LootTable
by adding one or more LootPools
. Each pool can contain multiple entries, modifiers, and conditions.
You can add multiple pools with different rolls, items, and conditions to build advanced loot logic.
Step 2: Generate Loot
To actually get the drops, use .generate() with a LootContext:
You can then drop or give the items however you want:
Step 3: Register a Loot Table (Optional)
If you want to register your table for reuse (or for access for other plugins), use a DeferredRegistry<LootTable>
:
Then just call CUSTOM_LOOT.get().generate(ctx)
anywhere you need the drops.
Loot Modifiers
Each LootEntry can be modified with functions:
SetCountFunction(int min, int max)
– Randomized stack size(More can be made by implementing
LootFunction
) You can chain.apply()
multiple times if needed.
Conditions
Loot pools can be wrapped in conditions like:
RandomChanceCondition(float chance)
– Only include the pool if a random roll succeeds