mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-22 13:09:53 +00:00
Added optional Nei color localization (#254)
Co-authored-by: UltraProdigy <[email protected]>
This commit is contained in:
1 parent
4f59ed6ea0
commit
848ba01de4
1 file changed
+48
-16
@@ -28,6 +28,23 @@ import tconstruct.util.config.PHConstruct;
|
||||
|
||||
public class RecipeHandlerToolMaterials extends RecipeHandlerBase {
|
||||
|
||||
private static final int DefaultTextColor = 0x404040;
|
||||
private static final String ColorKey = "tconstruct.nei.color.";
|
||||
|
||||
private static int getLocalizedColor(String colorName, int fallbackColor) {
|
||||
String colorKey = ColorKey + colorName;
|
||||
String colorValue = StatCollector.translateToLocal(colorKey);
|
||||
if (colorKey.equals(colorValue)) {
|
||||
return fallbackColor;
|
||||
}
|
||||
|
||||
try {
|
||||
return Integer.decode(colorValue.trim());
|
||||
} catch (NumberFormatException ignored) {
|
||||
return fallbackColor;
|
||||
}
|
||||
}
|
||||
|
||||
public class CachedToolMaterialsRecipe extends CachedBaseRecipe {
|
||||
|
||||
public List<PositionedStack> toolParts;
|
||||
@@ -99,38 +116,43 @@ public class RecipeHandlerToolMaterials extends RecipeHandlerBase {
|
||||
public void drawExtras(int recipe) {
|
||||
CachedToolMaterialsRecipe crecipe = (CachedToolMaterialsRecipe) this.arecipes.get(recipe);
|
||||
if (crecipe.material != null) {
|
||||
GuiDraw.drawString(EnumChatFormatting.BOLD + crecipe.material.localizedName(), 35, 10, 0x404040, false);
|
||||
GuiDraw.drawString(
|
||||
EnumChatFormatting.BOLD + crecipe.material.localizedName(),
|
||||
35,
|
||||
10,
|
||||
getLocalizedColor("materialName", DefaultTextColor),
|
||||
false);
|
||||
GuiDraw.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter4") + crecipe.material.durability,
|
||||
35,
|
||||
20,
|
||||
0x404040,
|
||||
getLocalizedColor("materialDurability", DefaultTextColor),
|
||||
false);
|
||||
GuiDraw.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter5") + crecipe.material.handleModifier + "x",
|
||||
35,
|
||||
30,
|
||||
0x404040,
|
||||
getLocalizedColor("materialHandleModifier1", DefaultTextColor),
|
||||
false);
|
||||
GuiDraw.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter11")
|
||||
+ Math.round(crecipe.material.durability * crecipe.material.handleModifier),
|
||||
35,
|
||||
40,
|
||||
0x404040,
|
||||
getLocalizedColor("materialHandleModifier2", DefaultTextColor),
|
||||
false);
|
||||
GuiDraw.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter6") + crecipe.material.miningspeed / 100F,
|
||||
35,
|
||||
50,
|
||||
0x404040,
|
||||
getLocalizedColor("materialMiningSpeed", DefaultTextColor),
|
||||
false);
|
||||
GuiDraw.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter7")
|
||||
+ HarvestLevels.getHarvestLevelName(crecipe.material.harvestLevel),
|
||||
35,
|
||||
60,
|
||||
0x404040,
|
||||
getLocalizedColor("materialHarvestLevel", DefaultTextColor),
|
||||
false);
|
||||
String heart = crecipe.material.attack == 2 ? StatCollector.translateToLocal("gui.partcrafter8")
|
||||
: StatCollector.translateToLocal("gui.partcrafter9");
|
||||
@@ -139,19 +161,24 @@ public class RecipeHandlerToolMaterials extends RecipeHandlerBase {
|
||||
StatCollector.translateToLocal("gui.partcrafter10") + crecipe.material.attack / 2 + heart,
|
||||
35,
|
||||
70,
|
||||
0x404040,
|
||||
getLocalizedColor("materialAttack1", DefaultTextColor),
|
||||
false);
|
||||
} else {
|
||||
GuiDraw.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter10") + crecipe.material.attack / 2F + heart,
|
||||
35,
|
||||
70,
|
||||
0x404040,
|
||||
getLocalizedColor("materialAttack2", DefaultTextColor),
|
||||
false);
|
||||
}
|
||||
int abilityY = 85;
|
||||
if (crecipe.material.reinforced > 0) {
|
||||
GuiDraw.drawString(getReinforcedString(crecipe.material.reinforced), 35, 85, 0x404040, false);
|
||||
GuiDraw.drawString(
|
||||
getReinforcedString(crecipe.material.reinforced),
|
||||
35,
|
||||
85,
|
||||
getLocalizedColor("materialReinforced", DefaultTextColor),
|
||||
false);
|
||||
abilityY += 10;
|
||||
}
|
||||
String ability = crecipe.material.ability();
|
||||
@@ -161,10 +188,15 @@ public class RecipeHandlerToolMaterials extends RecipeHandlerBase {
|
||||
ability + " (" + Math.abs(crecipe.material.stonebound) + ")",
|
||||
35,
|
||||
abilityY,
|
||||
0x404040,
|
||||
getLocalizedColor("materialStonebound", DefaultTextColor),
|
||||
false);
|
||||
} else {
|
||||
GuiDraw.drawString(ability, 35, abilityY, 0x404040, false);
|
||||
GuiDraw.drawString(
|
||||
ability,
|
||||
35,
|
||||
abilityY,
|
||||
getLocalizedColor("materialAbility", DefaultTextColor),
|
||||
false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,20 +207,20 @@ public class RecipeHandlerToolMaterials extends RecipeHandlerBase {
|
||||
EnumChatFormatting.BOLD + StatCollector.translateToLocal("tconstruct.nei.projectilematerials"),
|
||||
35,
|
||||
10,
|
||||
0x404040,
|
||||
getLocalizedColor("materialBow", DefaultTextColor),
|
||||
false);
|
||||
GuiDraw.drawString(
|
||||
StatCollector.translateToLocal("gui.toolstation6") + crecipe.bowMaterial.drawspeed,
|
||||
x,
|
||||
y,
|
||||
0x404040,
|
||||
getLocalizedColor("materialBowDrawSpeed", DefaultTextColor),
|
||||
false);
|
||||
y += 10;
|
||||
GuiDraw.drawString(
|
||||
StatCollector.translateToLocal("gui.toolstation7") + crecipe.bowMaterial.flightSpeedMax,
|
||||
x,
|
||||
y,
|
||||
0x404040,
|
||||
getLocalizedColor("materialBowFlightSpeedMax", DefaultTextColor),
|
||||
false);
|
||||
}
|
||||
if (crecipe.arrowMaterial != null) {
|
||||
@@ -198,14 +230,14 @@ public class RecipeHandlerToolMaterials extends RecipeHandlerBase {
|
||||
StatCollector.translateToLocal("gui.toolstation8") + crecipe.arrowMaterial.mass,
|
||||
x,
|
||||
y,
|
||||
0x404040,
|
||||
getLocalizedColor("materialArrowMass", DefaultTextColor),
|
||||
false);
|
||||
y += 10;
|
||||
GuiDraw.drawString(
|
||||
StatCollector.translateToLocal("gui.toolstation22") + crecipe.arrowMaterial.breakChance,
|
||||
x,
|
||||
y,
|
||||
0x404040,
|
||||
getLocalizedColor("materialArrowBreakChance", DefaultTextColor),
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user