package me.ktcm; import java.util.Locale; import javax.annotation.Nullable; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; public enum ModTextFormatting { BLACK("BLACK", '0', 0, 0), DARK_BLUE("DARK_BLUE", '1', 1, 170), DARK_GREEN("DARK_GREEN", '2', 2, 43520), DARK_AQUA("DARK_AQUA", '3', 3, 43690), DARK_RED("DARK_RED", '4', 4, 11141120), DARK_PURPLE("DARK_PURPLE", '5', 5, 11141290), GOLD("GOLD", '6', 6, 16755200), GRAY("GRAY", '7', 7, 11184810), DARK_GRAY("DARK_GRAY", '8', 8, 5592405), BLUE("BLUE", '9', 9, 5592575), GREEN("GREEN", 'a', 10, 5635925), AQUA("AQUA", 'b', 11, 5636095), RED("RED", 'c', 12, 16733525), LIGHT_PURPLE("LIGHT_PURPLE", 'd', 13, 16733695), YELLOW("YELLOW", 'e', 14, 16777045), WHITE("WHITE", 'f', 15, 16777215), // start of new colors // http://chir.ag/projects/name-that-color/ DARK_BROWN("DARK_BROWN", 'g', 16, buildColor(0.4f, 0.2f, 0.0f)), LIGHT_BROWN("LIGHT_BROWN", 'h', 17, buildColor(0.6f, 0.4f, 0.2f)), MIDNIGHT_BLUE("MIDNIGHT_BLUE", 'i', 18, buildColor(0.0f, 0.2f, 0.4f)), BAHAMA_BLUE("BAHAMA_BLUE", 'j', 19, buildColor(0.0f, 0.4f, 0.6f)), LIMEADE("LIMEADE", 'p', 20, buildColor(0.4f, 0.6f, 0.0f)), PISTACHIO("PISTACHIO", 'q', 21, buildColor(0.6f, 0.8f, 0.0f)), AZURE_RADIANCE("AZURE_RADIANCE", 's', 22, buildColor(0.0f, 0.6f, 1.0f)), MALIBU("MALIBU", 't', 23, buildColor(0.4f, 0.8f, 1.0f)), OREGON("OREGON", 'u', 24, buildColor(0.6f, 0.2f, 0.0f)), TENN("TENN", 'v', 25, buildColor(0.8f, 0.4f, 0.0f)), BUDDHA_GOLD("BUDDHA_GOLD", 'w', 26, buildColor(0.4f, 0.0f, 0.4f)), SUPERNOVA("SUPERNOVA", 'x', 27, buildColor(0.6f, 0.0f, 0.8f)), POMPADOUR("POMPADOUR", 'y', 28, buildColor(0.8f, 0.6f, 0.0f)), ELECTRIC_VIOLET("ELECTRIC_VIOLET", 'z', 29, buildColor(1.0f, 0.8f, 0.0f)), // end of new colors OBFUSCATED("OBFUSCATED", 'k', true), BOLD("BOLD", 'l', true), STRIKETHROUGH("STRIKETHROUGH", 'm', true), UNDERLINE("UNDERLINE", 'n', true), ITALIC("ITALIC", 'o', true), RESET("RESET", 'r', -1, null); private static int buildColor(float r, float g, float b) { int ir = (int) (255 * r); int ig = (int) (255 * g); int ib = (int) (255 * b); return (ir << 16) | (ig << 8) | (ib); } private final String name; private final char formattingCode; private final boolean fancyStyling; private final String controlString; private final int colorIndex; @Nullable private final Integer color; private ModTextFormatting(String formattingName, char formattingCodeIn, int index, @Nullable Integer colorCode) { this(formattingName, formattingCodeIn, false, index, colorCode); } private ModTextFormatting(String formattingName, char formattingCodeIn, boolean fancyStylingIn) { this(formattingName, formattingCodeIn, fancyStylingIn, -1, (Integer) null); } private ModTextFormatting(String formattingName, char formattingCodeIn, boolean fancyStylingIn, int index, @Nullable Integer colorCode) { this.name = formattingName; this.formattingCode = formattingCodeIn; this.fancyStyling = fancyStylingIn; this.colorIndex = index; this.color = colorCode; this.controlString = "\u00a7" + formattingCodeIn; } @Nullable @OnlyIn(Dist.CLIENT) public Integer func_211163_e() { return this.color; } @Nullable @OnlyIn(Dist.CLIENT) public Integer getColor() { return this.color; } @OnlyIn(Dist.CLIENT) public boolean func_211166_f() // isNormalStyle { return !this.fancyStyling; } @OnlyIn(Dist.CLIENT) public boolean isNormalStyle() { return !this.fancyStyling; } @Nullable @OnlyIn(Dist.CLIENT) public static ModTextFormatting fromFormattingCode(char formattingCodeIn) { return func_211165_a(formattingCodeIn); } @Nullable @OnlyIn(Dist.CLIENT) public static ModTextFormatting func_211165_a(char formattingCodeIn) { char c0 = Character.toString(formattingCodeIn).toLowerCase(Locale.ROOT).charAt(0); for(ModTextFormatting textformatting : values()) { if(textformatting.formattingCode == c0) { return textformatting; } } return null; } }