Class TextColor

java.lang.Object
net.minecraft.text.TextColor

public final class TextColor
extends Object
Represents an RGB color of a Text.

This is immutable, and part of a Style.

See Also:
Style
  • Field Details

  • Constructor Details

    • TextColor

      private TextColor​(int rgb, String name)
    • TextColor

      private TextColor​(int rgb)
  • Method Details

    • getRgb

      @Environment(CLIENT) public int getRgb()
      Gets the RGB value of this color.

      The red bits can be obtained by (rgb >> 16) & 0xFF, green bits by (rgb >> 8) & 0xFF, blue bits by rgb & 0xFF.

    • getName

      public String getName()
      Gets the name of this color, used for converting the color to JSON format.
    • getHexCode

      private String getHexCode()
    • equals

      public boolean equals​(Object object)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • fromFormatting

      @Nullable public static TextColor fromFormatting​(Formatting formatting)
      Obtains a text color from a formatting.
      Parameters:
      formatting - the formatting
    • fromRgb

      public static TextColor fromRgb​(int rgb)
      Obtains a text color from an RGB value.
      Parameters:
      rgb - the RGB color
    • parse

      @Nullable public static TextColor parse​(String name)
      Parses a color by its name.
      Parameters:
      name - the name