Class BuildableDataProvider.Builder<T>
java.lang.Object
com.pixelmonmod.pixelmon.api.npc.interaction.provider.type.BuildableDataProvider.Builder<T>
- Type Parameters:
T
- The type of the data provider
- Enclosing class:
- BuildableDataProvider<T>
A builder class for creating a custom data provider
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Creates the data provider
If the converter is null, this will throw anIllegalStateException
converter
(BiFunction<InteractionContext, VariableList, T> converter) Sets the converter for the data provider
This cannot be null<A,
B extends DataProvider<A>>
BuildableDataProvider.Builder<T>dataProvider
(String name, net.minecraft.network.chat.Component label, Class<A> type, com.mojang.serialization.Codec<B> provider, B defaultValue) Gives aDataProvider
variable to the data provider.protected <A> InputElementType<InputType<A>>
variable
(String name, net.minecraft.network.chat.Component label, A defaultValue, com.mojang.serialization.Codec<A> codec) Gives a variable to the data provider.
-
Constructor Details
-
Builder
protected Builder()
-
-
Method Details
-
variable
public <A> BuildableDataProvider.Builder<T> variable(String name, net.minecraft.network.chat.Component label, A defaultValue, com.mojang.serialization.Codec<A> codec) Gives a variable to the data provider.
Note: You cannot provideDataProvider
variables using this method and must instead use thedataProvider(String, Component, Class, Codec, DataProvider)
method otherwise you will get anUnsupportedOperationException
.- Type Parameters:
A
- The type of the variable- Parameters:
name
- The name of the variablelabel
- The label of the variabledefaultValue
- The default value of the variablecodec
- The codec of the variable- Returns:
- The builder
-
inputType
-
dataProvider
public <A,B extends DataProvider<A>> BuildableDataProvider.Builder<T> dataProvider(String name, net.minecraft.network.chat.Component label, Class<A> type, com.mojang.serialization.Codec<B> provider, B defaultValue) Gives aDataProvider
variable to the data provider.
Note: You cannot provide non-DataProvider
variables using this and must instead use thevariable(String, Component, Object, Codec)
method.- Type Parameters:
A
- The type of the variableB
- The type of the provider- Parameters:
name
- The label of the variablelabel
- The label of the variabletype
- The type of the variableprovider
- The provider of the variable- Returns:
- The builder
-
converter
public BuildableDataProvider.Builder<T> converter(BiFunction<InteractionContext, VariableList, T> converter) Sets the converter for the data provider
This cannot be null- Parameters:
converter
- The test for the data provider- Returns:
- The builder
-
build
Creates the data provider
If the converter is null, this will throw anIllegalStateException
- Returns:
- The data provider
-