Class EnchantWithLevelsFunction
java.lang.Object
net.minecraft.world.level.storage.loot.functions.LootItemConditionalFunction
net.minecraft.world.level.storage.loot.functions.EnchantWithLevelsFunction
- All Implemented Interfaces:
BiFunction<ItemStack, LootContext, ItemStack>, LootItemFunction, LootContextUser, Validatable
Applies a random enchantment to the stack.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanprivate final NumberProviderstatic final com.mojang.serialization.MapCodec<EnchantWithLevelsFunction> private final Optional<HolderSet<Enchantment>> Fields inherited from class LootItemConditionalFunction
predicates -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateEnchantWithLevelsFunction(List<LootItemCondition> predicates, NumberProvider levels, Optional<HolderSet<Enchantment>> options, boolean includeAdditionalCostComponent) -
Method Summary
Modifier and TypeMethodDescriptioncom.mojang.serialization.MapCodec<EnchantWithLevelsFunction> codec()enchantWithLevels(HolderLookup.Provider registries, NumberProvider levels) Set<ContextKey<?>> run(ItemStack itemStack, LootContext context) Called to perform the actual action of this function, after conditions have been checked.voidvalidate(ValidationContext context) Validate that this object is used correctly according to the given ValidationContext.Methods inherited from class LootItemConditionalFunction
apply, commonFields, simpleBuilderMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BiFunction
andThen
-
Field Details
-
MAP_CODEC
-
levels
-
options
-
includeAdditionalCostComponent
private final boolean includeAdditionalCostComponent
-
-
Constructor Details
-
EnchantWithLevelsFunction
private EnchantWithLevelsFunction(List<LootItemCondition> predicates, NumberProvider levels, Optional<HolderSet<Enchantment>> options, boolean includeAdditionalCostComponent)
-
-
Method Details
-
codec
- Specified by:
codecin interfaceLootItemFunction- Specified by:
codecin classLootItemConditionalFunction
-
getReferencedContextParams
-
validate
Description copied from interface:LootContextUserValidate that this object is used correctly according to the given ValidationContext.- Specified by:
validatein interfaceLootContextUser- Specified by:
validatein interfaceValidatable- Overrides:
validatein classLootItemConditionalFunction
-
run
Description copied from class:LootItemConditionalFunctionCalled to perform the actual action of this function, after conditions have been checked.- Specified by:
runin classLootItemConditionalFunction
-
enchantWithLevels
public static EnchantWithLevelsFunction.Builder enchantWithLevels(HolderLookup.Provider registries, NumberProvider levels)
-