Package net.minecraftforge.common.loot
Class LootModifier
- java.lang.Object
-
- net.minecraftforge.common.loot.LootModifier
-
- All Implemented Interfaces:
IGlobalLootModifier
- Direct Known Subclasses:
GlobalLootModifiersTest.DungeonLootEnhancerModifier
,GlobalLootModifiersTest.SilkTouchTestModifier
,GlobalLootModifiersTest.SmeltingEnchantmentModifier
,GlobalLootModifiersTest.WheatSeedsConverterModifier
public abstract class LootModifier extends java.lang.Object implements IGlobalLootModifier
A base implementation of a Global Loot Modifier for modders to extend. Takes care of ILootCondition matching and comes with a base serializer implementation that takes care of Forge registry things.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.function.Predicate<LootContext>
combinedConditions
protected ILootCondition[]
conditions
-
Constructor Summary
Constructors Modifier Constructor Description protected
LootModifier(ILootCondition[] conditionsIn)
Constructs a LootModifier.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.util.List<ItemStack>
apply(java.util.List<ItemStack> generatedLoot, LootContext context)
Applies the modifier to the list of generated loot.protected abstract java.util.List<ItemStack>
doApply(java.util.List<ItemStack> generatedLoot, LootContext context)
Applies the modifier to the generated loot (all loot conditions have already been checked and have returned true).
-
-
-
Field Detail
-
conditions
protected final ILootCondition[] conditions
-
combinedConditions
private final java.util.function.Predicate<LootContext> combinedConditions
-
-
Constructor Detail
-
LootModifier
protected LootModifier(ILootCondition[] conditionsIn)
Constructs a LootModifier.- Parameters:
conditionsIn
- the ILootConditions that need to be matched before the loot is modified.
-
-
Method Detail
-
apply
@Nonnull public final java.util.List<ItemStack> apply(java.util.List<ItemStack> generatedLoot, LootContext context)
Description copied from interface:IGlobalLootModifier
Applies the modifier to the list of generated loot. This function needs to be responsible for checking ILootConditions as well.- Specified by:
apply
in interfaceIGlobalLootModifier
- Parameters:
generatedLoot
- the list of ItemStacks that will be dropped, generated by loot tablescontext
- the LootContext, identical to what is passed to loot tables- Returns:
- modified loot drops
-
doApply
@Nonnull protected abstract java.util.List<ItemStack> doApply(java.util.List<ItemStack> generatedLoot, LootContext context)
Applies the modifier to the generated loot (all loot conditions have already been checked and have returned true).- Parameters:
generatedLoot
- the list of ItemStacks that will be dropped, generated by loot tablescontext
- the LootContext, identical to what is passed to loot tables- Returns:
- modified loot drops
-
-