Class UnbakedGeometryHelper
java.lang.Object
net.minecraftforge.client.model.geometry.UnbakedGeometryHelper
Helper for dealing with unbaked models and geometries.
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final FaceBakery
private static final Pattern
Explanation: This takes anything that looks like a valid resourcepack texture location, and tries to extract a resourcelocation out of it.private static final ItemModelGenerator
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic IQuadTransformer
applyRootTransform
(ModelState modelState, Transformation rootTransform) Create anIQuadTransformer
to apply aTransformation
that undoes theModelState
transform (blockstate transform), applies the given root transform and then re-applies the blockstate transform.static BakedModel
bake
(BlockModel blockModel, ModelBaker modelBaker, BlockModel owner, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelState, ResourceLocation modelLocation, boolean guiLight3d) Helper for bakingBlockModel
instances.static BakedQuad
bakeElementFace
(BlockElement element, BlockElementFace face, TextureAtlasSprite sprite, Direction direction, ModelState state, ResourceLocation modelLocation) Turns a singleBlockElementFace
into aBakedQuad
.bakeElements
(List<BlockElement> elements, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelState, ResourceLocation modelLocation) Bakes a list of block elements and returns the list of baked quads.static void
bakeElements
(IModelBuilder<?> builder, List<BlockElement> elements, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelState, ResourceLocation modelLocation) Bakes a list of block elements and feeds the baked quads to a model builder.static ModelState
composeRootTransformIntoModelState
(ModelState modelState, Transformation rootTransform) Returns aModelState
that combines the existing model state and the root transform.static List<BlockElement>
createUnbakedItemElements
(int layerIndex, SpriteContents spriteContents) static List<BlockElement>
createUnbakedItemElements
(int layerIndex, SpriteContents spriteContents, @Nullable ForgeFaceData faceData) Creates a list of block elements in the shape of the specified sprite contents.static List<BlockElement>
createUnbakedItemMaskElements
(int layerIndex, SpriteContents spriteContents) static List<BlockElement>
createUnbakedItemMaskElements
(int layerIndex, SpriteContents spriteContents, @Nullable ForgeFaceData faceData) Creates a list of block elements in the shape of the specified sprite contents.static Material
resolveDirtyMaterial
(@Nullable String tex, IGeometryBakingContext owner) Resolves a material that may have been defined with a filesystem path instead of a properResourceLocation
.
-
Field Details
-
ITEM_MODEL_GENERATOR
-
FACE_BAKERY
-
FILESYSTEM_PATH_TO_RESLOC
Explanation: This takes anything that looks like a valid resourcepack texture location, and tries to extract a resourcelocation out of it. 1. it will ignore anything up to and including an /assets/ folder, 2. it will take the next path component as a namespace, 3. it will match but skip the /textures/ part of the path, 4. it will take the rest of the path up to but excluding the .png extension as the resource path It's a best-effort situation, to allow model files exported by modelling software to be used without post-processing. Example: C:\Something\Or Other\src\main\resources\assets\mymodid\textures\item\my_thing.png ........................................--------_______----------_____________----Result after replacing '\' to '/': mymodid:item/my_thing
-
-
Constructor Details
-
UnbakedGeometryHelper
public UnbakedGeometryHelper()
-
-
Method Details
-
resolveDirtyMaterial
public static Material resolveDirtyMaterial(@Nullable @Nullable String tex, IGeometryBakingContext owner) Resolves a material that may have been defined with a filesystem path instead of a properResourceLocation
.The target atlas will always be
TextureAtlas.LOCATION_BLOCKS
. -
bake
@Internal public static BakedModel bake(BlockModel blockModel, ModelBaker modelBaker, BlockModel owner, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelState, ResourceLocation modelLocation, boolean guiLight3d) Helper for bakingBlockModel
instances. Handles baking custom geometries and deferring item model baking. -
createUnbakedItemElements
public static List<BlockElement> createUnbakedItemElements(int layerIndex, SpriteContents spriteContents) -
createUnbakedItemElements
public static List<BlockElement> createUnbakedItemElements(int layerIndex, SpriteContents spriteContents, @Nullable @Nullable ForgeFaceData faceData) Creates a list of block elements in the shape of the specified sprite contents. These can later be baked using the same, or another texture.The
Direction.NORTH
andDirection.SOUTH
faces take up the whole surface. -
createUnbakedItemMaskElements
public static List<BlockElement> createUnbakedItemMaskElements(int layerIndex, SpriteContents spriteContents) -
createUnbakedItemMaskElements
public static List<BlockElement> createUnbakedItemMaskElements(int layerIndex, SpriteContents spriteContents, @Nullable @Nullable ForgeFaceData faceData) Creates a list of block elements in the shape of the specified sprite contents. These can later be baked using the same, or another texture.The
Direction.NORTH
andDirection.SOUTH
faces take up only the pixels the texture uses. -
bakeElements
public static void bakeElements(IModelBuilder<?> builder, List<BlockElement> elements, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelState, ResourceLocation modelLocation) Bakes a list of block elements and feeds the baked quads to a model builder. -
bakeElements
public static List<BakedQuad> bakeElements(List<BlockElement> elements, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelState, ResourceLocation modelLocation) Bakes a list of block elements and returns the list of baked quads. -
bakeElementFace
public static BakedQuad bakeElementFace(BlockElement element, BlockElementFace face, TextureAtlasSprite sprite, Direction direction, ModelState state, ResourceLocation modelLocation) Turns a singleBlockElementFace
into aBakedQuad
. -
applyRootTransform
public static IQuadTransformer applyRootTransform(ModelState modelState, Transformation rootTransform) Create anIQuadTransformer
to apply aTransformation
that undoes theModelState
transform (blockstate transform), applies the given root transform and then re-applies the blockstate transform.- Returns:
- an
IQuadTransformer
that applies the root transform to a baked quad that already has the transformation of the givenModelState
applied to it
-
composeRootTransformIntoModelState
public static ModelState composeRootTransformIntoModelState(ModelState modelState, Transformation rootTransform) Returns aModelState
that combines the existing model state and the root transform.- Returns:
- a
ModelState
that combines the existing model state and the root transform
-