Class LootTableEvents

java.lang.Object
net.fabricmc.fabric.api.loot.v2.LootTableEvents

@Deprecated public final class LootTableEvents extends Object
Deprecated.
Please use LootTableEvents instead.
Events for manipulating loot tables.
  • Field Details

    • REPLACE

      @Deprecated public static final Event<LootTableEvents.Replace> REPLACE
      Deprecated.
      Please use LootTableEvents.REPLACE instead.
      This event can be used to replace loot tables. If a loot table is replaced, the iteration will stop for that loot table.
    • MODIFY

      @Deprecated public static final Event<LootTableEvents.Modify> MODIFY
      Deprecated.
      Please use LootTableEvents.MODIFY instead.
      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 source LootTableSource.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((key, tableBuilder, source) -> {
           // If the loot table is for the cobblestone block and it is not overridden by a user:
           if (Blocks.COBBLESTONE.getLootTableKey() == key && 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

      @Deprecated public static final Event<LootTableEvents.Loaded> ALL_LOADED
      Deprecated.
      Please use LootTableEvents.ALL_LOADED instead.
      This event can be used for post-processing after all loot tables have been loaded and modified by Fabric.