Class BuildableInteractionCondition
java.lang.Object
com.pixelmonmod.pixelmon.api.npc.interaction.condition.type.BuildableInteractionCondition
- All Implemented Interfaces:
InteractionCondition
An interaction condition that allows you to build it using a
builder pattern. This is useful for easily creating an interaction
condition without having to create a new class for it.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A builder class for creating a custom interaction conditionprotected static class
-
Field Summary
Modifier and TypeFieldDescriptionprotected final com.mojang.serialization.Codec<BuildableInteractionCondition>
protected final BiPredicate<InteractionContext,
VariableList> protected final List<BuildableInteractionCondition.Variable<?>>
Fields inherited from interface com.pixelmonmod.pixelmon.api.npc.interaction.condition.InteractionCondition
CODEC, DIRECT_CODEC
-
Constructor Summary
ModifierConstructorDescriptionprotected
protected
-
Method Summary
Modifier and TypeMethodDescriptionprotected BuildableInteractionCondition
builder()
Creates a new instance of the builder to create a custom interaction conditioncom.mojang.serialization.Codec<BuildableInteractionCondition>
codec()
Codec for decoding data about the interaction conditionfill
(ConditionData data) Fills the condition with the given databoolean
fits
(InteractionContext context) Method to check if the given context is correct for the conditionReturns the input types for the conditionnewInstance
(Object... variables) Creates a copy of this interaction condition with the given values set as the instances of the variables.protected <T> void
set
(BuildableInteractionCondition.Variable<T> variable, Object value) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.pixelmonmod.pixelmon.api.npc.interaction.condition.InteractionCondition
toData
-
Field Details
-
codec
-
test
-
variables
-
-
Constructor Details
-
BuildableInteractionCondition
-
BuildableInteractionCondition
-
-
Method Details
-
apply
-
set
-
codec
Description copied from interface:InteractionCondition
Codec for decoding data about the interaction condition- Specified by:
codec
in interfaceInteractionCondition
- Returns:
- The codec
-
fits
Description copied from interface:InteractionCondition
Method to check if the given context is correct for the condition- Specified by:
fits
in interfaceInteractionCondition
- Parameters:
context
- The context- Returns:
- True if the logic can proceed with the given context
-
inputTypes
Description copied from interface:InteractionCondition
Returns the input types for the condition- Specified by:
inputTypes
in interfaceInteractionCondition
- Returns:
- The input types
-
fill
Description copied from interface:InteractionCondition
Fills the condition with the given data- Specified by:
fill
in interfaceInteractionCondition
- Parameters:
data
- The data- Returns:
- The filled condition
-
newInstance
Creates a copy of this interaction condition with the given values set as the instances of the variables.
Notes:
- You must provide the correct amount of variables otherwise this will throw anIllegalArgumentException
.
- You must provide the variables in the same order as they were provided in the builder.
- You must provide the correct type of variables otherwise this will throw aClassCastException
.- Parameters:
variables
- The variables to set- Returns:
- The new instance of the interaction condition
-
builder
Creates a new instance of the builder to create a custom interaction condition- Returns:
- A new instance of the builder
-