Class ConfiguredModel.Builder<T>
- java.lang.Object
-
- net.minecraftforge.client.model.generators.ConfiguredModel.Builder<T>
-
- Type Parameters:
T
- the type of the owning builder, which supplied the callback, and will be returned upon completion.
- Enclosing class:
- ConfiguredModel
public static class ConfiguredModel.Builder<T> extends java.lang.Object
A builder forConfiguredModel
s, which can contain a callback for processing the finished result. If no callback is available (e.g. in the case ofConfiguredModel.builder()
), some methods will not be available.Multiple models can be configured at once through the use of
nextModel()
.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.function.Function<ConfiguredModel[],T>
callback
private ModelFile
model
private java.util.List<ConfiguredModel>
otherModels
private int
rotationX
private int
rotationY
private boolean
uvLock
private int
weight
-
Constructor Summary
Constructors Constructor Description Builder()
Builder(java.util.function.Function<ConfiguredModel[],T> callback, java.util.List<ConfiguredModel> otherModels)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
addModel()
Apply the contained callback and return the owning builder object.ConfiguredModel[]
build()
Build all configured models and return them as an array.ConfiguredModel
buildLast()
Build the most recent model, as ifnextModel()
was never called.ConfiguredModel.Builder<T>
modelFile(ModelFile model)
Set the underlying model object for this configured model.ConfiguredModel.Builder<T>
nextModel()
Complete the current model and return a new builder instance with the same callback, and storing all previously built models.ConfiguredModel.Builder<T>
rotationX(int value)
Set the x-rotation for this model.ConfiguredModel.Builder<T>
rotationY(int value)
Set the y-rotation for this model.ConfiguredModel.Builder<T>
uvLock(boolean value)
ConfiguredModel.Builder<T>
weight(int value)
Set the random weight for this model.
-
-
-
Field Detail
-
model
private ModelFile model
-
callback
@Nullable private final java.util.function.Function<ConfiguredModel[],T> callback
-
otherModels
private final java.util.List<ConfiguredModel> otherModels
-
rotationX
private int rotationX
-
rotationY
private int rotationY
-
uvLock
private boolean uvLock
-
weight
private int weight
-
-
Constructor Detail
-
Builder
Builder()
-
Builder
Builder(@Nullable java.util.function.Function<ConfiguredModel[],T> callback, java.util.List<ConfiguredModel> otherModels)
-
-
Method Detail
-
modelFile
public ConfiguredModel.Builder<T> modelFile(ModelFile model)
Set the underlying model object for this configured model.- Parameters:
model
- the model- Returns:
- this builder
- Throws:
java.lang.NullPointerException
- ifmodel
isnull
-
rotationX
public ConfiguredModel.Builder<T> rotationX(int value)
Set the x-rotation for this model.- Parameters:
value
- the x-rotation value- Returns:
- this builder
- Throws:
java.lang.IllegalArgumentException
- ifvalue
is not a valid x-rotation (seeModelRotation
)
-
rotationY
public ConfiguredModel.Builder<T> rotationY(int value)
Set the y-rotation for this model.- Parameters:
value
- the y-rotation value- Returns:
- this builder
- Throws:
java.lang.IllegalArgumentException
- ifvalue
is not a valid y-rotation (seeModelRotation
)
-
uvLock
public ConfiguredModel.Builder<T> uvLock(boolean value)
-
weight
public ConfiguredModel.Builder<T> weight(int value)
Set the random weight for this model.- Parameters:
value
- the weight value- Returns:
- this builder
- Throws:
java.lang.IllegalArgumentException
- ifvalue
is less than or equal to zero
-
buildLast
public ConfiguredModel buildLast()
Build the most recent model, as ifnextModel()
was never called. Useful for single-model builders.- Returns:
- the most recently configured model
-
build
public ConfiguredModel[] build()
Build all configured models and return them as an array.- Returns:
- the array of built models.
-
addModel
public T addModel()
Apply the contained callback and return the owning builder object. What the callback does is not defined by this class, but most likely it adds the built models to the current variant being configured.Known callbacks include:
- Returns:
- the owning builder object
- Throws:
java.lang.NullPointerException
- if there is no owning builder (and thus no callback)
-
nextModel
public ConfiguredModel.Builder<T> nextModel()
Complete the current model and return a new builder instance with the same callback, and storing all previously built models.- Returns:
- a new builder for configuring the next model
-
-