Class InteractionContext
java.lang.Object
com.pixelmonmod.pixelmon.api.npc.interaction.context.InteractionContext
Interaction context is the information that will be passed
down the control logic of the NPC interaction handling as it
checks against conditions, and then goes on to execute additional
functions.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescription<A> Optional<A>
getContext
(ContextKey<A> key) Gets the value stored by a given context key for this interaction contextClass<?>
getContextType
(net.minecraft.resources.ResourceLocation key) Gets the type of the context stored by the given key
This will return null if the key is not found in the context<A> A
getNullableContext
(ContextKey<A> key) Gets the value stored by a given context key for this interaction contextboolean
hasContext
(ContextKey<?> key) Checks if the context has the given keyboolean
hasContext
(net.minecraft.resources.ResourceLocation key) Checks if the context has the given keystatic InteractionContext
of()
Gets an instance of a new Interaction contextstatic <A> InteractionContext
of
(ContextKey<A> key, A value) Gets an instance of a mew Interaction context with the key and value set alreadyHandles the replacement of the placeholders in the textsetContext
(ContextKey<A> key, A value) Sets the context key with the given valuewithPlayer
(net.minecraft.server.level.ServerPlayer player) Adds the generic contexts for the player
-
Method Details
-
of
Gets an instance of a new Interaction context- Returns:
- new interaction context
-
of
Gets an instance of a mew Interaction context with the key and value set already- Returns:
- new interaction context
-
setContext
Sets the context key with the given value- Type Parameters:
A
- The type of the key and value- Parameters:
key
- The keyvalue
- The value being set- Returns:
- The context instance
-
withPlayer
Adds the generic contexts for the player- Parameters:
player
- The player for adding the generic contexts- Returns:
- The context instance
-
getContext
Gets the value stored by a given context key for this interaction context- Type Parameters:
A
- The type of the key and value- Parameters:
key
- The key to check for- Returns:
- The potential value stored
-
getNullableContext
Gets the value stored by a given context key for this interaction context- Type Parameters:
A
- The type of the key and value- Parameters:
key
- The key to check for- Returns:
- The potential value stored
-
hasContext
public boolean hasContext(net.minecraft.resources.ResourceLocation key) Checks if the context has the given key- Parameters:
key
- The key to check for- Returns:
- If the context has the key
-
hasContext
Checks if the context has the given key- Parameters:
key
- The key to check for- Returns:
- If the context has the key
-
getContextType
Gets the type of the context stored by the given key
This will return null if the key is not found in the context- Parameters:
key
- The key to check for- Returns:
- The type of the context key
-
replace
Handles the replacement of the placeholders in the text- Parameters:
originalText
- The text to replace- Returns:
- The text with the placeholders replaced
-