Skip to content

Commit

Permalink
patch up glass chemical formula
Browse files Browse the repository at this point in the history
Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>
  • Loading branch information
Glease committed Jan 4, 2023
1 parent c844b29 commit 4cf2a40
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/java/gregtech/api/enums/Materials.java
Original file line number Diff line number Diff line change
Expand Up @@ -1467,10 +1467,12 @@ public Materials(
aColor);
mExtraData = aExtraData;
mMaterialList.addAll(aMaterialList);
mChemicalFormula = mMaterialList.stream()
.map(MaterialStack::toString)
.collect(Collectors.joining())
.replaceAll("_", "-");
if (mMaterialList.size() == 1) mChemicalFormula = mMaterialList.get(0).toStringSingle();
else
mChemicalFormula = mMaterialList.stream()
.map(MaterialStack::toString)
.collect(Collectors.joining())
.replaceAll("_", "-");

int tAmountOfComponents = 0, tMeltingPoint = 0;
for (MaterialStack tMaterial : mMaterialList) {
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/gregtech/api/objects/MaterialStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ public String toString() {
return temp1 + temp2 + temp3 + temp4;
}

public String toStringSingle() {
String temp1 = "", temp2 = mMaterial.getToolTip(true), temp3 = "", temp4 = "";
if (mAmount > 1) {
temp4 = GT_Utility.toSubscript(mAmount);
if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
temp1 = "(";
temp3 = ")";
}
}
return temp1 + temp2 + temp3 + temp4;
}

private boolean isMaterialListComplex(MaterialStack materialStack) {
if (materialStack.mMaterial.mMaterialList.size() > 1) {
return true;
Expand Down

0 comments on commit 4cf2a40

Please sign in to comment.