Class SetItemDamageFunction
java.lang.Object
net.minecraft.world.level.storage.loot.functions.LootItemConditionalFunction
net.minecraft.world.level.storage.loot.functions.SetItemDamageFunction
- All Implemented Interfaces:
BiFunction<ItemStack, LootContext, ItemStack>, LootItemFunction, LootContextUser, Validatable
LootItemFunction that sets the stack's damage based on a
NumberProvider, optionally adding to any existing damage.-
Nested Class Summary
Nested classes/interfaces inherited from class LootItemConditionalFunction
LootItemConditionalFunction.Builder<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanprivate final NumberProviderprivate static final org.slf4j.Loggerstatic final com.mojang.serialization.MapCodec<SetItemDamageFunction> Fields inherited from class LootItemConditionalFunction
predicates -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateSetItemDamageFunction(List<LootItemCondition> predicates, NumberProvider damage, boolean add) -
Method Summary
Modifier and TypeMethodDescriptioncom.mojang.serialization.MapCodec<SetItemDamageFunction> codec()run(ItemStack itemStack, LootContext context) Called to perform the actual action of this function, after conditions have been checked.static LootItemConditionalFunction.Builder<?> setDamage(NumberProvider value) static LootItemConditionalFunction.Builder<?> setDamage(NumberProvider value, boolean add) 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
andThenMethods inherited from interface LootContextUser
getReferencedContextParams
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
MAP_CODEC
-
damage
-
add
private final boolean add
-
-
Constructor Details
-
SetItemDamageFunction
private SetItemDamageFunction(List<LootItemCondition> predicates, NumberProvider damage, boolean add)
-
-
Method Details
-
codec
- Specified by:
codecin interfaceLootItemFunction- Specified by:
codecin classLootItemConditionalFunction
-
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
-
setDamage
-
setDamage
-