Class StrictStoredContext
java.lang.Object
com.pixelmonmod.pixelmon.api.context.StoredContext
com.pixelmonmod.pixelmon.api.context.StrictStoredContext
This is a "strict" implementation of
This is only intended to be used internally for code usages of context. For example, the battle engine.
Whereas, the
StoredContext
that only allows
immutable context keys to be set and retrieved.
This is only intended to be used internally for code usages of context. For example, the battle engine.
Whereas, the
StoredContext
is intended to be used for the public facing API, and pipelines such as the NPC and Research
pipelines where a user might want to set a context key that is mutable, or that is not registered in the code.-
Method Summary
Modifier and TypeMethodDescription<A> Optional
<A> getContext
(ContextKey<A> key) Gets the value stored by a given context key for this stored context<A> Optional
<A> getContext
(net.minecraft.resources.ResourceLocation key) Gets the value stored by a given context key for this stored context<A> A
getNullableContext
(ContextKey<A> key) Gets the value stored by a given context key for this stored context<A> A
getNullableContext
(net.minecraft.resources.ResourceLocation key) Gets the value stored by a given context key for this stored context<A> StoredContext
setContext
(ContextKey<A> key, A value) Sets the context key with the given value<A> StoredContext
setContext
(net.minecraft.resources.ResourceLocation key, A value) Sets the context key with the given valuewithPlayer
(net.minecraft.server.level.ServerPlayer player) Adds the generic contexts for the playerMethods inherited from class com.pixelmonmod.pixelmon.api.context.StoredContext
copy, getContextType, hasContext, hasContext, of, of, replace, strict, strict
-
Method Details
-
setContext
Description copied from class:StoredContext
Sets the context key with the given value- Overrides:
setContext
in classStoredContext
- Type Parameters:
A
- The type of the key and value- Parameters:
key
- The keyvalue
- The value being set- Returns:
- The context instance
-
getNullableContext
Description copied from class:StoredContext
Gets the value stored by a given context key for this stored context- Overrides:
getNullableContext
in classStoredContext
- Type Parameters:
A
- The type of the key and value- Parameters:
key
- The key to check for- Returns:
- The potential value stored
-
getContext
Description copied from class:StoredContext
Gets the value stored by a given context key for this stored context- Overrides:
getContext
in classStoredContext
- Type Parameters:
A
- The type of the key and value- Parameters:
key
- The key to check for- Returns:
- The potential value stored
-
withPlayer
Description copied from class:StoredContext
Adds the generic contexts for the player- Overrides:
withPlayer
in classStoredContext
- Parameters:
player
- The player for adding the generic contexts- Returns:
- The context instance
-
setContext
public <A> StoredContext setContext(net.minecraft.resources.ResourceLocation key, @Nullable A value) Description copied from class:StoredContext
Sets the context key with the given value- Overrides:
setContext
in classStoredContext
- Type Parameters:
A
- The type of the key and value- Parameters:
key
- The keyvalue
- The value being set- Returns:
- The context instance
-
getNullableContext
@Nullable public <A> A getNullableContext(net.minecraft.resources.ResourceLocation key) Description copied from class:StoredContext
Gets the value stored by a given context key for this stored context- Overrides:
getNullableContext
in classStoredContext
- Type Parameters:
A
- The type of the key and value- Parameters:
key
- The key to check for- Returns:
- The potential value stored
-
getContext
Description copied from class:StoredContext
Gets the value stored by a given context key for this stored context- Overrides:
getContext
in classStoredContext
- Type Parameters:
A
- The type of the key and value- Parameters:
key
- The key to check for- Returns:
- The potential value stored
-