Class UnbakedGeometryHelper
java.lang.Object
net.neoforged.neoforge.client.model.geometry.UnbakedGeometryHelper
Helper for dealing with unbaked models and geometries.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final FaceBakeryprivate static final PatternExplanation: 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic IQuadTransformerapplyRootTransform(ModelState modelState, Transformation rootTransform) Create anIQuadTransformerto apply aTransformationthat undoes theModelStatetransform (blockstate transform), applies the given root transform and then re-applies the blockstate transform.static BakedModelbake(BlockModel blockModel, ModelBaker modelBaker, BlockModel owner, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelState, boolean guiLight3d) Helper for bakingBlockModelinstances.static BakedQuadbakeElementFace(BlockElement element, BlockElementFace face, TextureAtlasSprite sprite, Direction direction, ModelState state) Turns a singleBlockElementFaceinto aBakedQuad.bakeElements(List<BlockElement> elements, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelState) Bakes a list of block elements and returns the list of baked quads.static voidbakeElements(IModelBuilder<?> builder, List<BlockElement> elements, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelState) Bakes a list of block elements and feeds the baked quads to a model builder.static ModelStatecomposeRootTransformIntoModelState(ModelState modelState, Transformation rootTransform) Returns aModelStatethat combines the existing model state and the root transform.static List<BlockElement> createUnbakedItemElements(int layerIndex, TextureAtlasSprite sprite) static List<BlockElement> createUnbakedItemElements(int layerIndex, TextureAtlasSprite sprite, @Nullable ExtraFaceData faceData) Creates a list of block elements in the shape of the specified sprite contents.static List<BlockElement> createUnbakedItemMaskElements(int layerIndex, TextureAtlasSprite sprite) static List<BlockElement> createUnbakedItemMaskElements(int layerIndex, TextureAtlasSprite sprite, @Nullable ExtraFaceData faceData) Creates a list of block elements in the shape of the specified sprite contents.static MaterialresolveDirtyMaterial(@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, boolean guiLight3d) Helper for bakingBlockModelinstances. Handles baking custom geometries and deferring item model baking. -
createUnbakedItemElements
public static List<BlockElement> createUnbakedItemElements(int layerIndex, TextureAtlasSprite sprite) - See Also:
-
createUnbakedItemElements
public static List<BlockElement> createUnbakedItemElements(int layerIndex, TextureAtlasSprite sprite, @Nullable @Nullable ExtraFaceData 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.NORTHandDirection.SOUTHfaces take up the whole surface. -
createUnbakedItemMaskElements
public static List<BlockElement> createUnbakedItemMaskElements(int layerIndex, TextureAtlasSprite sprite) - See Also:
-
createUnbakedItemMaskElements
public static List<BlockElement> createUnbakedItemMaskElements(int layerIndex, TextureAtlasSprite sprite, @Nullable @Nullable ExtraFaceData 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.NORTHandDirection.SOUTHfaces take up only the pixels the texture uses. -
bakeElements
public static void bakeElements(IModelBuilder<?> builder, List<BlockElement> elements, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelState) 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) 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) Turns a singleBlockElementFaceinto aBakedQuad. -
applyRootTransform
public static IQuadTransformer applyRootTransform(ModelState modelState, Transformation rootTransform) Create anIQuadTransformerto apply aTransformationthat undoes theModelStatetransform (blockstate transform), applies the given root transform and then re-applies the blockstate transform.- Returns:
- an
IQuadTransformerthat applies the root transform to a baked quad that already has the transformation of the givenModelStateapplied to it
-
composeRootTransformIntoModelState
public static ModelState composeRootTransformIntoModelState(ModelState modelState, Transformation rootTransform) Returns aModelStatethat combines the existing model state and the root transform.- Returns:
- a
ModelStatethat combines the existing model state and the root transform
-