Package net.fabricmc.fabric.api.loot.v2
Class LootTableEvents
java.lang.Object
net.fabricmc.fabric.api.loot.v2.LootTableEvents
Events for manipulating loot tables.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
static interface
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Event
<LootTableEvents.Loaded> This event can be used for post-processing after all loot tables have been loaded and modified by Fabric.static final Event
<LootTableEvents.Modify> This event can be used to modify loot tables.static final Event
<LootTableEvents.Replace> This event can be used to replace loot tables. -
Method Summary
-
Field Details
-
REPLACE
This event can be used to replace loot tables. If a loot table is replaced, the iteration will stop for that loot table. -
MODIFY
This event can be used to modify loot tables. The main use case is to add items to vanilla or mod loot tables (e.g. modded seeds to grass).You can also modify loot tables that are created by
REPLACE
. They have the loot table sourceLootTableSource.REPLACED
.Example: adding diamonds to the cobblestone loot table
We'll add a new diamond loot pool to the cobblestone loot table that will be dropped alongside the original cobblestone loot pool.If you want only one of the items to drop, you can use
FabricLootTableBuilder.modifyPools(java.util.function.Consumer)
to add the new item to the original loot pool instead.LootTableEvents.MODIFY.register((resourceManager, lootManager, id, tableBuilder, source) -> { // If the loot table is for the cobblestone block and it is not overridden by a user: if (Blocks.COBBLESTONE.getLootTableId().equals(id) && source.isBuiltin()) { // Create a new loot pool that will hold the diamonds. LootPool.Builder pool = LootPool.builder() // Add diamonds... .with(ItemEntry.builder(Items.DIAMOND)) // ...only if the block would survive a potential explosion. .conditionally(SurvivesExplosionLootCondition.builder()); // Add the loot pool to the loot table tableBuilder.pool(pool); } });
-
ALL_LOADED
This event can be used for post-processing after all loot tables have been loaded and modified by Fabric.
-