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
LootContextParams.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic enumRepresents a type of entity that can be looked up in aLootContextusing aLootContextParam.static 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 pParams, RandomSource pRandom, HolderGetter.Provider pLootDataResolver) privateLootContext(LootParams pParams, RandomSource pRandom, HolderGetter.Provider pLootDataResolver, ResourceLocation queriedLootTableId) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDynamicDrops(ResourceLocation pName, Consumer<ItemStack> pConsumer) Add the dynamic drops for the given dynamic drops name to the given consumer.createVisitedEntry(LootItemFunction pModifier) static LootContext.VisitedEntry<LootTable> createVisitedEntry(LootTable pLootTable) createVisitedEntry(LootItemCondition pPredicate) getLevel()floatgetLuck()<T> TgetParam(LootContextParam<T> pParam) Get the value of the given parameter.<T> TgetParamOrNull(LootContextParam<T> pParameter) Get the value of the given parameter if it is present in this context, null otherwise.booleanhasParam(LootContextParam<?> pParameter) Check whether the given parameter is present in this context.booleanhasVisitedElement(LootContext.VisitedEntry<?> pElement) voidpopVisitedElement(LootContext.VisitedEntry<?> pElement) booleanpushVisitedElement(LootContext.VisitedEntry<?> pElement) voidsetQueriedLootTableId(@Nullable ResourceLocation queriedLootTableId)
-
Field Details
-
params
-
random
-
lootDataResolver
-
visitedElements
-
queriedLootTableId
-
-
Constructor Details
-
LootContext
LootContext(LootParams pParams, RandomSource pRandom, HolderGetter.Provider pLootDataResolver) -
LootContext
private LootContext(LootParams pParams, RandomSource pRandom, HolderGetter.Provider pLootDataResolver, ResourceLocation queriedLootTableId)
-
-
Method Details
-
hasParam
Check whether the given parameter is present in this context. -
getParam
Get the value of the given parameter. -
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:
-
getParamOrNull
Get the value of the given parameter if it is present in this context, null otherwise. -
hasVisitedElement
-
pushVisitedElement
-
popVisitedElement
-
getResolver
-
getRandom
-
getLuck
public float getLuck() -
getLevel
-
createVisitedEntry
-
createVisitedEntry
public static LootContext.VisitedEntry<LootItemCondition> createVisitedEntry(LootItemCondition pPredicate) -
createVisitedEntry
public static LootContext.VisitedEntry<LootItemFunction> createVisitedEntry(LootItemFunction pModifier) -
setQueriedLootTableId
-
getQueriedLootTableId
-