Class ModelHelper

java.lang.Object
net.fabricmc.fabric.api.renderer.v1.model.ModelHelper

public final class ModelHelper extends Object
Collection of utilities for model implementations.
  • Field Details

    • NULL_FACE_ID

      public static final int NULL_FACE_ID
      Result from toFaceIndex(Direction) for null values.
      See Also:
    • TRANSFORM_BLOCK_GUI

      public static final Transformation TRANSFORM_BLOCK_GUI
    • TRANSFORM_BLOCK_GROUND

      public static final Transformation TRANSFORM_BLOCK_GROUND
    • TRANSFORM_BLOCK_FIXED

      public static final Transformation TRANSFORM_BLOCK_FIXED
    • TRANSFORM_BLOCK_3RD_PERSON_RIGHT

      public static final Transformation TRANSFORM_BLOCK_3RD_PERSON_RIGHT
    • TRANSFORM_BLOCK_1ST_PERSON_RIGHT

      public static final Transformation TRANSFORM_BLOCK_1ST_PERSON_RIGHT
    • TRANSFORM_BLOCK_1ST_PERSON_LEFT

      public static final Transformation TRANSFORM_BLOCK_1ST_PERSON_LEFT
    • MODEL_TRANSFORM_BLOCK

      public static final ModelTransformation MODEL_TRANSFORM_BLOCK
      Mimics the vanilla model transformation used for most vanilla blocks, and should be suitable for most custom block-like models.
  • Method Details

    • toFaceIndex

      public static int toFaceIndex(@Nullable @Nullable Direction face)
      Convenient way to encode faces that may be null. Null is returned as NULL_FACE_ID. Use faceFromIndex(int) to retrieve encoded face.
    • faceFromIndex

      @Nullable public static @Nullable Direction faceFromIndex(int faceIndex)
      Use to decode a result from toFaceIndex(Direction). Return value will be null if encoded value was null. Can also be used for no-allocation iteration of Direction.values(), optionally including the null face. (Use < or <= NULL_FACE_ID to exclude or include the null value, respectively.)
    • toQuadLists

      public static List<BakedQuad>[] toQuadLists(Mesh mesh)
      Converts a mesh into an array of lists of vanilla baked quads. Useful for creating vanilla baked models when required for compatibility. The array indexes correspond to Direction.getId() with the addition of NULL_FACE_ID.

      Retrieves sprites from the block texture atlas via SpriteFinder.