Skip to content

Commit

Permalink
give ore mixes localized names
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyfts committed Sep 27, 2024
1 parent b6d5e9a commit b46b9b6
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 166 deletions.
102 changes: 68 additions & 34 deletions src/main/java/gregtech/api/enums/OreMixes.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public enum OreMixes {
.primary(Materials.BrownLimonite)
.secondary(Materials.YellowLimonite)
.inBetween(Materials.BandedIron)
.sporadic(Materials.Malachite)),
.sporadic(Materials.Malachite)
.localize(Materials.Iron)),

Cassiterite(new OreMixBuilder().name("ore.mix.cassiterite")
.heightRange(60, 220)
Expand All @@ -107,7 +108,8 @@ public enum OreMixes {
.primary(Materials.Tin)
.secondary(Materials.Tin)
.inBetween(Materials.Cassiterite)
.sporadic(Materials.Tin)),
.sporadic(Materials.Tin)
.localize(Materials.Cassiterite)),

Tetrahedrite(new OreMixBuilder().name("ore.mix.tetrahedrite")
.heightRange(80, 120)
Expand Down Expand Up @@ -155,7 +157,8 @@ public enum OreMixes {
.primary(Materials.Chalcopyrite)
.secondary(Materials.Iron)
.inBetween(Materials.Pyrite)
.sporadic(Materials.Copper)),
.sporadic(Materials.Copper)
.localize(Materials.Copper)),

Bauxite(new OreMixBuilder().name("ore.mix.bauxite")
.heightRange(10, 80)
Expand Down Expand Up @@ -191,7 +194,8 @@ public enum OreMixes {
.primary(Materials.RockSalt)
.secondary(Materials.Salt)
.inBetween(Materials.Lepidolite)
.sporadic(Materials.Spodumene)),
.sporadic(Materials.Spodumene)
.localize(Materials.Salt)),

Redstone(new OreMixBuilder().name("ore.mix.redstone")
.heightRange(5, 40)
Expand Down Expand Up @@ -227,7 +231,8 @@ public enum OreMixes {
.primary(Materials.Garnierite)
.secondary(Materials.Nickel)
.inBetween(Materials.Cobaltite)
.sporadic(Materials.Pentlandite)),
.sporadic(Materials.Pentlandite)
.localize(Materials.Nickel)),

Platinum(new OreMixBuilder().name("ore.mix.platinum")
.heightRange(40, 50)
Expand All @@ -238,7 +243,8 @@ public enum OreMixes {
.primary(Materials.Cooperite)
.secondary(Materials.Palladium)
.inBetween(Materials.Platinum)
.sporadic(Materials.Iridium)),
.sporadic(Materials.Iridium)
.localize(Materials.Platinum)),

Pitchblende(new OreMixBuilder().name("ore.mix.pitchblende")
.heightRange(60, 60)
Expand All @@ -260,7 +266,8 @@ public enum OreMixes {
.primary(Materials.Bastnasite)
.secondary(Materials.Bastnasite)
.inBetween(Materials.Monazite)
.sporadic(Materials.Neodymium)),
.sporadic(Materials.Neodymium)
.localize(Materials.Monazite)),

Molybdenum(new OreMixBuilder().name("ore.mix.molybdenum")
.heightRange(20, 50)
Expand All @@ -272,7 +279,8 @@ public enum OreMixes {
.primary(Materials.Wulfenite)
.secondary(Materials.Molybdenite)
.inBetween(Materials.Molybdenum)
.sporadic(Materials.Powellite)),
.sporadic(Materials.Powellite)
.localize(Materials.Molybdenum)),

Tungstate(new OreMixBuilder().name("ore.mix.tungstate")
.heightRange(20, 60)
Expand All @@ -297,7 +305,8 @@ public enum OreMixes {
.primary(Materials.Scheelite)
.secondary(Materials.Scheelite)
.inBetween(Materials.Tungstate)
.sporadic(Materials.Lithium)),
.sporadic(Materials.Lithium)
.localize(Materials.Tungstate)),

Sapphire(new OreMixBuilder().name("ore.mix.sapphire")
.heightRange(10, 40)
Expand All @@ -309,7 +318,8 @@ public enum OreMixes {
.primary(Materials.Almandine)
.secondary(Materials.Pyrope)
.inBetween(Materials.Sapphire)
.sporadic(Materials.GreenSapphire)),
.sporadic(Materials.GreenSapphire)
.localize(Materials.Sapphire)),

Manganese(new OreMixBuilder().name("ore.mix.manganese")
.heightRange(20, 30)
Expand All @@ -321,7 +331,8 @@ public enum OreMixes {
.primary(Materials.Grossular)
.secondary(Materials.Spessartine)
.inBetween(Materials.Pyrolusite)
.sporadic(Materials.Tantalite)),
.sporadic(Materials.Tantalite)
.localize(Materials.Manganese)),

Quartz(new OreMixBuilder().name("ore.mix.quartz")
.heightRange(80, 120)
Expand All @@ -345,7 +356,8 @@ public enum OreMixes {
.primary(Materials.Graphite)
.secondary(Materials.Graphite)
.inBetween(Materials.Diamond)
.sporadic(Materials.Coal)),
.sporadic(Materials.Coal)
.localize(Materials.Diamond)),

Olivine(new OreMixBuilder().name("ore.mix.olivine")
.heightRange(10, 40)
Expand All @@ -357,7 +369,8 @@ public enum OreMixes {
.primary(Materials.Bentonite)
.secondary(Materials.Magnesite)
.inBetween(Materials.Olivine)
.sporadic(Materials.Glauconite)),
.sporadic(Materials.Glauconite)
.localize(Materials.Olivine)),

Apatite(new OreMixBuilder().name("ore.mix.apatite")
.heightRange(40, 60)
Expand Down Expand Up @@ -391,7 +404,8 @@ public enum OreMixes {
.primary(Materials.Lazurite)
.secondary(Materials.Sodalite)
.inBetween(Materials.Lapis)
.sporadic(Materials.Calcite)),
.sporadic(Materials.Calcite)
.localize(Materials.Lapis)),

Beryllium(new OreMixBuilder().name("ore.mix.beryllium")
.heightRange(5, 30)
Expand Down Expand Up @@ -425,7 +439,8 @@ public enum OreMixes {
.primary(Materials.Uraninite)
.secondary(Materials.Uraninite)
.inBetween(Materials.Uranium)
.sporadic(Materials.Uranium)),
.sporadic(Materials.Uranium)
.localize(Materials.Uranium)),
OilSand(new OreMixBuilder().name("ore.mix.oilsand")
.heightRange(50, 80)
.weight(40)
Expand Down Expand Up @@ -458,7 +473,8 @@ public enum OreMixes {
.primary(Materials.InfusedWater)
.secondary(Materials.InfusedFire)
.inBetween(Materials.Amber)
.sporadic(Materials.Cinnabar)),
.sporadic(Materials.Cinnabar)
.localize(Materials.InfusedWater, Materials.InfusedFire, Materials.Amber)),

TerraAer(new OreMixBuilder().name("ore.mix.terraaer")
.heightRange(5, 35)
Expand All @@ -470,7 +486,8 @@ public enum OreMixes {
.primary(Materials.InfusedEarth)
.secondary(Materials.InfusedAir)
.inBetween(Materials.Amber)
.sporadic(Materials.Cinnabar)),
.sporadic(Materials.Cinnabar)
.localize(Materials.InfusedEarth, Materials.InfusedAir)),

PerditioOrdo(new OreMixBuilder().name("ore.mix.perditioordo")
.heightRange(5, 35)
Expand All @@ -482,7 +499,8 @@ public enum OreMixes {
.primary(Materials.InfusedEntropy)
.secondary(Materials.InfusedOrder)
.inBetween(Materials.Amber)
.sporadic(Materials.Cinnabar)),
.sporadic(Materials.Cinnabar)
.localize(Materials.InfusedEntropy, Materials.InfusedOrder)),

CopperTin(new OreMixBuilder().name("ore.mix.coppertin")
.heightRange(80, 200)
Expand All @@ -493,7 +511,8 @@ public enum OreMixes {
.primary(Materials.Chalcopyrite)
.secondary(Materials.Vermiculite)
.inBetween(Materials.Cassiterite)
.sporadic(Materials.Alunite)),
.sporadic(Materials.Alunite)
.localize(Materials.Vermiculite)),

TitaniumChrome(new OreMixBuilder().name("ore.mix.titaniumchrome")
.heightRange(10, 70)
Expand Down Expand Up @@ -552,7 +571,8 @@ public enum OreMixes {
.primary(Materials.Kyanite)
.secondary(Materials.Mica)
.inBetween(Materials.Cassiterite)
.sporadic(Materials.Pollucite)),
.sporadic(Materials.Pollucite)
.localize(Materials.Mica)),

Dolomite(new OreMixBuilder().name("ore.mix.dolomite")
.heightRange(150, 200)
Expand All @@ -575,7 +595,8 @@ public enum OreMixes {
.primary(Materials.Platinum)
.secondary(Materials.Chrome)
.inBetween(Materials.Cooperite)
.sporadic(Materials.Palladium)),
.sporadic(Materials.Palladium)
.localize(Materials.Palladium)),

IridiumMytryl(new OreMixBuilder().name("ore.mix.iridiummytryl")
.heightRange(15, 40)
Expand All @@ -586,7 +607,8 @@ public enum OreMixes {
.primary(Materials.Nickel)
.secondary(Materials.Iridium)
.inBetween(Materials.Palladium)
.sporadic(Materials.Mithril)),
.sporadic(Materials.Mithril)
.localize(Materials.Iridium)),

Osmium(new OreMixBuilder().name("ore.mix.osmium")
.heightRange(5, 30)
Expand All @@ -597,7 +619,8 @@ public enum OreMixes {
.primary(Materials.Nickel)
.secondary(Materials.Osmium)
.inBetween(Materials.Iridium)
.sporadic(Materials.Nickel)),
.sporadic(Materials.Nickel)
.localize(Materials.Osmium)),

SaltPeterElectrotine(new OreMixBuilder().name("ore.mix.saltpeterelectrotine")
.heightRange(5, 45)
Expand All @@ -609,7 +632,8 @@ public enum OreMixes {
.primary(Materials.Saltpeter)
.secondary(Materials.Diatomite)
.inBetween(Materials.Electrotine)
.sporadic(Materials.Alunite)),
.sporadic(Materials.Alunite)
.localize(Materials.Electrotine)),

Desh(new OreMixBuilder().name("ore.mix.desh")
.heightRange(5, 40)
Expand Down Expand Up @@ -708,7 +732,8 @@ public enum OreMixes {
.primary(Materials.Gold)
.secondary(Materials.Gold)
.inBetween(Materials.InfusedGold)
.sporadic(Materials.Platinum)),
.sporadic(Materials.Platinum)
.localize(Materials.InfusedGold)),

Niobium(new OreMixBuilder().name("ore.mix.niobium")
.heightRange(5, 30)
Expand Down Expand Up @@ -763,7 +788,8 @@ public enum OreMixes {
.primary(Materials.GarnetSand)
.secondary(Materials.NetherStar)
.inBetween(Materials.GarnetRed)
.sporadic(Materials.GarnetYellow)),
.sporadic(Materials.GarnetYellow)
.localize(Materials.NetherStar)),

Garnet(new OreMixBuilder().name("ore.mix.garnet")
.heightRange(10, 30)
Expand All @@ -785,7 +811,8 @@ public enum OreMixes {
.primary(Materials.Cadmium)
.secondary(Materials.Caesium)
.inBetween(Materials.Lanthanum)
.sporadic(Materials.Cerium)),
.sporadic(Materials.Cerium)
.localize(Materials.RareEarth)),

RichNuclear(new OreMixBuilder().name("ore.mix.richnuclear")
.heightRange(55, 120)
Expand All @@ -796,7 +823,8 @@ public enum OreMixes {
.primary(Materials.Uranium)
.secondary(Materials.Plutonium)
.inBetween(Materials.Thorium)
.sporadic(Materials.Thorium)),
.sporadic(Materials.Thorium)
.localize(Materials.Plutonium)),

HeavyPentele(new OreMixBuilder().name("ore.mix.heavypentele")
.heightRange(40, 60)
Expand Down Expand Up @@ -851,7 +879,8 @@ public enum OreMixes {
.primary(Materials.Quartzite)
.secondary(Materials.Barite)
.inBetween(Materials.CertusQuartz)
.sporadic(Materials.CertusQuartz)),
.sporadic(Materials.CertusQuartz)
.localize(Materials.Quartz)),

Rutile(new OreMixBuilder().name("ore.mix.rutile")
.heightRange(5, 20)
Expand All @@ -874,7 +903,8 @@ public enum OreMixes {
.primary(Materials.Galena)
.secondary(Materials.Silver)
.inBetween(Materials.Lead)
.sporadic(Materials.Cryolite)),
.sporadic(Materials.Cryolite)
.localize(Materials.Cryolite)),

LuVTantalite(new OreMixBuilder().name("ore.mix.luvtantalite")
.heightRange(20, 30)
Expand Down Expand Up @@ -907,7 +937,8 @@ public enum OreMixes {
.primary(Materials.Neutronium)
.secondary(Materials.Adamantium)
.inBetween(Materials.InfinityCatalyst)
.sporadic(Materials.Bedrockium)),
.sporadic(Materials.Bedrockium)
.localize(Materials.InfinityCatalyst)),

CosmicNeutronium(new OreMixBuilder().name("ore.mix.cosmicneutronium")
.heightRange(5, 20)
Expand All @@ -918,7 +949,8 @@ public enum OreMixes {
.primary(Materials.Neutronium)
.secondary(Materials.CosmicNeutronium)
.inBetween(Materials.BlackPlutonium)
.sporadic(Materials.Bedrockium)),
.sporadic(Materials.Bedrockium)
.localize(Materials.CosmicNeutronium)),

Dilithium(new OreMixBuilder().name("ore.mix.dilithium")
.heightRange(30, 100)
Expand All @@ -940,7 +972,8 @@ public enum OreMixes {
.primary(Materials.Naquadah)
.secondary(Materials.NaquadahEnriched)
.inBetween(Materials.Naquadria)
.sporadic(Materials.Trinium)),
.sporadic(Materials.Trinium)
.localize(Materials.Naquadria)),

AwakenedDraconium(new OreMixBuilder().name("ore.mix.awakeneddraconium")
.heightRange(20, 40)
Expand All @@ -951,7 +984,8 @@ public enum OreMixes {
.primary(Materials.Draconium)
.secondary(Materials.Draconium)
.inBetween(Materials.DraconiumAwakened)
.sporadic(Materials.NetherStar)),
.sporadic(Materials.NetherStar)
.localize(Materials.DraconiumAwakened)),

Tengam(new OreMixBuilder().name("ore.mix.tengam")
.heightRange(30, 180)
Expand Down
35 changes: 34 additions & 1 deletion src/main/java/gregtech/common/OreMixBuilder.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package gregtech.common;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -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;
Expand Down Expand Up @@ -65,6 +67,10 @@ public OreMixBuilder size(int size) {

public OreMixBuilder primary(Materials primary) {
this.primary = primary;
if (representative == null || localizedName == null) {
representative = primary;
localizedName = primary.mLocalizedName;
}
return this;
}

Expand All @@ -83,4 +89,31 @@ public OreMixBuilder sporadic(Materials sporadic) {
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;
}
}
Loading

0 comments on commit b46b9b6

Please sign in to comment.