Class SetContainerLootTable
java.lang.Object
net.minecraft.world.level.storage.loot.functions.LootItemConditionalFunction
net.minecraft.world.level.storage.loot.functions.SetContainerLootTable
- All Implemented Interfaces:
BiFunction<ItemStack, LootContext, ItemStack>, LootItemFunction, LootContextUser, Validatable
LootItemFunction that sets the LootTable and optionally the loot table seed on the stack's
BlockEntityTag. The effect of this is that containers such as chests will receive the given LootTable when placed.-
Nested Class Summary
Nested classes/interfaces inherited from class LootItemConditionalFunction
LootItemConditionalFunction.Builder<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<SetContainerLootTable> private final ResourceKey<LootTable> private final longprivate final Holder<BlockEntityType<?>> Fields inherited from class LootItemConditionalFunction
predicates -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateSetContainerLootTable(List<LootItemCondition> predicates, ResourceKey<LootTable> name, long seed, Holder<BlockEntityType<?>> type) -
Method Summary
Modifier and TypeMethodDescriptioncom.mojang.serialization.MapCodec<SetContainerLootTable> codec()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.static LootItemConditionalFunction.Builder<?> withLootTable(BlockEntityType<?> type, ResourceKey<LootTable> value) static LootItemConditionalFunction.Builder<?> withLootTable(BlockEntityType<?> type, ResourceKey<LootTable> value, long seed) 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
-
MAP_CODEC
-
name
-
seed
private final long seed -
type
-
-
Constructor Details
-
SetContainerLootTable
private SetContainerLootTable(List<LootItemCondition> predicates, ResourceKey<LootTable> name, long seed, Holder<BlockEntityType<?>> type)
-
-
Method Details
-
codec
- Specified by:
codecin interfaceLootItemFunction- Specified by:
codecin classLootItemConditionalFunction
-
run
Description copied from class:LootItemConditionalFunctionCalled to perform the actual action of this function, after conditions have been checked.- Specified by:
runin 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
-
withLootTable
public static LootItemConditionalFunction.Builder<?> withLootTable(BlockEntityType<?> type, ResourceKey<LootTable> value) -
withLootTable
public static LootItemConditionalFunction.Builder<?> withLootTable(BlockEntityType<?> type, ResourceKey<LootTable> value, long seed)
-