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
ContextKeys.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic classstatic enumRepresents a type of entity that can be looked up in aLootContextusing aContextKey.static enumstatic final record -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final HolderGetter.Providerprivate final LootParamsprivate @Nullable Identifierprivate 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, Identifier queriedLootTableId) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDynamicDrops(Identifier 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> @Nullable 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 Identifier 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, Identifier 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
-