java.lang.Object
net.elytrium.limboapi.api.protocol.packets.data.MapPalette

public class MapPalette extends Object
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final byte
     
    static final byte
    Deprecated.
    Use Color.WHITE instead.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    convertImage(byte[] from, byte[] to, MapPalette.MapVersion version)
    Convert an image from MapVersion.MAXIMUM_VERSION to the desired version
    static byte[]
    convertImage(int[] from, byte[] to, MapPalette.MapVersion version)
    Convert an image from MapVersion.MAXIMUM_VERSION to the desired version
    static int[]
    convertImage(int[] from, int[] to, MapPalette.MapVersion version)
    Convert an image from MapVersion.MAXIMUM_VERSION to the desired version
    static int[]
    convertImage(int[] image, MapPalette.MapVersion version)
    Convert an image from MapVersion.MAXIMUM_VERSION to the desired version
    static byte[]
    imageToBytes(int[] from, byte[] to, com.velocitypowered.api.network.ProtocolVersion version)
    Convert an image to a byte[] using the palette.
    static int[]
    imageToBytes(int[] from, int[] to, com.velocitypowered.api.network.ProtocolVersion version)
    Convert an image to a byte[] using the palette.
    static int[]
    imageToBytes(int[] image, com.velocitypowered.api.network.ProtocolVersion version)
    Convert an image to a byte[] using the palette.
    static int[]
    Convert an Image to a byte[] using the palette.
    static int[]
    imageToBytes(BufferedImage image, com.velocitypowered.api.network.ProtocolVersion version)
    Convert an Image to a byte[] using the palette.
    static byte
    tryFastMatchColor(int rgb, com.velocitypowered.api.network.ProtocolVersion version)
    Get the index of the closest matching color in the palette to the given color.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • MapPalette

      public MapPalette()
  • Method Details

    • imageToBytes

      public static int[] imageToBytes(BufferedImage image)
      Convert an Image to a byte[] using the palette. Uses reduced set of colors, to support more colors use imageToBytes(BufferedImage, ProtocolVersion)
      Parameters:
      image - The image to convert.
      Returns:
      A byte[] containing the pixels of the image.
    • imageToBytes

      public static int[] imageToBytes(BufferedImage image, com.velocitypowered.api.network.ProtocolVersion version)
      Convert an Image to a byte[] using the palette.
      Parameters:
      image - The image to convert.
      version - The ProtocolVersion to support more colors.
      Returns:
      A byte[] containing the pixels of the image.
    • imageToBytes

      public static int[] imageToBytes(int[] image, com.velocitypowered.api.network.ProtocolVersion version)
      Convert an image to a byte[] using the palette.
      Parameters:
      image - The image to convert.
      version - The ProtocolVersion to support more colors.
      Returns:
      A byte[] containing the pixels of the image.
    • imageToBytes

      public static int[] imageToBytes(int[] from, int[] to, com.velocitypowered.api.network.ProtocolVersion version)
      Convert an image to a byte[] using the palette.
      Parameters:
      from - The image to convert.
      to - Output image.
      version - The ProtocolVersion to support more colors.
      Returns:
      A byte[] containing the pixels of the image.
    • imageToBytes

      public static byte[] imageToBytes(int[] from, byte[] to, com.velocitypowered.api.network.ProtocolVersion version)
      Convert an image to a byte[] using the palette.
      Parameters:
      from - The image to convert.
      to - Output image.
      version - The ProtocolVersion to support more colors.
      Returns:
      A byte[] containing the pixels of the image.
    • tryFastMatchColor

      public static byte tryFastMatchColor(int rgb, com.velocitypowered.api.network.ProtocolVersion version)
      Get the index of the closest matching color in the palette to the given color. Uses caching and downscaling of color values.
      Parameters:
      rgb - The Color to match.
      Returns:
      The index in the palette.
    • convertImage

      public static int[] convertImage(int[] image, MapPalette.MapVersion version)
      Convert an image from MapVersion.MAXIMUM_VERSION to the desired version
      Parameters:
      image - The image to convert.
      version - The ProtocolVersion to support more colors.
      Returns:
      A byte[] containing the pixels of the image.
    • convertImage

      public static int[] convertImage(int[] from, int[] to, MapPalette.MapVersion version)
      Convert an image from MapVersion.MAXIMUM_VERSION to the desired version
      Parameters:
      from - The image to convert.
      to - Output image.
      version - The ProtocolVersion to support more colors.
      Returns:
      A byte[] containing the pixels of the image.
    • convertImage

      public static byte[] convertImage(byte[] from, byte[] to, MapPalette.MapVersion version)
      Convert an image from MapVersion.MAXIMUM_VERSION to the desired version
      Parameters:
      from - The image to convert.
      to - Output image.
      version - The ProtocolVersion to support more colors.
      Returns:
      A byte[] containing the pixels of the image.
    • convertImage

      public static byte[] convertImage(int[] from, byte[] to, MapPalette.MapVersion version)
      Convert an image from MapVersion.MAXIMUM_VERSION to the desired version
      Parameters:
      from - The image to convert.
      to - Output image.
      version - The ProtocolVersion to support more colors.
      Returns:
      A byte[] containing the pixels of the image.