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:
Mappings:
Namespace Name
named net/minecraft/text/TextColor
intermediary net/minecraft/class_5251
official yu
  • Field Details

    • RGB_PREFIX

      private static final String RGB_PREFIX
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named RGB_PREFIX Lnet/minecraft/text/TextColor;RGB_PREFIX:Ljava/lang/String;
      intermediary field_33291 Lnet/minecraft/class_5251;field_33291:Ljava/lang/String;
      official b Lyu;b:Ljava/lang/String;
    • CODEC

      public static final com.mojang.serialization.Codec<TextColor> CODEC
      Mappings:
      Namespace Name Mixin selector
      named CODEC Lnet/minecraft/text/TextColor;CODEC:Lcom/mojang/serialization/Codec;
      intermediary field_39242 Lnet/minecraft/class_5251;field_39242:Lcom/mojang/serialization/Codec;
      official a Lyu;a:Lcom/mojang/serialization/Codec;
    • FORMATTING_TO_COLOR

      private static final Map<Formatting,TextColor> FORMATTING_TO_COLOR
      Mappings:
      Namespace Name Mixin selector
      named FORMATTING_TO_COLOR Lnet/minecraft/text/TextColor;FORMATTING_TO_COLOR:Ljava/util/Map;
      intermediary field_24362 Lnet/minecraft/class_5251;field_24362:Ljava/util/Map;
      official c Lyu;c:Ljava/util/Map;
    • BY_NAME

      private static final Map<String,TextColor> BY_NAME
      Mappings:
      Namespace Name Mixin selector
      named BY_NAME Lnet/minecraft/text/TextColor;BY_NAME:Ljava/util/Map;
      intermediary field_24363 Lnet/minecraft/class_5251;field_24363:Ljava/util/Map;
      official d Lyu;d:Ljava/util/Map;
    • rgb

      private final int rgb
      Mappings:
      Namespace Name Mixin selector
      named rgb Lnet/minecraft/text/TextColor;rgb:I
      intermediary field_24364 Lnet/minecraft/class_5251;field_24364:I
      official e Lyu;e:I
    • name

      @Nullable private final @Nullable String name
      Mappings:
      Namespace Name Mixin selector
      named name Lnet/minecraft/text/TextColor;name:Ljava/lang/String;
      intermediary field_24365 Lnet/minecraft/class_5251;field_24365:Ljava/lang/String;
      official f Lyu;f:Ljava/lang/String;
  • Constructor Details

    • TextColor

      private TextColor(int rgb, String name)
      Mappings:
      Namespace Name Mixin selector
      named <init> Lnet/minecraft/text/TextColor;<init>(ILjava/lang/String;)V
      intermediary <init> Lnet/minecraft/class_5251;<init>(ILjava/lang/String;)V
      official <init> Lyu;<init>(ILjava/lang/String;)V
    • TextColor

      private TextColor(int rgb)
      Mappings:
      Namespace Name Mixin selector
      named <init> Lnet/minecraft/text/TextColor;<init>(I)V
      intermediary <init> Lnet/minecraft/class_5251;<init>(I)V
      official <init> Lyu;<init>(I)V
  • Method Details

    • getRgb

      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.

      Mappings:
      Namespace Name Mixin selector
      named getRgb Lnet/minecraft/text/TextColor;getRgb()I
      intermediary method_27716 Lnet/minecraft/class_5251;method_27716()I
      official a Lyu;a()I
    • getName

      public String getName()
      Gets the name of this color, used for converting the color to JSON format.
      Mappings:
      Namespace Name Mixin selector
      named getName Lnet/minecraft/text/TextColor;getName()Ljava/lang/String;
      intermediary method_27721 Lnet/minecraft/class_5251;method_27721()Ljava/lang/String;
      official b Lyu;b()Ljava/lang/String;
    • getHexCode

      private String getHexCode()
      Mappings:
      Namespace Name Mixin selector
      named getHexCode Lnet/minecraft/text/TextColor;getHexCode()Ljava/lang/String;
      intermediary method_27723 Lnet/minecraft/class_5251;method_27723()Ljava/lang/String;
      official c Lyu;c()Ljava/lang/String;
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
      Mappings:
      Namespace Name Mixin selector
      named equals Lnet/minecraft/text/TextColor;equals(Ljava/lang/Object;)Z
      intermediary equals Lnet/minecraft/class_5251;equals(Ljava/lang/Object;)Z
      official equals Lyu;equals(Ljava/lang/Object;)Z
    • hashCode

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

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

      @Nullable public static @Nullable TextColor fromFormatting(Formatting formatting)
      Obtains a text color from a formatting.
      Parameters:
      formatting - the formatting
      Mappings:
      Namespace Name Mixin selector
      named fromFormatting Lnet/minecraft/text/TextColor;fromFormatting(Lnet/minecraft/util/Formatting;)Lnet/minecraft/text/TextColor;
      intermediary method_27718 Lnet/minecraft/class_5251;method_27718(Lnet/minecraft/class_124;)Lnet/minecraft/class_5251;
      official a Lyu;a(Ln;)Lyu;
    • fromRgb

      public static TextColor fromRgb(int rgb)
      Obtains a text color from an RGB value.
      Parameters:
      rgb - the RGB color
      Mappings:
      Namespace Name Mixin selector
      named fromRgb Lnet/minecraft/text/TextColor;fromRgb(I)Lnet/minecraft/text/TextColor;
      intermediary method_27717 Lnet/minecraft/class_5251;method_27717(I)Lnet/minecraft/class_5251;
      official a Lyu;a(I)Lyu;
    • parse

      public static com.mojang.serialization.DataResult<TextColor> parse(String name)
      Parses a color by its name.
      Parameters:
      name - the name
      Mappings:
      Namespace Name Mixin selector
      named parse Lnet/minecraft/text/TextColor;parse(Ljava/lang/String;)Lcom/mojang/serialization/DataResult;
      intermediary method_27719 Lnet/minecraft/class_5251;method_27719(Ljava/lang/String;)Lcom/mojang/serialization/DataResult;
      official a Lyu;a(Ljava/lang/String;)Lcom/mojang/serialization/DataResult;