Class LootContext
java.lang.Object
net.minecraft.world.level.storage.loot.LootContext
LootContext stores various context information for loot generation.
This includes the Level as well as any known
s.
invalid reference
LootContextParam
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic enumRepresents a type of entity that can be looked up in aLootContextusing a.invalid reference
LootContextParamstatic final record -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final HolderGetter.Providerprivate final LootParamsprivate @Nullable ResourceLocationprivate final RandomSourceprivate final Set<LootContext.VisitedEntry<?>> -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)LootContext(LootParams params, RandomSource random, HolderGetter.Provider lootDataResolver) privateLootContext(LootParams params, RandomSource random, HolderGetter.Provider lootDataResolver, ResourceLocation queriedLootTableId) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDynamicDrops(ResourceLocation name, Consumer<ItemStack> consumer) Add the dynamic drops for the given dynamic drops name to the given consumer.createVisitedEntry(LootItemFunction modifier) static LootContext.VisitedEntry<LootTable> createVisitedEntry(LootTable lootTable) createVisitedEntry(LootItemCondition predicate) getLevel()floatgetLuck()<T> TgetOptionalParameter(ContextKey<T> parameter) <T> TgetParameter(ContextKey<T> parameter) booleanhasParameter(ContextKey<?> parameter) booleanhasVisitedElement(LootContext.VisitedEntry<?> element) voidpopVisitedElement(LootContext.VisitedEntry<?> element) booleanpushVisitedElement(LootContext.VisitedEntry<?> element) voidsetQueriedLootTableId(@Nullable ResourceLocation queriedLootTableId)
-
Field Details
-
params
-
random
-
lootDataResolver
-
visitedElements
-
queriedLootTableId
-
-
Constructor Details
-
LootContext
LootContext(LootParams params, RandomSource random, HolderGetter.Provider lootDataResolver) -
LootContext
private LootContext(LootParams params, RandomSource random, HolderGetter.Provider lootDataResolver, ResourceLocation queriedLootTableId)
-
-
Method Details
-
hasParameter
-
getParameter
-
getOptionalParameter
-
addDynamicDrops
Add the dynamic drops for the given dynamic drops name to the given consumer. If no dynamic drops provider for the given name has been registered to this LootContext, nothing is generated.- See Also:
-
hasVisitedElement
-
pushVisitedElement
-
popVisitedElement
-
getResolver
-
getRandom
-
getLuck
public float getLuck() -
getLevel
-
createVisitedEntry
-
createVisitedEntry
public static LootContext.VisitedEntry<LootItemCondition> createVisitedEntry(LootItemCondition predicate) -
createVisitedEntry
public static LootContext.VisitedEntry<LootItemFunction> createVisitedEntry(LootItemFunction modifier) -
setQueriedLootTableId
-
getQueriedLootTableId
-