Package net.minecraftforge.common.loot
Class LootModifier
java.lang.Object
net.minecraftforge.common.loot.LootModifier
- All Implemented Interfaces:
- IGlobalLootModifier
A base implementation of a Global Loot Modifier for modders to extend.
 Takes care of ILootCondition matching and comes with the base codec to extend.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprivate final Predicate<LootContext>protected final LootItemCondition[]Fields inherited from interface net.minecraftforge.common.loot.IGlobalLootModifierDIRECT_CODEC, LOOT_CONDITIONS_CODEC
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedLootModifier(LootItemCondition[] conditionsIn) Constructs a LootModifier.
- 
Method SummaryModifier and TypeMethodDescriptionfinal @NotNull it.unimi.dsi.fastutil.objects.ObjectArrayList<ItemStack>apply(it.unimi.dsi.fastutil.objects.ObjectArrayList<ItemStack> generatedLoot, LootContext context) Applies the modifier to the list of generated loot.protected static <T extends LootModifier>
 com.mojang.datafixers.Products.P1<com.mojang.serialization.codecs.RecordCodecBuilder.Mu<T>,LootItemCondition[]> codecStart(com.mojang.serialization.codecs.RecordCodecBuilder.Instance<T> instance) Simplifies codec creation, especially if no other fields are added:protected abstract @NotNull it.unimi.dsi.fastutil.objects.ObjectArrayList<ItemStack>doApply(it.unimi.dsi.fastutil.objects.ObjectArrayList<ItemStack> generatedLoot, LootContext context) Applies the modifier to the generated loot (all loot conditions have already been checked and have returned true).Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraftforge.common.loot.IGlobalLootModifiercodec
- 
Field Details- 
conditions
- 
combinedConditions
 
- 
- 
Constructor Details- 
LootModifierConstructs a LootModifier.- Parameters:
- conditionsIn- the ILootConditions that need to be matched before the loot is modified.
 
 
- 
- 
Method Details- 
codecStartprotected static <T extends LootModifier> com.mojang.datafixers.Products.P1<com.mojang.serialization.codecs.RecordCodecBuilder.Mu<T>,LootItemCondition[]> codecStart(com.mojang.serialization.codecs.RecordCodecBuilder.Instance<T> instance) Simplifies codec creation, especially if no other fields are added:
 Otherwise can follow this with #and() to add more fields. Examples: Forge Test Subclasses orpublic static final Codec<MyLootModifier> CODEC = RecordCodecBuilder.create(inst -> codecStart(inst).apply(inst, MyLootModifier::new));BendingTrunkPlacer.CODEC
- 
apply@NotNull public final @NotNull it.unimi.dsi.fastutil.objects.ObjectArrayList<ItemStack> apply(it.unimi.dsi.fastutil.objects.ObjectArrayList<ItemStack> generatedLoot, LootContext context) Description copied from interface:IGlobalLootModifierApplies the modifier to the list of generated loot. This function needs to be responsible for checking ILootConditions as well.- Specified by:
- applyin interface- IGlobalLootModifier
- 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
 
- 
doApply@NotNull protected abstract @NotNull it.unimi.dsi.fastutil.objects.ObjectArrayList<ItemStack> doApply(it.unimi.dsi.fastutil.objects.ObjectArrayList<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 tables
- context- the LootContext, identical to what is passed to loot tables
- Returns:
- modified loot drops
 
 
-