Class SetNameFunction
java.lang.Object
net.minecraft.world.level.storage.loot.functions.LootItemConditionalFunction
net.minecraft.world.level.storage.loot.functions.SetNameFunction
- All Implemented Interfaces:
BiFunction<ItemStack,
,LootContext, ItemStack> LootItemFunction
,LootContextUser
LootItemFunction that sets a stack's name.
The Component for the name is optionally resolved relative to a given
LootContext.EntityTarget
for entity-sensitive component data such as scoreboard scores.-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class net.minecraft.world.level.storage.loot.functions.LootItemConditionalFunction
LootItemConditionalFunction.Builder<T extends LootItemConditionalFunction.Builder<T>>, LootItemConditionalFunction.DummyBuilder
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec
<SetNameFunction> private static final org.slf4j.Logger
private final Optional
<LootContext.EntityTarget> private final SetNameFunction.Target
Fields inherited from class net.minecraft.world.level.storage.loot.functions.LootItemConditionalFunction
predicates
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
SetNameFunction
(List<LootItemCondition> p_299241_, Optional<Component> p_298804_, Optional<LootContext.EntityTarget> p_298545_, SetNameFunction.Target p_338830_) -
Method Summary
Modifier and TypeMethodDescriptionstatic UnaryOperator
<Component> createResolver
(LootContext pLootContext, LootContext.EntityTarget pResolutionContext) Create a UnaryOperator that resolves Components based on the given LootContext and EntityTarget.Set
<LootContextParam<?>> getType()
run
(ItemStack pStack, LootContext pContext) Called to perform the actual action of this function, after conditions have been checked.static LootItemConditionalFunction.Builder
<?> setName
(Component pName, SetNameFunction.Target pTarget) static LootItemConditionalFunction.Builder
<?> setName
(Component pName, SetNameFunction.Target pTarget, LootContext.EntityTarget pResolutionContext) 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
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
CODEC
-
name
-
resolutionContext
-
target
-
-
Constructor Details
-
SetNameFunction
private SetNameFunction(List<LootItemCondition> p_299241_, Optional<Component> p_298804_, Optional<LootContext.EntityTarget> p_298545_, SetNameFunction.Target p_338830_)
-
-
Method Details
-
getType
- Specified by:
getType
in interfaceLootItemFunction
- Specified by:
getType
in classLootItemConditionalFunction
-
getReferencedContextParams
-
createResolver
public static UnaryOperator<Component> createResolver(LootContext pLootContext, @Nullable LootContext.EntityTarget pResolutionContext) Create a UnaryOperator that resolves Components based on the given LootContext and EntityTarget. This will replace for example score components. -
run
Called to perform the actual action of this function, after conditions have been checked.- Specified by:
run
in classLootItemConditionalFunction
-
setName
public static LootItemConditionalFunction.Builder<?> setName(Component pName, SetNameFunction.Target pTarget) -
setName
public static LootItemConditionalFunction.Builder<?> setName(Component pName, SetNameFunction.Target pTarget, LootContext.EntityTarget pResolutionContext)
-