Class EnchantRandomlyFunction
java.lang.Object
net.minecraft.world.level.storage.loot.functions.LootItemConditionalFunction
net.minecraft.world.level.storage.loot.functions.EnchantRandomlyFunction
- All Implemented Interfaces:
BiFunction<ItemStack,
,LootContext, ItemStack> LootItemFunction
,LootContextUser
LootItemFunction that applies a random enchantment to the stack. If an empty list is given, chooses from all enchantments.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class net.minecraft.world.level.storage.loot.functions.LootItemConditionalFunction
LootItemConditionalFunction.DummyBuilder
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec
<EnchantRandomlyFunction> private static final org.slf4j.Logger
private final boolean
private final Optional
<HolderSet<Enchantment>> Fields inherited from class net.minecraft.world.level.storage.loot.functions.LootItemConditionalFunction
predicates
-
Constructor Summary
ConstructorsConstructorDescriptionEnchantRandomlyFunction
(List<LootItemCondition> conditons, Optional<HolderSet<Enchantment>> options, boolean onlyCompatible) -
Method Summary
Modifier and TypeMethodDescriptionprivate static ItemStack
enchantItem
(ItemStack stack, Holder<Enchantment> enchantment, RandomSource random) getType()
randomApplicableEnchantment
(HolderLookup.Provider registries) run
(ItemStack stack, LootContext context) Called to perform the actual action of this function, after conditions have been checked.Methods inherited from class net.minecraft.world.level.storage.loot.functions.LootItemConditionalFunction
apply, commonFields, simpleBuilder, validate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.function.BiFunction
andThen
Methods inherited from interface net.minecraft.world.level.storage.loot.LootContextUser
getReferencedContextParams
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
CODEC
-
options
-
onlyCompatible
private final boolean onlyCompatible
-
-
Constructor Details
-
EnchantRandomlyFunction
EnchantRandomlyFunction(List<LootItemCondition> conditons, Optional<HolderSet<Enchantment>> options, boolean onlyCompatible)
-
-
Method Details
-
getType
- Specified by:
getType
in interfaceLootItemFunction
- Specified by:
getType
in classLootItemConditionalFunction
-
run
Called to perform the actual action of this function, after conditions have been checked.- Specified by:
run
in classLootItemConditionalFunction
-
enchantItem
private static ItemStack enchantItem(ItemStack stack, Holder<Enchantment> enchantment, RandomSource random) -
randomEnchantment
-
randomApplicableEnchantment
public static EnchantRandomlyFunction.Builder randomApplicableEnchantment(HolderLookup.Provider registries)
-