Class ItemTextureQuadConverter


  • public final class ItemTextureQuadConverter
    extends java.lang.Object
    • Constructor Detail

      • ItemTextureQuadConverter

        private ItemTextureQuadConverter()
    • Method Detail

      • convertTexture

        public static java.util.List<BakedQuad> convertTexture​(TransformationMatrix transform,
                                                               TextureAtlasSprite template,
                                                               TextureAtlasSprite sprite,
                                                               float z,
                                                               Direction facing,
                                                               int color,
                                                               int tint)
        Takes a texture and converts it into BakedQuads. The conversion is done by scanning the texture horizontally and vertically and creating "strips" of the texture. Strips that are of the same size and follow each other are converted into one bigger quad.
        The resulting list of quads is the texture represented as a list of horizontal OR vertical quads, depending on which creates less quads. If the amount of quads is equal, horizontal is preferred.
        Parameters:
        template - The input texture to convert
        sprite - The texture whose UVs shall be used
        Returns:
        The generated quads.
      • convertTextureHorizontal

        public static java.util.List<BakedQuad> convertTextureHorizontal​(TransformationMatrix transform,
                                                                         TextureAtlasSprite template,
                                                                         TextureAtlasSprite sprite,
                                                                         float z,
                                                                         Direction facing,
                                                                         int color,
                                                                         int tint)
        Scans a texture and converts it into a list of horizontal strips stacked on top of each other. The height of the strips is as big as possible.
      • convertTextureVertical

        public static java.util.List<BakedQuad> convertTextureVertical​(TransformationMatrix transform,
                                                                       TextureAtlasSprite template,
                                                                       TextureAtlasSprite sprite,
                                                                       float z,
                                                                       Direction facing,
                                                                       int color,
                                                                       int tint)
        Scans a texture and converts it into a list of vertical strips stacked next to each other from left to right. The width of the strips is as big as possible.
      • isVisible

        private static boolean isVisible​(int color)
      • genQuad

        public static BakedQuad genQuad​(TransformationMatrix transform,
                                        float x1,
                                        float y1,
                                        float x2,
                                        float y2,
                                        float z,
                                        TextureAtlasSprite sprite,
                                        Direction facing,
                                        int color,
                                        int tint)
        Generates a Front/Back quad for an itemmodel. Therefore only supports facing NORTH and SOUTH. Coordinates are [0,16] to match the usual coordinates used in TextureAtlasSprites
      • putVertex

        private static void putVertex​(IVertexConsumer consumer,
                                      Direction side,
                                      float x,
                                      float y,
                                      float z,
                                      float u,
                                      float v,
                                      int color,
                                      int luminosity)