aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/OreMixBuilder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/common/OreMixBuilder.java')
-rw-r--r--src/main/java/gregtech/common/OreMixBuilder.java35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/main/java/gregtech/common/OreMixBuilder.java b/src/main/java/gregtech/common/OreMixBuilder.java
index cd8d14c884..86453ca0a8 100644
--- a/src/main/java/gregtech/common/OreMixBuilder.java
+++ b/src/main/java/gregtech/common/OreMixBuilder.java
@@ -1,5 +1,6 @@
package gregtech.common;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@@ -16,7 +17,8 @@ public class OreMixBuilder {
public boolean enabledByDefault = true;
public Map<String, Boolean> dimsEnabled = new HashMap<>();
public int minY, maxY, weight, density, size;
- public Materials primary, secondary, between, sporadic;
+ public Materials primary, secondary, between, sporadic, representative;
+ public String localizedName;
public OreMixBuilder name(String name) {
this.oreMixName = name;
@@ -65,6 +67,10 @@ public class OreMixBuilder {
public OreMixBuilder primary(Materials primary) {
this.primary = primary;
+ if (representative == null || localizedName == null) {
+ representative = primary;
+ localizedName = primary.mLocalizedName;
+ }
return this;
}
@@ -83,4 +89,31 @@ public class OreMixBuilder {
return this;
}
+ /**
+ * Sets the localized name for the ore mix based on the provided materials.
+ * If more than one material is provided, their localized names are concatenated
+ * with commas, last comma is replaced by "&".
+ *
+ * @param materials The materials to be used for localization. The first material
+ * in the array will be used to represent to ore mix in GUI's.
+ * If none are provided the {@link #primary} will be used.
+ */
+ public OreMixBuilder localize(Materials... materials) {
+ if (materials.length > 1) {
+ String localizedName = String.join(
+ ", ",
+ Arrays.stream(materials)
+ .map(material -> material.mLocalizedName)
+ .toArray(String[]::new));
+ int index = localizedName.lastIndexOf(", ");
+ if (index != -1) {
+ localizedName = localizedName.substring(0, index) + " & " + localizedName.substring(index + 2);
+ }
+ this.localizedName = localizedName;
+ } else {
+ this.localizedName = materials[0].mLocalizedName;
+ }
+ this.representative = materials[0];
+ return this;
+ }
}