Class ModelBuilder<T extends ModelBuilder<T>>
- java.lang.Object
-
- net.minecraftforge.client.model.generators.ModelFile
-
- net.minecraftforge.client.model.generators.ModelBuilder<T>
-
- Type Parameters:
T
- Self type, for simpler chaining of methods.
- Direct Known Subclasses:
BlockModelBuilder
,ItemModelBuilder
public class ModelBuilder<T extends ModelBuilder<T>> extends ModelFile
General purpose model builder, contains all the commonalities between item and block models.- See Also:
ModelProvider
,BlockModelBuilder
,ItemModelBuilder
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
ModelBuilder.ElementBuilder
static class
ModelBuilder.FaceRotation
static class
ModelBuilder.Perspective
class
ModelBuilder.TransformsBuilder
-
Nested classes/interfaces inherited from class net.minecraftforge.client.model.generators.ModelFile
ModelFile.ExistingModelFile, ModelFile.UncheckedModelFile
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
ambientOcclusion
protected CustomLoaderBuilder
customLoader
protected java.util.List<ModelBuilder.ElementBuilder>
elements
protected ExistingFileHelper
existingFileHelper
protected BlockModel.GuiLight
guiLight
protected ModelFile
parent
protected java.util.Map<java.lang.String,java.lang.String>
textures
protected ModelBuilder.TransformsBuilder
transforms
-
Constructor Summary
Constructors Modifier Constructor Description protected
ModelBuilder(ResourceLocation outputLocation, ExistingFileHelper existingFileHelper)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description T
ao(boolean ao)
<L extends CustomLoaderBuilder<T>>
LcustomLoader(java.util.function.BiFunction<T,ExistingFileHelper,L> customLoaderFactory)
Use a custom loader instead of the vanilla elements.ModelBuilder.ElementBuilder
element()
ModelBuilder.ElementBuilder
element(int index)
Get an existing element builderprotected boolean
exists()
int
getElementCount()
Gets the number of elements in this model builderT
gui3d(boolean gui3d)
Deprecated.Unused in 1.15, useguiLight(GuiLight)
instead.T
guiLight(BlockModel.GuiLight light)
T
parent(ModelFile parent)
Set the parent model for the current model.private T
self()
private java.lang.Number
serializeFloat(float f)
private java.lang.String
serializeLocOrKey(java.lang.String tex)
private com.google.gson.JsonArray
serializeVector3f(Vector3f vec)
T
texture(java.lang.String key, java.lang.String texture)
Set the texture for a given dictionary key.T
texture(java.lang.String key, ResourceLocation texture)
Set the texture for a given dictionary key.com.google.gson.JsonObject
toJson()
ModelBuilder.TransformsBuilder
transforms()
-
Methods inherited from class net.minecraftforge.client.model.generators.ModelFile
assertExistence, getLocation, getUncheckedLocation
-
-
-
-
Field Detail
-
parent
@Nullable protected ModelFile parent
-
textures
protected final java.util.Map<java.lang.String,java.lang.String> textures
-
transforms
protected final ModelBuilder.TransformsBuilder transforms
-
existingFileHelper
protected final ExistingFileHelper existingFileHelper
-
ambientOcclusion
protected boolean ambientOcclusion
-
guiLight
protected BlockModel.GuiLight guiLight
-
elements
protected final java.util.List<ModelBuilder.ElementBuilder> elements
-
customLoader
protected CustomLoaderBuilder customLoader
-
-
Constructor Detail
-
ModelBuilder
protected ModelBuilder(ResourceLocation outputLocation, ExistingFileHelper existingFileHelper)
-
-
Method Detail
-
self
private T self()
-
parent
public T parent(ModelFile parent)
Set the parent model for the current model.- Parameters:
parent
- the parent model- Returns:
- this builder
- Throws:
java.lang.NullPointerException
- ifparent
isnull
java.lang.IllegalStateException
- ifparent
does notexist
-
texture
public T texture(java.lang.String key, java.lang.String texture)
Set the texture for a given dictionary key.- Parameters:
key
- the texture keytexture
- the texture, can be another key e.g."#all"
- Returns:
- this builder
- Throws:
java.lang.NullPointerException
- ifkey
isnull
java.lang.NullPointerException
- iftexture
isnull
java.lang.IllegalStateException
- iftexture
is not a key (does not start with'#'
) and does not exist in any known resource pack
-
texture
public T texture(java.lang.String key, ResourceLocation texture)
Set the texture for a given dictionary key.- Parameters:
key
- the texture keytexture
- the texture- Returns:
- this builder
- Throws:
java.lang.NullPointerException
- ifkey
isnull
java.lang.NullPointerException
- iftexture
isnull
java.lang.IllegalStateException
- iftexture
is not a key (does not start with'#'
) and does not exist in any known resource pack
-
transforms
public ModelBuilder.TransformsBuilder transforms()
-
ao
public T ao(boolean ao)
-
gui3d
@Deprecated public T gui3d(boolean gui3d)
Deprecated.Unused in 1.15, useguiLight(GuiLight)
instead.- Parameters:
gui3d
-- Returns:
- this builder
-
guiLight
public T guiLight(BlockModel.GuiLight light)
-
element
public ModelBuilder.ElementBuilder element()
-
element
public ModelBuilder.ElementBuilder element(int index)
Get an existing element builder- Parameters:
index
- the index of the existing element builder- Returns:
- the element builder
- Throws:
java.lang.IndexOutOfBoundsException
- if index is out of bounds
-
getElementCount
public int getElementCount()
Gets the number of elements in this model builder- Returns:
- the number of elements in this model builder
-
customLoader
public <L extends CustomLoaderBuilder<T>> L customLoader(java.util.function.BiFunction<T,ExistingFileHelper,L> customLoaderFactory)
Use a custom loader instead of the vanilla elements.- Parameters:
customLoaderFactory
-- Returns:
- the custom loader builder
-
toJson
public com.google.gson.JsonObject toJson()
-
serializeLocOrKey
private java.lang.String serializeLocOrKey(java.lang.String tex)
-
serializeVector3f
private com.google.gson.JsonArray serializeVector3f(Vector3f vec)
-
serializeFloat
private java.lang.Number serializeFloat(float f)
-
-