Class AddTableLootModifier

java.lang.Object
net.neoforged.neoforge.common.loot.LootModifier
net.neoforged.neoforge.common.loot.AddTableLootModifier
All Implemented Interfaces:
IGlobalLootModifier

public class AddTableLootModifier extends LootModifier

Loot modifier that rolls one loot table (the "subtable" and adds the results to the loot being modified (the "target table"). Loot modifiers are not rolled for the subtable, as that could result in the subtables' items being modified twice (by downstream loot modifiers modifying the target table).

Json format:

 {
   "type": "neoforge:add_table",
   "conditions": [], // conditions block to predicate target tables by
   "table": "namespace:loot_table_id" // subtable to roll loot for to add to the target table(s)
 }
 

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.MapCodec<AddTableLootModifier>
     
    private final net.minecraft.resources.ResourceKey<net.minecraft.world.level.storage.loot.LootTable>
     

    Fields inherited from class net.neoforged.neoforge.common.loot.LootModifier

    conditions

    Fields inherited from interface net.neoforged.neoforge.common.loot.IGlobalLootModifier

    CONDITIONAL_CODEC, DIRECT_CODEC, LOOT_CONDITIONS_CODEC
  • Constructor Summary

    Constructors
    Constructor
    Description
    AddTableLootModifier(net.minecraft.world.level.storage.loot.predicates.LootItemCondition[] conditionsIn, net.minecraft.resources.ResourceKey<net.minecraft.world.level.storage.loot.LootTable> table)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.mojang.serialization.MapCodec<? extends IGlobalLootModifier>
    Returns the registered codec for this modifier
    protected it.unimi.dsi.fastutil.objects.ObjectArrayList<net.minecraft.world.item.ItemStack>
    doApply(it.unimi.dsi.fastutil.objects.ObjectArrayList<net.minecraft.world.item.ItemStack> generatedLoot, net.minecraft.world.level.storage.loot.LootContext context)
    Applies the modifier to the generated loot (all loot conditions have already been checked and have returned true).
    net.minecraft.resources.ResourceKey<net.minecraft.world.level.storage.loot.LootTable>
     

    Methods inherited from class net.neoforged.neoforge.common.loot.LootModifier

    apply, codecStart

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • AddTableLootModifier

      public AddTableLootModifier(net.minecraft.world.level.storage.loot.predicates.LootItemCondition[] conditionsIn, net.minecraft.resources.ResourceKey<net.minecraft.world.level.storage.loot.LootTable> table)
  • Method Details

    • table

      public net.minecraft.resources.ResourceKey<net.minecraft.world.level.storage.loot.LootTable> table()
    • doApply

      protected it.unimi.dsi.fastutil.objects.ObjectArrayList<net.minecraft.world.item.ItemStack> doApply(it.unimi.dsi.fastutil.objects.ObjectArrayList<net.minecraft.world.item.ItemStack> generatedLoot, net.minecraft.world.level.storage.loot.LootContext context)
      Description copied from class: LootModifier
      Applies the modifier to the generated loot (all loot conditions have already been checked and have returned true).
      Specified by:
      doApply in class LootModifier
      Parameters:
      generatedLoot - the list of ItemStacks that will be dropped, generated by loot tables
      context - the LootContext, identical to what is passed to loot tables
      Returns:
      modified loot drops
    • codec

      public com.mojang.serialization.MapCodec<? extends IGlobalLootModifier> codec()
      Description copied from interface: IGlobalLootModifier
      Returns the registered codec for this modifier