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 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 BakedModel
bakeVanilla
(BlockModel blockModel, ModelBaker modelBaker, BlockModel owner, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelState, ResourceLocation modelLocation) Deprecated, for removal: This API element is subject to removal in a future version.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. -
bakeVanilla
@Internal @Deprecated(forRemoval=true, since="1.19.2") public static BakedModel bakeVanilla(BlockModel blockModel, ModelBaker modelBaker, BlockModel owner, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelState, ResourceLocation modelLocation) Deprecated, for removal: This API element is subject to removal in a future version.Merge into the method above in 1.20 once the call fromBlockModel
is gone.Helper for baking vanillaBlockModel
instances. -
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
.
-
BlockModel
is gone.