java.lang.Object
net.darkhax.botanypots.common.api.data.display.math.TintColor

public final class TintColor extends Object
Represents the ARGB channels of a color.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static com.mojang.serialization.Codec<TintColor>
    A codec that can read a TintColor from a component map or hexadecimal string.
    static com.mojang.serialization.Codec<TintColor>
    A codec that reads a TintColor from different keys of a map.
    static com.mojang.serialization.Codec<TintColor>
    A codec that reads a TintColor from a hexadecimal encoded string.
    static net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf,TintColor>
    Stream codec for networking.
    static final TintColor
    A pure white tint color.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TintColor(int alpha, int red, int green, int blue)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the alpha value of the color.
    int[]
    Gets the color components as an array.
    Represents the color as a hex string.
    float[]
    Gets the color components as an array of percentages.
    int
    Gets the blue value.
    static TintColor
    fromHex(String hexCode)
    Decodes a color from a hex string.
    int
    ? Gets the green value.
    int
    Packs the color into a single integer.
    int
    red()
    Gets the red value.
    static TintColor
    unpack(int color)
    Unpacks a color from a single integer using bit shifting.

    Methods inherited from class java.lang.Object

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

    • WHITE

      public static final TintColor WHITE
      A pure white tint color. This is used as a default and effectively leaves the original colors unmodified.
    • CODEC_ARGB

      public static com.mojang.serialization.Codec<TintColor> CODEC_ARGB
      A codec that reads a TintColor from different keys of a map.
    • CODEC_STRING

      public static com.mojang.serialization.Codec<TintColor> CODEC_STRING
      A codec that reads a TintColor from a hexadecimal encoded string. The casing of the string does not matter and a leading hashtag will be removed if present.
    • CODEC

      public static com.mojang.serialization.Codec<TintColor> CODEC
      A codec that can read a TintColor from a component map or hexadecimal string.
    • STREAM

      public static net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf,TintColor> STREAM
      Stream codec for networking.
  • Constructor Details

    • TintColor

      public TintColor(int alpha, int red, int green, int blue)
      Parameters:
      alpha - The value of the alpha channel. An alpha of 0 is fully invisible while 255 is fully opaque.
      red - The value of the red channel.
      green - The value of the green channel.
      blue - The value of the blue channel.
  • Method Details

    • asHex

      public String asHex()
      Represents the color as a hex string. The trailing hashtag is not included.
      Returns:
      A string that contains a hexadecimal representation of the color.
    • asPercents

      public float[] asPercents()
      Gets the color components as an array of percentages. This can be useful for floating point rendering.
      Returns:
      An array of color components as percentages.
    • asArray

      public int[] asArray()
      Gets the color components as an array.
      Returns:
      The color components as an array.
    • pack

      public int pack()
      Packs the color into a single integer.
      Returns:
      The integer representation of the color.
    • alpha

      public int alpha()
      Gets the alpha value of the color. 0 is fully transparent and 255 is fully opaque.
      Returns:
      The value of the alpha channel.
    • red

      public int red()
      Gets the red value.
      Returns:
      The value of the red channel.
    • green

      public int green()
      ? Gets the green value.
      Returns:
      The value of the green channel.
    • blue

      public int blue()
      Gets the blue value.
      Returns:
      The value of the blue channel.
    • unpack

      public static TintColor unpack(int color)
      Unpacks a color from a single integer using bit shifting.
      Parameters:
      color - The color to unpack.
      Returns:
      A tint based on the bits of the integer.
    • fromHex

      public static TintColor fromHex(String hexCode)
      Decodes a color from a hex string. The casing does not matter and the hashtag is completely optional.
      Parameters:
      hexCode - The hex string to decode.
      Returns:
      The color that was decoded.