diff --git a/src/main/java/tconstruct/client/TProxyClient.java b/src/main/java/tconstruct/client/TProxyClient.java index d94d884e18..ed19e4dc8b 100644 --- a/src/main/java/tconstruct/client/TProxyClient.java +++ b/src/main/java/tconstruct/client/TProxyClient.java @@ -23,7 +23,6 @@ import tconstruct.armor.ArmorProxyClient; import tconstruct.armor.player.TPlayerStats; import tconstruct.common.TProxyCommon; -import tconstruct.library.util.LocalizedColors; import tconstruct.tools.items.ManualInfo; public class TProxyClient extends TProxyCommon { @@ -39,7 +38,6 @@ public class TProxyClient extends TProxyCommon { public void initialize() { registerRenderer(); readManuals(); - LocalizedColors.reload(); } /* Registers any rendering code. */ diff --git a/src/main/java/tconstruct/library/util/ColorUtils.java b/src/main/java/tconstruct/library/util/ColorUtils.java new file mode 100644 index 0000000000..986de3d790 --- /dev/null +++ b/src/main/java/tconstruct/library/util/ColorUtils.java @@ -0,0 +1,28 @@ +package tconstruct.library.util; + +import com.gtnewhorizon.gtnhlib.color.ColorResource; + +public class ColorUtils { + + private static final ColorResource.Factory color = new ColorResource.Factory("tinker"); + + public static final ColorResource + // spotless:off + materialName = color.rgb("materialName", "0x404040"), + materialDurability = color.rgb("materialDurability", "0x404040"), + materialHandleModifier1 = color.rgb("materialHandleModifier1", "0x404040"), + materialHandleModifier2 = color.rgb("materialHandleModifier2", "0x404040"), + materialMiningSpeed = color.rgb("materialMiningSpeed", "0x404040"), + materialHarvestLevel = color.rgb("materialHarvestLevel", "0x404040"), + materialAttack1 = color.rgb("materialAttack1", "0x404040"), + materialAttack2 = color.rgb("materialAttack2", "0x404040"), + materialReinforced = color.rgb("materialReinforced", "0x404040"), + materialStonebound = color.rgb("materialStonebound", "0x404040"), + materialAbility = color.rgb("materialAbility", "0x404040"), + materialBow = color.rgb("materialBow", "0x404040"), + materialBowDrawSpeed = color.rgb("materialBowDrawSpeed", "0x404040"), + materialBowFlightSpeedMax = color.rgb("materialBowFlightSpeedMax", "0x404040"), + materialArrowMass = color.rgb("materialArrowMass", "0x404040"), + materialArrowBreakChance = color.rgb("materialArrowBreakChance", "0x404040"); + // spotless:on +} diff --git a/src/main/java/tconstruct/library/util/LocalizedColors.java b/src/main/java/tconstruct/library/util/LocalizedColors.java deleted file mode 100644 index 8f959c736f..0000000000 --- a/src/main/java/tconstruct/library/util/LocalizedColors.java +++ /dev/null @@ -1,63 +0,0 @@ -package tconstruct.library.util; - -import net.minecraft.util.StatCollector; - -public final class LocalizedColors { - - private static final String KEY_PREFIX = "tconstruct.nei.color."; - - public static int MATERIAL_NAME = 0x404040; - public static int MATERIAL_DURABILITY = 0x404040; - public static int MATERIAL_HANDLE_MODIFIER1 = 0x404040; - public static int MATERIAL_HANDLE_MODIFIER2 = 0x404040; - public static int MATERIAL_MINING_SPEED = 0x404040; - public static int MATERIAL_HARVEST_LEVEL = 0x404040; - public static int MATERIAL_ATTACK1 = 0x404040; - public static int MATERIAL_ATTACK2 = 0x404040; - public static int MATERIAL_REINFORCED = 0x404040; - public static int MATERIAL_STONEBOUND = 0x404040; - public static int MATERIAL_ABILITY = 0x404040; - public static int MATERIAL_BOW = 0x404040; - public static int MATERIAL_BOW_DRAW_SPEED = 0x404040; - public static int MATERIAL_BOW_FLIGHT_SPEED_MAX = 0x404040; - public static int MATERIAL_ARROW_MASS = 0x404040; - public static int MATERIAL_ARROW_BREAK_CHANCE = 0x404040; - - private LocalizedColors() {} - - public static void reload() { - MATERIAL_NAME = get("materialName", MATERIAL_NAME); - MATERIAL_DURABILITY = get("materialDurability", MATERIAL_DURABILITY); - MATERIAL_HANDLE_MODIFIER1 = get("materialHandleModifier1", MATERIAL_HANDLE_MODIFIER1); - MATERIAL_HANDLE_MODIFIER2 = get("materialHandleModifier2", MATERIAL_HANDLE_MODIFIER2); - MATERIAL_MINING_SPEED = get("materialMiningSpeed", MATERIAL_MINING_SPEED); - MATERIAL_HARVEST_LEVEL = get("materialHarvestLevel", MATERIAL_HARVEST_LEVEL); - MATERIAL_ATTACK1 = get("materialAttack1", MATERIAL_ATTACK1); - MATERIAL_ATTACK2 = get("materialAttack2", MATERIAL_ATTACK2); - MATERIAL_REINFORCED = get("materialReinforced", MATERIAL_REINFORCED); - MATERIAL_STONEBOUND = get("materialStonebound", MATERIAL_STONEBOUND); - MATERIAL_ABILITY = get("materialAbility", MATERIAL_ABILITY); - MATERIAL_BOW = get("materialBow", MATERIAL_BOW); - MATERIAL_BOW_DRAW_SPEED = get("materialBowDrawSpeed", MATERIAL_BOW_DRAW_SPEED); - MATERIAL_BOW_FLIGHT_SPEED_MAX = get("materialBowFlightSpeedMax", MATERIAL_BOW_FLIGHT_SPEED_MAX); - MATERIAL_ARROW_MASS = get("materialArrowMass", MATERIAL_ARROW_MASS); - MATERIAL_ARROW_BREAK_CHANCE = get("materialArrowBreakChance", MATERIAL_ARROW_BREAK_CHANCE); - } - - private static int get(String key, int fallback) { - String full = KEY_PREFIX + key; - - if (!StatCollector.canTranslate(full)) return fallback; - - String raw = StatCollector.translateToLocal(full).trim(); - - if (raw.startsWith("0x") || raw.startsWith("0X")) raw = raw.substring(2); - else if (raw.startsWith("#")) raw = raw.substring(1); - - try { - return (int) Long.parseLong(raw, 16); - } catch (NumberFormatException ignored) { - return fallback; - } - } -} diff --git a/src/main/java/tconstruct/plugins/nei/RecipeHandlerToolMaterials.java b/src/main/java/tconstruct/plugins/nei/RecipeHandlerToolMaterials.java index fa6fbe3973..4465e1508e 100644 --- a/src/main/java/tconstruct/plugins/nei/RecipeHandlerToolMaterials.java +++ b/src/main/java/tconstruct/plugins/nei/RecipeHandlerToolMaterials.java @@ -21,16 +21,14 @@ import tconstruct.library.tools.BowMaterial; import tconstruct.library.tools.DynamicToolPart; import tconstruct.library.tools.ToolMaterial; +import tconstruct.library.util.ColorUtils; import tconstruct.library.util.HarvestLevels; import tconstruct.library.util.IToolPart; -import tconstruct.library.util.LocalizedColors; import tconstruct.tools.items.ToolPart; import tconstruct.util.config.PHConstruct; public class RecipeHandlerToolMaterials extends RecipeHandlerBase { - private static final int DefaultTextColor = 0x404040; - public class CachedToolMaterialsRecipe extends CachedBaseRecipe { public List toolParts; @@ -106,39 +104,39 @@ public void drawExtras(int recipe) { EnumChatFormatting.BOLD + crecipe.material.localizedName(), 35, 10, - LocalizedColors.MATERIAL_NAME, + ColorUtils.materialName.getColor(), false); GuiDraw.drawString( StatCollector.translateToLocal("gui.partcrafter4") + crecipe.material.durability, 35, 20, - LocalizedColors.MATERIAL_DURABILITY, + ColorUtils.materialDurability.getColor(), false); GuiDraw.drawString( StatCollector.translateToLocal("gui.partcrafter5") + crecipe.material.handleModifier + "x", 35, 30, - LocalizedColors.MATERIAL_HANDLE_MODIFIER1, + ColorUtils.materialHandleModifier1.getColor(), false); GuiDraw.drawString( StatCollector.translateToLocal("gui.partcrafter11") + Math.round(crecipe.material.durability * crecipe.material.handleModifier), 35, 40, - LocalizedColors.MATERIAL_HANDLE_MODIFIER2, + ColorUtils.materialHandleModifier2.getColor(), false); GuiDraw.drawString( StatCollector.translateToLocal("gui.partcrafter6") + crecipe.material.miningspeed / 100F, 35, 50, - LocalizedColors.MATERIAL_MINING_SPEED, + ColorUtils.materialMiningSpeed.getColor(), false); GuiDraw.drawString( StatCollector.translateToLocal("gui.partcrafter7") + HarvestLevels.getHarvestLevelName(crecipe.material.harvestLevel), 35, 60, - LocalizedColors.MATERIAL_HARVEST_LEVEL, + ColorUtils.materialHarvestLevel.getColor(), false); String heart = crecipe.material.attack == 2 ? StatCollector.translateToLocal("gui.partcrafter8") : StatCollector.translateToLocal("gui.partcrafter9"); @@ -147,14 +145,14 @@ public void drawExtras(int recipe) { StatCollector.translateToLocal("gui.partcrafter10") + crecipe.material.attack / 2 + heart, 35, 70, - LocalizedColors.MATERIAL_ATTACK1, + ColorUtils.materialAttack1.getColor(), false); } else { GuiDraw.drawString( StatCollector.translateToLocal("gui.partcrafter10") + crecipe.material.attack / 2F + heart, 35, 70, - LocalizedColors.MATERIAL_ATTACK2, + ColorUtils.materialAttack2.getColor(), false); } int abilityY = 85; @@ -163,7 +161,7 @@ public void drawExtras(int recipe) { getReinforcedString(crecipe.material.reinforced), 35, 85, - LocalizedColors.MATERIAL_REINFORCED, + ColorUtils.materialReinforced.getColor(), false); abilityY += 10; } @@ -174,10 +172,10 @@ public void drawExtras(int recipe) { ability + " (" + Math.abs(crecipe.material.stonebound) + ")", 35, abilityY, - LocalizedColors.MATERIAL_STONEBOUND, + ColorUtils.materialStonebound.getColor(), false); } else { - GuiDraw.drawString(ability, 35, abilityY, LocalizedColors.MATERIAL_ABILITY, false); + GuiDraw.drawString(ability, 35, abilityY, ColorUtils.materialAbility.getColor(), false); } } } @@ -188,20 +186,20 @@ public void drawExtras(int recipe) { EnumChatFormatting.BOLD + StatCollector.translateToLocal("tconstruct.nei.projectilematerials"), 35, 10, - LocalizedColors.MATERIAL_BOW, + ColorUtils.materialBow.getColor(), false); GuiDraw.drawString( StatCollector.translateToLocal("gui.toolstation6") + crecipe.bowMaterial.drawspeed, x, y, - LocalizedColors.MATERIAL_BOW_DRAW_SPEED, + ColorUtils.materialBowDrawSpeed.getColor(), false); y += 10; GuiDraw.drawString( StatCollector.translateToLocal("gui.toolstation7") + crecipe.bowMaterial.flightSpeedMax, x, y, - LocalizedColors.MATERIAL_BOW_FLIGHT_SPEED_MAX, + ColorUtils.materialBowFlightSpeedMax.getColor(), false); } if (crecipe.arrowMaterial != null) { @@ -211,14 +209,14 @@ public void drawExtras(int recipe) { StatCollector.translateToLocal("gui.toolstation8") + crecipe.arrowMaterial.mass, x, y, - LocalizedColors.MATERIAL_ARROW_MASS, + ColorUtils.materialArrowMass.getColor(), false); y += 10; GuiDraw.drawString( StatCollector.translateToLocal("gui.toolstation22") + crecipe.arrowMaterial.breakChance, x, y, - LocalizedColors.MATERIAL_ARROW_BREAK_CHANCE, + ColorUtils.materialArrowBreakChance.getColor(), false); } }