diff options
author | miozune <miozune@gmail.com> | 2022-08-24 19:44:44 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-24 11:44:44 +0100 |
commit | e67218cb6f0fbdb7691797366f181b0d4a13ee12 (patch) | |
tree | 3b4ca60ca257d4d2206a4db65e923cf892a06f8e /src/main | |
parent | fa8d3e87bec46d334e857ac6a5a13f053cf64b73 (diff) | |
download | GT5-Unofficial-e67218cb6f0fbdb7691797366f181b0d4a13ee12.tar.gz GT5-Unofficial-e67218cb6f0fbdb7691797366f181b0d4a13ee12.tar.bz2 GT5-Unofficial-e67218cb6f0fbdb7691797366f181b0d4a13ee12.zip |
Fix empty formula causing incorrect tooltip displayed (#188)
Former-commit-id: 83f4332711b80cdec42d0d748eecc6036046dcde
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java index baa19e43cb..fc4209ed27 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java @@ -199,23 +199,21 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { if (contents.length > 1) { if (p.getKey() instanceof Materials) { if (((Materials) p.getKey()).mMaterialList.size() > 1 && p.getValue() > 1) -// if (((Materials) p.getKey()).mChemicalFormula != null && Character.isDigit(((Materials) p.getKey()).mChemicalFormula.toCharArray()[((Materials) p.getKey()).mChemicalFormula.length()-1])) - this.toolTip += "(" + ((Materials) p.getKey()).mChemicalFormula + ")" + (BW_Util.subscriptNumber(p.getValue())); + this.toolTip += "(" + getFormula((Materials) p.getKey()) + ")" + (BW_Util.subscriptNumber(p.getValue())); else - this.toolTip += ((Materials) p.getKey()).mChemicalFormula + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); + this.toolTip += getFormula((Materials) p.getKey()) + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); } if (p.getKey() instanceof Werkstoff) { if (((Werkstoff) p.getKey()).CONTENTS.size() > 1 && p.getValue() > 1) -// if (((Werkstoff) p.getKey()).toolTip != null && Character.isDigit(((Werkstoff) p.getKey()).toolTip.toCharArray()[((Werkstoff) p.getKey()).toolTip.length()-1])) - this.toolTip += "(" + ((Werkstoff) p.getKey()).toolTip + ")" + (BW_Util.subscriptNumber(p.getValue())); + this.toolTip += "(" + getFormula((Werkstoff) p.getKey()) + ")" + (BW_Util.subscriptNumber(p.getValue())); else - this.toolTip += ((Werkstoff) p.getKey()).toolTip + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); + this.toolTip += getFormula((Werkstoff) p.getKey()) + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); } } else { if (p.getKey() instanceof Materials) { - this.toolTip += ((Materials) p.getKey()).mChemicalFormula + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); + this.toolTip += getFormula((Materials) p.getKey()) + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); } else if (p.getKey() instanceof Werkstoff) - this.toolTip += ((Werkstoff) p.getKey()).toolTip + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); + this.toolTip += getFormula((Werkstoff) p.getKey()) + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); } } } else @@ -293,6 +291,13 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { this.owner = getMaterialOwner(); } + private static String getFormula(Materials material) { + return material.mChemicalFormula.isEmpty() ? "?" : material.mChemicalFormula; + } + + private static String getFormula(Werkstoff material) { + return material.toolTip.isEmpty() ? "?" : material.toolTip; + } public Werkstoff addAdditionalOreDict(String s) { ADDITIONAL_OREDICT.add(s); |