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 classModelBuilder.ElementBuilderstatic classModelBuilder.FaceRotationstatic classModelBuilder.PerspectiveclassModelBuilder.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 booleanambientOcclusionprotected CustomLoaderBuildercustomLoaderprotected java.util.List<ModelBuilder.ElementBuilder>elementsprotected ExistingFileHelperexistingFileHelperprotected BlockModel.GuiLightguiLightprotected ModelFileparentprotected java.util.Map<java.lang.String,java.lang.String>texturesprotected ModelBuilder.TransformsBuildertransforms
-
Constructor Summary
Constructors Modifier Constructor Description protectedModelBuilder(ResourceLocation outputLocation, ExistingFileHelper existingFileHelper)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Tao(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.ElementBuilderelement()ModelBuilder.ElementBuilderelement(int index)Get an existing element builderprotected booleanexists()intgetElementCount()Gets the number of elements in this model builderTgui3d(boolean gui3d)Deprecated.Unused in 1.15, useguiLight(GuiLight)instead.TguiLight(BlockModel.GuiLight light)Tparent(ModelFile parent)Set the parent model for the current model.private Tself()private java.lang.NumberserializeFloat(float f)private java.lang.StringserializeLocOrKey(java.lang.String tex)private com.google.gson.JsonArrayserializeVector3f(Vector3f vec)Ttexture(java.lang.String key, java.lang.String texture)Set the texture for a given dictionary key.Ttexture(java.lang.String key, ResourceLocation texture)Set the texture for a given dictionary key.com.google.gson.JsonObjecttoJson()ModelBuilder.TransformsBuildertransforms()-
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- ifparentisnulljava.lang.IllegalStateException- ifparentdoes 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- ifkeyisnulljava.lang.NullPointerException- iftextureisnulljava.lang.IllegalStateException- iftextureis 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- ifkeyisnulljava.lang.NullPointerException- iftextureisnulljava.lang.IllegalStateException- iftextureis 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)
-
-