aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/pers/gwyog/gtneioreplugin/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/pers/gwyog/gtneioreplugin/util')
-rw-r--r--src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java229
-rw-r--r--src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java159
-rw-r--r--src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java199
-rw-r--r--src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java139
-rw-r--r--src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java195
-rw-r--r--src/main/java/pers/gwyog/gtneioreplugin/util/GT5UndergroundFluidHelper.java146
-rw-r--r--src/main/java/pers/gwyog/gtneioreplugin/util/OreVeinLayer.java18
-rw-r--r--src/main/java/pers/gwyog/gtneioreplugin/util/Oremix.java600
-rw-r--r--src/main/java/pers/gwyog/gtneioreplugin/util/StringPaddingHack.java131
-rw-r--r--src/main/java/pers/gwyog/gtneioreplugin/util/Veinrenamer.java23
-rw-r--r--src/main/java/pers/gwyog/gtneioreplugin/util/XtoBool.java33
11 files changed, 1872 insertions, 0 deletions
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java b/src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java
new file mode 100644
index 0000000000..1a56044219
--- /dev/null
+++ b/src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java
@@ -0,0 +1,229 @@
+package pers.gwyog.gtneioreplugin.util;
+
+import java.io.BufferedWriter;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import com.opencsv.CSVWriter;
+import com.opencsv.bean.ColumnPositionMappingStrategy;
+import com.opencsv.bean.StatefulBeanToCsv;
+import com.opencsv.bean.StatefulBeanToCsvBuilder;
+
+import pers.gwyog.gtneioreplugin.GTNEIOrePlugin;
+import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5VeinStat;
+import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper.OreLayerWrapper;
+
+public class CSVMaker implements Runnable {
+
+ public CSVMaker() {}
+
+ public static List<Oremix> Combsort(List<Oremix> list) {
+ try {
+ List<Oremix> list2 = new ArrayList<>(list.size());
+ list2.addAll(list);
+
+ int step = list2.size();
+ boolean swapped;
+ do {
+ swapped = false;
+ if (step > 1) {
+ step = (int) (step / 1.3);
+ }
+ for (int i = 0; i < list2.size() - step; i++) {
+ if (list2.get(i).getOreName().substring(0, 3)
+ .compareTo((list2.get(i + step).getOreName().substring(0, 3))) > 0) {
+ Oremix tmp = list2.get(i);
+ list2.set(i, list2.get(i + step));
+ list2.set(i + step, tmp);
+ swapped = true;
+ }
+ }
+ } while (swapped || step > 1);
+ return list2;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public void runSmallOres() {
+ try {
+ Iterator<Map.Entry<String, GT5OreSmallHelper.OreSmallWrapper>> it = GT5OreSmallHelper.mapOreSmallWrapper
+ .entrySet().iterator();
+ List<Oremix> OreVeins = new ArrayList<>();
+ while (it.hasNext()) {
+ Oremix oremix = new Oremix();
+
+ Map.Entry<String, GT5OreSmallHelper.OreSmallWrapper> pair = it.next();
+ String Dims = GT5OreSmallHelper.bufferedDims.get(pair.getValue());
+ GT5OreSmallHelper.OreSmallWrapper oreLayer = pair.getValue();
+ oremix.setOreName(oreLayer.oreGenName.split("\\.")[2]);
+ oremix.setHeight(oreLayer.worldGenHeightRange);
+ oremix.setDensity(oreLayer.amountPerChunk);
+ oremix.an = Dims.contains("An");
+ oremix.as = Dims.contains("As");
+ oremix.bc = Dims.contains("BC");
+ oremix.be = Dims.contains("BE");
+ oremix.bf = Dims.contains("BF");
+ oremix.ca = Dims.contains("Ca");
+ oremix.cb = Dims.contains("CA");
+ oremix.ce = Dims.contains("Ce");
+ oremix.dd = Dims.contains("DD");
+ oremix.de = Dims.contains("De");
+ oremix.ea = Dims.contains("EA");
+ oremix.en = Dims.contains("En");
+ oremix.eu = Dims.contains("Eu");
+ oremix.ga = Dims.contains("Ga");
+ oremix.ha = Dims.contains("Ha");
+ oremix.ho = Dims.contains("Ho");
+ oremix.io = Dims.contains("Io");
+ oremix.kb = Dims.contains("KB");
+ oremix.make = Dims.contains("MM");
+ oremix.ma = Dims.contains("Ma");
+ oremix.mb = Dims.contains("MB");
+ oremix.me = Dims.contains("Me");
+ oremix.mh = Dims.contains("Mh");
+ oremix.mi = Dims.contains("Mi");
+ oremix.mo = Dims.contains("Mo");
+ oremix.np = Dims.contains("Np");
+ oremix.ob = Dims.contains("Ob");
+ oremix.ph = Dims.contains("Ph");
+ oremix.pl = Dims.contains("Pl");
+ oremix.pr = Dims.contains("Pr");
+ oremix.se = Dims.contains("Se");
+ oremix.tcetie = Dims.contains("TE");
+ oremix.tf = Dims.contains("TF");
+ oremix.ti = Dims.contains("Ti");
+ oremix.tr = Dims.contains("Tr");
+ oremix.vb = Dims.contains("VB");
+ oremix.ve = Dims.contains("Ve");
+ oremix.setOverworld(Dims.contains("Ow"));
+ oremix.setNether(Dims.contains("Ne"));
+ oremix.setEnd(Dims.contains("EN"));
+ OreVeins.add(oremix);
+
+ System.out.println(pair.getKey() + " = " + pair.getValue());
+ it.remove(); // avoids a ConcurrentModificationException
+ }
+ BufferedWriter one = Files.newBufferedWriter(Paths.get(GTNEIOrePlugin.CSVnameSmall));
+ ColumnPositionMappingStrategy<Oremix> strat = new ColumnPositionMappingStrategy<>();
+ strat.setType(Oremix.class);
+ String[] columns = "ORENAME,mix,DENSITY,overworld,nether,end,ea,tf,mo,ma,ph,de,as,ce,eu,ga,ca,io,ve,me,en,ti,mi,ob,pr,tr,pl,kb,ha,make,dd,cb,vb,bc,be,bf,tcetie,an,ho,np,mh,mb,se"
+ .split("\\,");
+ strat.setColumnMapping(columns);
+ StatefulBeanToCsv<Oremix> beanToCsv = new StatefulBeanToCsvBuilder<Oremix>(one)
+ .withQuotechar(CSVWriter.NO_QUOTE_CHARACTER).withMappingStrategy(strat).build();
+ List<Oremix> towrite = Combsort(OreVeins);
+ one.write(
+ "Ore Name,Primary,Secondary,Inbetween,Around,ID,Tier,Height,Density,Size,Weight,Overworld,Nether,End,End Asteroids,Twilight Forest,Moon,Mars,Phobos,Deimos,Asteroids,Ceres,Europa,Ganymede,Callisto,Io,Venus,Mercury,Enceladus,Titan,Miranda,Oberon,Proteus,Triton,Pluto,Kuiper Belt,Haumea,Makemake,Deep Dark,Centauri Bb,Vega B,Barnard C,Barnard E,Barnard F,T Ceti E,Anubis,Horus,Neper,Maahes,Mehen Belt,Seth");
+ one.newLine();
+ beanToCsv.write(towrite);
+ one.flush();
+ one.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void run() {
+ runVeins();
+ runSmallOres();
+ }
+
+ public void runVeins() {
+ try {
+ Iterator<Map.Entry<String, OreLayerWrapper>> it = GT5OreLayerHelper.mapOreLayerWrapper.entrySet()
+ .iterator();
+ List<Oremix> OreVeins = new ArrayList<>();
+ while (it.hasNext()) {
+ Oremix oremix = new Oremix();
+
+ Map.Entry<String, OreLayerWrapper> pair = it.next();
+ String Dims = GT5OreLayerHelper.bufferedDims.get(pair.getValue());
+ OreLayerWrapper oreLayer = pair.getValue();
+ oremix.setOreName(oreLayer.veinName.split("\\.")[2]);
+ oremix.setPrimary(PluginGT5VeinStat.getGTOreLocalizedName(oreLayer.Meta[0]));
+ oremix.setSecondary(PluginGT5VeinStat.getGTOreLocalizedName(oreLayer.Meta[1]));
+ oremix.setInbetween(PluginGT5VeinStat.getGTOreLocalizedName(oreLayer.Meta[2]));
+ oremix.setAround(PluginGT5VeinStat.getGTOreLocalizedName(oreLayer.Meta[3]));
+ oremix.setSize(oreLayer.size);
+ oremix.setHeight(oreLayer.worldGenHeightRange);
+ oremix.setDensity(oreLayer.density);
+ oremix.setWeight(oreLayer.randomWeight);
+ oremix.setMix(
+ Integer.toString(oreLayer.Meta[0]) + "|"
+ + Integer.toString(oreLayer.Meta[1])
+ + "|"
+ + Integer.toString(oreLayer.Meta[2])
+ + "|"
+ + Integer.toString(oreLayer.Meta[3]));
+ oremix.an = Dims.contains("An");
+ oremix.as = Dims.contains("As");
+ oremix.bc = Dims.contains("BC");
+ oremix.be = Dims.contains("BE");
+ oremix.bf = Dims.contains("BF");
+ oremix.ca = Dims.contains("Ca");
+ oremix.cb = Dims.contains("CA");
+ oremix.ce = Dims.contains("Ce");
+ oremix.dd = Dims.contains("DD");
+ oremix.de = Dims.contains("De");
+ oremix.ea = Dims.contains("EA");
+ oremix.en = Dims.contains("En");
+ oremix.eu = Dims.contains("Eu");
+ oremix.ga = Dims.contains("Ga");
+ oremix.ha = Dims.contains("Ha");
+ oremix.ho = Dims.contains("Ho");
+ oremix.io = Dims.contains("Io");
+ oremix.kb = Dims.contains("KB");
+ oremix.make = Dims.contains("MM");
+ oremix.ma = Dims.contains("Ma");
+ oremix.mb = Dims.contains("MB");
+ oremix.me = Dims.contains("Me");
+ oremix.mh = Dims.contains("Mh");
+ oremix.mi = Dims.contains("Mi");
+ oremix.mo = Dims.contains("Mo");
+ oremix.np = Dims.contains("Np");
+ oremix.ob = Dims.contains("Ob");
+ oremix.ph = Dims.contains("Ph");
+ oremix.pl = Dims.contains("Pl");
+ oremix.pr = Dims.contains("Pr");
+ oremix.se = Dims.contains("Se");
+ oremix.tcetie = Dims.contains("TE");
+ oremix.tf = Dims.contains("TF");
+ oremix.ti = Dims.contains("Ti");
+ oremix.tr = Dims.contains("Tr");
+ oremix.vb = Dims.contains("VB");
+ oremix.ve = Dims.contains("Ve");
+ oremix.setOverworld(Dims.contains("Ow"));
+ oremix.setNether(Dims.contains("Ne"));
+ oremix.setEnd(Dims.contains("EN"));
+ OreVeins.add(oremix);
+
+ System.out.println(pair.getKey() + " = " + pair.getValue());
+ it.remove(); // avoids a ConcurrentModificationException
+ }
+ BufferedWriter one = Files.newBufferedWriter(Paths.get(GTNEIOrePlugin.CSVname));
+ ColumnPositionMappingStrategy<Oremix> strat = new ColumnPositionMappingStrategy<>();
+ strat.setType(Oremix.class);
+ String[] columns = "ORENAME,PRIMARY,SECONDARY,INBETWEEN,AROUND,mix,TIER,HEIGHT,DENSITY,SIZE,WEIGHT,overworld,nether,end,ea,tf,mo,ma,ph,de,as,ce,eu,ga,ca,io,ve,me,en,ti,mi,ob,pr,tr,pl,kb,ha,make,dd,cb,vb,bc,be,bf,tcetie,an,ho,np,mh,mb,se"
+ .split("\\,");
+ strat.setColumnMapping(columns);
+ StatefulBeanToCsv<Oremix> beanToCsv = new StatefulBeanToCsvBuilder<Oremix>(one)
+ .withQuotechar(CSVWriter.NO_QUOTE_CHARACTER).withMappingStrategy(strat).build();
+ List<Oremix> towrite = Combsort(OreVeins);
+ one.write(
+ "Ore Name,Primary,Secondary,Inbetween,Around,ID,Tier,Height,Density,Size,Weight,Overworld,Nether,End,End Asteroids,Twilight Forest,Moon,Mars,Phobos,Deimos,Asteroids,Ceres,Europa,Ganymede,Callisto,Io,Venus,Mercury,Enceladus,Titan,Miranda,Oberon,Proteus,Triton,Pluto,Kuiper Belt,Haumea,Makemake,Deep Dark,Centauri Bb,Vega B,Barnard C,Barnard E,Barnard F,T Ceti E,Anubis,Horus,Neper,Maahes,Mehen Belt,Seth");
+ one.newLine();
+ beanToCsv.write(towrite);
+ one.flush();
+ one.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java
new file mode 100644
index 0000000000..b82cb63f58
--- /dev/null
+++ b/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java
@@ -0,0 +1,159 @@
+package pers.gwyog.gtneioreplugin.util;
+
+import static pers.gwyog.gtneioreplugin.GTNEIOrePlugin.maxTooltipLines;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+
+import net.minecraft.util.StatCollector;
+
+public class DimensionHelper {
+
+ public static final String[] DimName = {
+ // Non GC dimensions in progression order instead of alphabetical
+ "Overworld", "Nether", "Twilight", "TheEnd", "Vanilla_EndAsteroids", "EndAsteroid",
+ // T1
+ "GalacticraftCore_Moon",
+ // T2
+ "GalaxySpace_Deimos", "GalacticraftMars_Mars", "GalaxySpace_Phobos",
+ // T3
+ "GalacticraftMars_Asteroids", "GalaxySpace_Callisto", "GalaxySpace_Ceres", "GalaxySpace_Europa",
+ "GalaxySpace_Ganymede", "Ross128b",
+ // T4
+ "GalaxySpace_Io", "GalaxySpace_Mercury", "GalaxySpace_Venus",
+ // T5
+ "GalaxySpace_Enceladus", "GalaxySpace_Miranda", "GalaxySpace_Oberon", "GalaxySpace_Titan", "Ross128ba",
+ // T6
+ "GalaxySpace_Proteus", "GalaxySpace_Triton",
+ // T7
+ "GalaxySpace_Haumea", "GalaxySpace_Kuiperbelt", "GalaxySpace_MakeMake", "GalaxySpace_Pluto",
+ // T8
+ "GalaxySpace_BarnardC", "GalaxySpace_BarnardE", "GalaxySpace_BarnardF", "GalaxySpace_CentauriA",
+ "GalaxySpace_TcetiE", "GalaxySpace_VegaB",
+ // T9
+ "GalacticraftAmunRa_Anubis", "GalacticraftAmunRa_Horus", "GalacticraftAmunRa_Maahes",
+ "GalacticraftAmunRa_MehenBelt", "GalacticraftAmunRa_Neper", "GalacticraftAmunRa_Seth",
+ // T10
+ "Underdark", };
+
+ public static final String[] DimNameTrimmed = Arrays.stream(DimName)
+ .map(
+ n -> n.replaceAll("GalacticraftCore_", "").replaceAll("GalacticraftMars_", "")
+ .replaceAll("GalaxySpace_", "").replaceAll("GalacticraftAmunRa_", "")
+ .replaceAll("Vanilla_", "Vanilla "))
+ .toArray(String[]::new);
+
+ public static final String[] DimNameDisplayed = { // first 2 letters if one word else 1 letter of every word, except
+ // capital letter in
+ // name, then 1rst + capital Moon = Mo, BarnardC = BC, EndAsteroid = EA
+ // Non GC dimensions in progression order instead of alphabetical
+ "Ow", // Overworld
+ "Ne", // Nether
+ "TF", // Twilight
+ "ED", // TheEnd because En = Encalus
+ "VA", // Vanilla_EndAsteroids
+ "EA", // EndAsteroid
+ // T1
+ "Mo", // GalacticraftCore_Moon
+ // T2
+ "De", // GalaxySpace_Deimos
+ "Ma", // GalacticraftMars_Mars
+ "Ph", // GalaxySpace_Phobos
+ // T3
+ "As", // GalacticraftMars_Asteroids
+ "Ca", // GalaxySpace_Callisto
+ "Ce", // GalaxySpace_Ceres
+ "Eu", // GalaxySpace_Europa
+ "Ga", // GalaxySpace_Ganymede
+ "Rb", // Ross128b
+ // T4
+ "Io", // GalaxySpace_Io
+ "Me", // GalaxySpace_Mercury
+ "Ve", // GalaxySpace_Venus
+ // T5
+ "En", // GalaxySpace_Enceladus
+ "Mi", // GalaxySpace_Miranda
+ "Ob", // GalaxySpace_Oberon
+ "Ti", // GalaxySpace_Titan
+ "Ra", // Ross128ba
+ // T6
+ "Pr", // GalaxySpace_Proteus
+ "Tr", // GalaxySpace_Triton
+ // T7
+ "Ha", // GalaxySpace_Haumea
+ "KB", // GalaxySpace_Kuiperbelt
+ "MM", // GalaxySpace_MakeMake
+ "Pl", // GalaxySpace_Pluto
+ // T8
+ "BC", // GalaxySpace_BarnardC
+ "BE", // GalaxySpace_BarnardE
+ "BF", // GalaxySpace_BarnardF
+ "CB", // GalaxySpace_CentauriA is actually α Centauri Bb
+ "TE", // GalaxySpace_TcetiE
+ "VB", // GalaxySpace_VegaB
+ // T9
+ "An", // GalacticraftAmunRa_Anubis
+ "Ho", // GalacticraftAmunRa_Horus
+ "Mh", // GalacticraftAmunRa_Maahes
+ "MB", // GalacticraftAmunRa_MehenBelt
+ "Np", // GalacticraftAmunRa_Neper
+ "Se", // GalacticraftAmunRa_Seth
+ // T10
+ "DD", // Underdark
+ };
+
+ private static final HashMap<String, List<String>> tooltipBuffer = new HashMap<>();
+
+ private static List<String> computeString(String line) {
+ String[] dims = parseDimNames(line);
+ for (int j = 0; j < dims.length; j++) {
+ String s = dims[j];
+ for (int i = 0; i < DimNameDisplayed.length; i++) {
+ if (s.equals(DimNameDisplayed[i])) {
+ String k = DimNameTrimmed[i];
+ s = StatCollector.translateToLocal("gtnop.world." + k);
+ s = switch (k) {
+ case "Moon" -> "T1: " + s;
+ case "Deimos", "Mars", "Phobos" -> "T2: " + s;
+ case "Asteroids", "Callisto", "Ceres", "Europa", "Ganymede", "Ross128b" -> "T3: " + s;
+ case "Io", "Mercury", "Venus" -> "T4: " + s;
+ case "Enceladus", "Miranda", "Oberon", "Titan", "Ross128ba" -> "T5: " + s;
+ case "Proteus", "Triton" -> "T6: " + s;
+ case "Haumea", "Kuiperbelt", "MakeMake", "Pluto" -> "T7: " + s;
+ case "BarnardC", "BarnardE", "BarnardF", "CentauriA", "TcetiE", "VegaB" -> "T8: " + s;
+ case "Anubis", "Horus", "Maahes", "MehenBelt", "Neper", "Seth" -> "T9: " + s;
+ case "Underdark" -> "T10: " + s;
+ default -> s;
+ };
+
+ dims[j] = s;
+ }
+ }
+ }
+
+ if (dims.length > maxTooltipLines) {
+ dims = StringPaddingHack.stringsToSpacedColumns(
+ dims,
+ dims.length / maxTooltipLines + (dims.length % maxTooltipLines == 0 ? 0 : 1),
+ 2);
+ }
+
+ return Arrays.asList(dims);
+ }
+
+ public static String[] parseDimNames(String line) {
+ String[] dims = line.split(",");
+ for (int j = 0; j < dims.length; j++) {
+ String s = dims[j];
+ s = s.replaceAll(",", "");
+ s = s.trim();
+ dims[j] = s;
+ }
+ return dims;
+ }
+
+ public static List<String> convertCondensedStringToToolTip(String line) {
+ return tooltipBuffer.computeIfAbsent(line, (String tmp) -> computeString(line));
+ }
+}
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java
new file mode 100644
index 0000000000..ebc9956af1
--- /dev/null
+++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java
@@ -0,0 +1,199 @@
+package pers.gwyog.gtneioreplugin.util;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+
+import net.minecraftforge.common.config.ConfigCategory;
+import net.minecraftforge.common.config.Configuration;
+import net.minecraftforge.common.config.Property;
+
+import cpw.mods.fml.common.FMLLog;
+import gregtech.api.GregTech_API;
+import pers.gwyog.gtneioreplugin.GTNEIOrePlugin;
+
+public class GT5CFGHelper {
+
+ // Do NOT ever put a comma in this or it will break split calls later in the code. Bad, but it is what it is.
+ public static final String oreVeinNotInAnyDim = "Not available in any Galactic Dim!";
+
+ private static final File F = GregTech_API.sWorldgenFile.mConfig.getConfigFile();
+
+ public static String GT5CFGSmallOres(String Veinname) {
+ List<String> raw = new ArrayList<>();
+ List<String> rawbools = new ArrayList<>();
+ String st;
+ Configuration c = new Configuration(F);
+ ConfigCategory configCategory = c.getCategory("worldgen." + Veinname);
+ for (Property p : configCategory.getOrderedValues()) {
+ if (p.isBooleanValue() && p.getBoolean()) {
+ raw.add(p.getName() + "=" + p.getBoolean());
+ }
+ }
+ if (!raw.isEmpty()) {
+ for (String s : raw) {
+ for (int j = 0; j < DimensionHelper.DimName.length; j++) {
+ if (s.contains(DimensionHelper.DimName[j])) {
+ rawbools.add(s);
+ }
+ }
+ }
+ } else GTNEIOrePlugin.LOG.info("Config entry not found for Vein: " + Veinname);
+
+ StringBuilder ret = new StringBuilder(" ");
+
+ HashSet<String> rawboolsset = new HashSet<>();
+ if (!rawbools.isEmpty()) {
+ for (String rawbool : rawbools) {
+ st = rawbool.replace("B:", "").replace("_true", "").replace("_false", "").replaceAll(" ", "")
+ .replaceAll("\"", "");
+ rawboolsset.add(st);
+ }
+ rawbools = new ArrayList<>(rawboolsset);
+ for (int j = 0; j < DimensionHelper.DimName.length; j++) {
+ for (String rawbool : rawbools) {
+ st = rawbool;
+ if (st.contains(DimensionHelper.DimName[j]) && st.contains("=true")) {
+ ret.append(DimensionHelper.DimNameDisplayed[j]).append(",");
+ }
+ }
+ }
+ }
+ ret = new StringBuilder(ret.toString().trim());
+ if (ret.toString().equals("") || ret.toString().equals(" ")) {
+ ret = new StringBuilder(oreVeinNotInAnyDim);
+ }
+ return ret.toString();
+ }
+
+ public static String GT5CFG(String Veinname) {
+ // FMLLog.info(Veinname);
+ if (F == null) {
+ FMLLog.bigWarning("GT_CFG_NOT_found[0]");
+ return "Error while Loading CFG";
+ } else try {
+ int buffer = (int) (0.1 * Runtime.getRuntime().freeMemory());
+ if (buffer > F.length()) {
+ buffer = (int) F.length();
+ }
+ // allocate 10% of free memory for read-in-buffer, if there is less than filesize memory available
+ // FMLLog.info("GT_CFG_found[0]");
+ FileReader in = new FileReader(F);
+ // FMLLog.info("FileReader created");
+ BufferedReader reader = new BufferedReader(in, buffer);
+ // FMLLog.info("BufferedReader" +Integer.toString(buffer)+"created");
+ String st;
+ List<String> raw = new ArrayList<>();
+ List<String> rawbools = new ArrayList<>();
+ Boolean[] found = new Boolean[2];
+ found[0] = false;
+ found[1] = false;
+
+ do {
+ // FMLLog.info("erste");
+ // read until reached eof or mix {
+ st = reader.readLine();
+ // FMLLog.info("st: "+st);
+ if (st != null && st.trim().equals("mix {")) {
+ while (!(st == null || found[0])) {
+ // FMLLog.info("zweite");
+ st = reader.readLine();
+ // read until reached eof or Veinname {
+ // FMLLog.info("MIXst: "+st);
+ if (st != null && st.trim().equals(Veinname + " {")) {
+ // FMLLog.info("VEINNAMEst: "+st);
+ while (!(st == null || found[0])) {
+ st = reader.readLine();
+ if ((!(st == null)) && st.trim().equals("}")) {
+ found[0] = true;
+ }
+ // FMLLog.info("dritte");
+ // add everything below Veinname { undtil } to raw
+ raw.add(st);
+ }
+ }
+ }
+ }
+
+ if (st != null && st.trim().equals("dimensions {")) {
+ while (!(st == null || found[1])) {
+ // FMLLog.info("zweite");
+ st = reader.readLine();
+ if (st != null && (st.trim().equals("mix {"))) {
+ while (!(st == null || found[1])) {
+ // FMLLog.info("dritte");
+ st = reader.readLine();
+ // read until reached eof or Veinname {
+ // FMLLog.info("MIXst: "+st);
+ if (st != null && st.trim().equals(Veinname + " {")) {
+ // FMLLog.info("VEINNAMEst: "+st);
+ while (!(st == null || found[1])) {
+ st = reader.readLine();
+ if ((!(st == null)) && st.trim().equals("}")) {
+ found[1] = true;
+ }
+ // FMLLog.info("vierte");
+ // add everything below Veinname { undtil } to raw
+ raw.add(st);
+ }
+ }
+ }
+ }
+ }
+ }
+ } while (st != null);
+ reader.close(); // not needed anymore
+
+ if (!raw.isEmpty()) {
+ for (String s : raw) {
+ // filter needed booleans from raw
+ /// FMLLog.info("raw contains"+raw.get(i));
+ for (int j = 0; j < DimensionHelper.DimName.length; j++) {
+ if (s.contains(DimensionHelper.DimName[j])) {
+ rawbools.add(s);
+ }
+ }
+ // FMLLog.info("rawbools: "+rawbools.get(i));
+ }
+ } else {
+ GTNEIOrePlugin.LOG.info("Config entry not found for Vein: " + Veinname);
+ }
+
+ StringBuilder ret = new StringBuilder(" ");
+
+ HashSet<String> rawboolsset = new HashSet<>();
+ if (!rawbools.isEmpty()) {
+ // remove dublicates
+ for (String rawbool : rawbools) {
+ st = rawbool.replace("B:", "").replace("_true", "").replace("_false", "").replaceAll(" ", "")
+ .replaceAll("\"", "");
+ rawboolsset.add(st);
+ }
+ rawbools = new ArrayList<>(rawboolsset);
+ // filter for dims set to true
+ for (int j = 0; j < DimensionHelper.DimName.length; j++) {
+ // FMLLog.info("RawBools:"+st);
+ for (String rawbool : rawbools) {
+ st = rawbool;
+ if (st.contains(DimensionHelper.DimName[j]) && st.contains("=true")) {
+ ret.append(DimensionHelper.DimNameDisplayed[j]).append(",");
+ }
+ }
+ }
+ }
+ ret = new StringBuilder(ret.toString().trim());
+ // FMLLog.info("ret:"+ret);
+ if (ret.toString().equals("") || ret.toString().equals(" ")) {
+ ret = new StringBuilder(oreVeinNotInAnyDim);
+ }
+ return ret.toString();
+ } catch (IOException e) {
+ e.printStackTrace();
+ return "Error while Loading CFG";
+ }
+ }
+}
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java
new file mode 100644
index 0000000000..c2c4fa9800
--- /dev/null
+++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java
@@ -0,0 +1,139 @@
+package pers.gwyog.gtneioreplugin.util;
+
+import static pers.gwyog.gtneioreplugin.util.GT5CFGHelper.oreVeinNotInAnyDim;
+import static pers.gwyog.gtneioreplugin.util.OreVeinLayer.*;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+
+import net.minecraft.item.ItemStack;
+
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.Materials;
+import gregtech.api.objects.ItemData;
+import gregtech.api.util.GT_OreDictUnificator;
+import gregtech.common.GT_Worldgen_GT_Ore_Layer;
+
+public class GT5OreLayerHelper {
+
+ public static class NormalOreDimensionWrapper {
+
+ public final ArrayList<OreLayerWrapper> internalDimOreList = new ArrayList<>();
+ public final HashMap<OreLayerWrapper, Double> oreVeinToProbabilityInDimension = new HashMap<>();
+
+ // Calculate all weights of ore veins once dimension is initialised.
+ private void calculateWeights() {
+ int totalWeight = 0;
+ for (OreLayerWrapper oreVein : internalDimOreList) {
+ totalWeight += oreVein.randomWeight;
+ }
+ for (OreLayerWrapper oreVein : internalDimOreList) {
+ oreVeinToProbabilityInDimension.put(oreVein, ((double) oreVein.randomWeight) / ((double) totalWeight));
+ }
+ }
+ }
+
+ private static final int DIMENSION_COUNT = 33;
+ public static final Integer[] weightPerWorld = new Integer[DIMENSION_COUNT];
+ public static final Integer[] DimIDs = new Integer[DIMENSION_COUNT];
+ public static final HashMap<String, OreLayerWrapper> mapOreLayerWrapper = new HashMap<>();
+ public static final HashMap<OreLayerWrapper, String> bufferedDims = new HashMap<>();
+ public static final HashMap<String, NormalOreDimensionWrapper> dimToOreWrapper = new HashMap<>();
+
+ public static void init() {
+ Arrays.fill(weightPerWorld, 0);
+ Arrays.fill(DimIDs, 0);
+ for (GT_Worldgen_GT_Ore_Layer tWorldGen : GT_Worldgen_GT_Ore_Layer.sList)
+ mapOreLayerWrapper.put(tWorldGen.mWorldGenName, new OreLayerWrapper(tWorldGen));
+ for (OreLayerWrapper layer : mapOreLayerWrapper.values()) {
+ bufferedDims.put(layer, getDims(layer));
+ }
+
+ // --- Handling of dimToOreWrapper ---
+
+ // Get dims as "Ow,Ne,Ma" etc.
+ bufferedDims.forEach((veinInfo, dims) -> {
+ if (dims.equals(oreVeinNotInAnyDim)) {
+ return;
+ }
+
+ for (String dim : dims.split(",")) {
+ if (!dim.isEmpty()) {
+ NormalOreDimensionWrapper dimensionOres = dimToOreWrapper
+ .getOrDefault(dim, new NormalOreDimensionWrapper());
+ dimensionOres.internalDimOreList.add(veinInfo);
+ dimToOreWrapper.put(dim, dimensionOres);
+ }
+ }
+
+ // Calculate probabilities for each dim.
+ for (String dim : dimToOreWrapper.keySet()) {
+ dimToOreWrapper.get(dim).calculateWeights();
+ }
+ });
+ // --- End of handling for dimToOreWrapper ---
+ }
+
+ public static String getDims(OreLayerWrapper oreLayer) {
+ return GT5CFGHelper.GT5CFG(oreLayer.veinName.replace("ore.mix.custom" + ".", "").replace("ore.mix.", ""));
+ }
+
+ public static class OreLayerWrapper {
+
+ public final String veinName, worldGenHeightRange;
+ public final short[] Meta = new short[4];
+ public final short randomWeight, size, density;
+
+ public final Materials mPrimaryVeinMaterial;
+ public final Materials mSecondaryMaterial;
+ public final Materials mBetweenMaterial;
+ public final Materials mSporadicMaterial;
+
+ public OreLayerWrapper(GT_Worldgen_GT_Ore_Layer worldGen) {
+ this.veinName = worldGen.mWorldGenName;
+ this.Meta[0] = worldGen.mPrimaryMeta;
+ this.Meta[1] = worldGen.mSecondaryMeta;
+ this.Meta[2] = worldGen.mBetweenMeta;
+ this.Meta[3] = worldGen.mSporadicMeta;
+
+ // Black magic, don't ask me how it works, I have no idea.
+ ItemData primaryVeinData = GT_OreDictUnificator
+ .getAssociation(new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.mPrimaryMeta));
+ this.mPrimaryVeinMaterial = primaryVeinData != null ? primaryVeinData.mMaterial.mMaterial : null;
+ ItemData secondaryVeinData = GT_OreDictUnificator
+ .getAssociation(new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.mSecondaryMeta));
+ this.mSecondaryMaterial = secondaryVeinData != null ? secondaryVeinData.mMaterial.mMaterial : null;
+ ItemData betweenVeinData = GT_OreDictUnificator
+ .getAssociation(new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.mBetweenMeta));
+ this.mBetweenMaterial = betweenVeinData != null ? betweenVeinData.mMaterial.mMaterial : null;
+ ItemData sporadicVeinData = GT_OreDictUnificator
+ .getAssociation(new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.mSporadicMeta));
+ this.mSporadicMaterial = sporadicVeinData != null ? sporadicVeinData.mMaterial.mMaterial : null;
+
+ this.size = worldGen.mSize;
+ this.density = worldGen.mDensity;
+ this.worldGenHeightRange = worldGen.mMinY + "-" + worldGen.mMaxY;
+ this.randomWeight = worldGen.mWeight;
+ }
+
+ public List<ItemStack> getVeinLayerOre(int maximumMaterialIndex, int veinLayer) {
+ List<ItemStack> stackList = new ArrayList<>();
+ for (int i = 0; i < maximumMaterialIndex; i++) {
+ stackList.add(getLayerOre(veinLayer, i));
+ }
+ return stackList;
+ }
+
+ public ItemStack getLayerOre(int veinLayer, int materialIndex) {
+ return new ItemStack(GregTech_API.sBlockOres1, 1, Meta[veinLayer] + materialIndex * 1000);
+ }
+
+ public boolean containsOre(short materialIndex) {
+ return Meta[VEIN_PRIMARY] == materialIndex || Meta[VEIN_SECONDARY] == materialIndex
+ || Meta[VEIN_BETWEEN] == materialIndex
+ || Meta[VEIN_SPORADIC] == materialIndex;
+ }
+ }
+}
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java
new file mode 100644
index 0000000000..8a150967a0
--- /dev/null
+++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java
@@ -0,0 +1,195 @@
+package pers.gwyog.gtneioreplugin.util;
+
+import static pers.gwyog.gtneioreplugin.util.GT5CFGHelper.oreVeinNotInAnyDim;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import net.minecraft.item.ItemStack;
+
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.Materials;
+import gregtech.api.enums.OrePrefixes;
+import gregtech.api.objects.ItemData;
+import gregtech.api.util.GT_OreDictUnificator;
+import gregtech.api.world.GT_Worldgen;
+import gregtech.common.GT_Worldgen_GT_Ore_SmallPieces;
+
+public class GT5OreSmallHelper {
+
+ private static final int SMALL_ORE_BASE_META = 16000;
+ public static boolean restrictBiomeSupport = false;
+ public static final List<ItemStack> oreSmallList = new ArrayList<>();
+ public static final HashMap<String, OreSmallWrapper> mapOreSmallWrapper = new HashMap<>();
+ public static final HashMap<String, Short> mapOreDropUnlocalizedNameToOreMeta = new HashMap<>();
+ public static final HashMap<Short, List<ItemStack>> mapOreMetaToOreDrops = new HashMap<>();
+ public static final HashMap<OreSmallWrapper, String> bufferedDims = new HashMap<>();
+ public static final HashMap<String, SmallOreDimensionWrapper> dimToSmallOreWrapper = new HashMap<>();
+
+ public static class SmallOreDimensionWrapper {
+
+ public final ArrayList<OreSmallWrapper> internalDimOreList = new ArrayList<>();
+ public final HashMap<OreSmallWrapper, Double> oreVeinToProbabilityInDimension = new HashMap<>();
+
+ // Calculate all weights of ore veins once dimension is initialised.
+ private void calculateWeights() {
+ int totalWeight = 0;
+ for (OreSmallWrapper oreVein : internalDimOreList) {
+ totalWeight += oreVein.amountPerChunk;
+ }
+ for (OreSmallWrapper oreVein : internalDimOreList) {
+ oreVeinToProbabilityInDimension
+ .put(oreVein, ((double) oreVein.amountPerChunk) / ((double) totalWeight));
+ }
+ }
+ }
+
+ public static void init() {
+ checkExtraSupport();
+ ItemStack stack;
+ Materials material;
+ short meta;
+ for (GT_Worldgen worldGen : GregTech_API.sWorldgenList)
+ if (worldGen.mWorldGenName.startsWith("ore.small.") && worldGen instanceof GT_Worldgen_GT_Ore_SmallPieces) {
+ GT_Worldgen_GT_Ore_SmallPieces worldGenSmallPieces = (GT_Worldgen_GT_Ore_SmallPieces) worldGen;
+ meta = worldGenSmallPieces.mMeta;
+ if (meta < 0) break;
+ material = GregTech_API.sGeneratedMaterials[meta];
+ mapOreSmallWrapper.put(worldGen.mWorldGenName, new OreSmallWrapper(worldGenSmallPieces));
+ if (!mapOreMetaToOreDrops.containsKey(meta)) {
+ List<ItemStack> stackList = new ArrayList<>();
+ stack = GT_OreDictUnificator.get(
+ OrePrefixes.gemExquisite,
+ material,
+ GT_OreDictUnificator.get(OrePrefixes.gem, material, 1L),
+ 1L);
+ if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.containsKey(stack.getUnlocalizedName())) {
+ mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);
+ stackList.add(stack);
+ }
+ stack = GT_OreDictUnificator.get(
+ OrePrefixes.gemFlawless,
+ material,
+ GT_OreDictUnificator.get(OrePrefixes.gem, material, 1L),
+ 1L);
+ if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.containsKey(stack.getUnlocalizedName())) {
+ mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);
+ stackList.add(stack);
+ }
+ stack = GT_OreDictUnificator.get(OrePrefixes.gem, material, 1L);
+ if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.containsKey(stack.getUnlocalizedName())) {
+ mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);
+ stackList.add(stack);
+ }
+ stack = GT_OreDictUnificator.get(
+ OrePrefixes.gemFlawed,
+ material,
+ GT_OreDictUnificator.get(OrePrefixes.crushed, material, 1L),
+ 1L);
+ if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.containsKey(stack.getUnlocalizedName())) {
+ mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);
+ stackList.add(stack);
+ }
+ stack = GT_OreDictUnificator.get(OrePrefixes.crushed, material, 1L);
+ if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.containsKey(stack.getUnlocalizedName())) {
+ mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);
+ stackList.add(stack);
+ }
+ stack = GT_OreDictUnificator.get(
+ OrePrefixes.gemChipped,
+ material,
+ GT_OreDictUnificator.get(OrePrefixes.dustImpure, material, 1L),
+ 1L);
+ if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.containsKey(stack.getUnlocalizedName())) {
+ mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);
+ stackList.add(stack);
+ }
+ stack = GT_OreDictUnificator.get(OrePrefixes.dustImpure, material, 1L);
+ if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.containsKey(stack.getUnlocalizedName())) {
+ mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);
+ stackList.add(stack);
+ }
+ oreSmallList.add(new ItemStack(GregTech_API.sBlockOres1, 1, meta + SMALL_ORE_BASE_META));
+ mapOreMetaToOreDrops.put(meta, stackList);
+ }
+ }
+ for (OreSmallWrapper oreSmallWrapper : mapOreSmallWrapper.values()) {
+ bufferedDims.put(oreSmallWrapper, GT5CFGHelper.GT5CFGSmallOres(oreSmallWrapper.oreGenName));
+ }
+
+ // --- Handling of dimToOreWrapper ---
+
+ // Get dims as "Ow,Ne,Ma" etc.
+ bufferedDims.forEach((veinInfo, dims) -> {
+ if (dims.equals(oreVeinNotInAnyDim)) {
+ return;
+ }
+
+ for (String dim : dims.split(",")) {
+ if (!dim.isEmpty()) {
+ SmallOreDimensionWrapper dimensionSmallOres = dimToSmallOreWrapper
+ .getOrDefault(dim, new SmallOreDimensionWrapper());
+ dimensionSmallOres.internalDimOreList.add(veinInfo);
+ dimToSmallOreWrapper.put(dim, dimensionSmallOres);
+ }
+ }
+
+ // Calculate probabilities for each dim.
+ for (String dim : dimToSmallOreWrapper.keySet()) {
+ dimToSmallOreWrapper.get(dim).calculateWeights();
+ }
+ });
+ // --- End of handling for dimToOreWrapper ---
+ }
+
+ private static void checkExtraSupport() {
+ Class<?> clazzGTOreSmall = null;
+ try {
+ clazzGTOreSmall = Class.forName("gregtech.common" + ".GT_Worldgen_GT_Ore_SmallPieces");
+ } catch (ClassNotFoundException ignored) {}
+ if (clazzGTOreSmall != null) {
+ try {
+ clazzGTOreSmall.getField("mRestrictBiome");
+ restrictBiomeSupport = true;
+ } catch (Exception ignored) {}
+ }
+ }
+
+ public static Materials[] getDroppedDusts() {
+ return new Materials[] { Materials.Stone, Materials.Netherrack, Materials.Endstone, Materials.GraniteBlack,
+ Materials.GraniteRed, Materials.Marble, Materials.Basalt, Materials.Stone };
+ }
+
+ public static class OreSmallWrapper {
+
+ public final String oreGenName;
+ public final short oreMeta;
+ public final String worldGenHeightRange;
+ public final short amountPerChunk;
+
+ @SuppressWarnings("unused")
+ public Materials getOreMaterial() {
+ return oreMaterial;
+ }
+
+ private final Materials oreMaterial;
+
+ public OreSmallWrapper(GT_Worldgen_GT_Ore_SmallPieces worldGen) {
+ this.oreGenName = worldGen.mWorldGenName;
+ this.oreMeta = worldGen.mMeta;
+ this.worldGenHeightRange = worldGen.mMinY + "-" + worldGen.mMaxY;
+ this.amountPerChunk = worldGen.mAmount;
+ ItemData oreData = GT_OreDictUnificator
+ .getAssociation(new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.mMeta));
+ this.oreMaterial = oreData != null ? oreData.mMaterial.mMaterial : null;
+ }
+
+ public List<ItemStack> getMaterialDrops(int maximumIndex) {
+ List<ItemStack> stackList = new ArrayList<>();
+ for (int i = 0; i < maximumIndex; i++)
+ stackList.add(new ItemStack(GregTech_API.sBlockOres1, 1, oreMeta + SMALL_ORE_BASE_META + i * 1000));
+ return stackList;
+ }
+ }
+}
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5UndergroundFluidHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5UndergroundFluidHelper.java
new file mode 100644
index 0000000000..85c4ee3004
--- /dev/null
+++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5UndergroundFluidHelper.java
@@ -0,0 +1,146 @@
+package pers.gwyog.gtneioreplugin.util;
+
+import static pers.gwyog.gtneioreplugin.GTNEIOrePlugin.LOG;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidRegistry;
+
+import com.google.common.collect.BiMap;
+
+import gregtech.GT_Mod;
+import gregtech.api.objects.GT_UO_Dimension;
+import gregtech.api.objects.GT_UO_DimensionList;
+import gregtech.api.objects.GT_UO_Fluid;
+
+public class GT5UndergroundFluidHelper {
+
+ /**
+ * Need to store fluid name instead of fluid because fluid instance might be different between gas and liquid
+ */
+ private static final Map<String, List<UndergroundFluidWrapper>> fluidMap = new HashMap<>();
+
+ @SuppressWarnings("unchecked")
+ public static void init() {
+ try {
+ Field fieldDimensionList = GT_UO_DimensionList.class.getDeclaredField("fDimensionList");
+ fieldDimensionList.setAccessible(true);
+ BiMap<String, GT_UO_Dimension> dimensionList = (BiMap<String, GT_UO_Dimension>) fieldDimensionList
+ .get(GT_Mod.gregtechproxy.mUndergroundOil);
+ for (Map.Entry<String, GT_UO_Dimension> dimensionEntry : dimensionList.entrySet()) {
+ String rawDimension = dimensionEntry.getKey();
+ String dimension;
+ try {
+ dimension = getDimensionFromID(Integer.parseInt(rawDimension));
+ } catch (NumberFormatException ignored) {
+ dimension = getDimensionForEdgeCase(rawDimension);
+ if (dimension == null) {
+ for (int i = 0; i < DimensionHelper.DimNameTrimmed.length; i++) {
+ if (DimensionHelper.DimNameTrimmed[i].equalsIgnoreCase(rawDimension)) {
+ dimension = DimensionHelper.DimNameDisplayed[i];
+ break;
+ }
+ }
+ }
+ }
+ if (dimension == null) {
+ LOG.warn("Unknown dimension found in GT5 config: " + rawDimension);
+ continue;
+ }
+
+ Field fieldFluids = GT_UO_Dimension.class.getDeclaredField("fFluids");
+ fieldFluids.setAccessible(true);
+ BiMap<String, GT_UO_Fluid> fluids = (BiMap<String, GT_UO_Fluid>) fieldFluids
+ .get(dimensionEntry.getValue());
+
+ int maxChance = 0;
+ for (Map.Entry<String, GT_UO_Fluid> fluidEntry : fluids.entrySet()) {
+ maxChance += fluidEntry.getValue().Chance;
+ }
+
+ for (Map.Entry<String, GT_UO_Fluid> fluidEntry : fluids.entrySet()) {
+ Fluid fluid = FluidRegistry.getFluid(fluidEntry.getKey());
+ if (fluid != null) {
+ UndergroundFluidWrapper wrapper = new UndergroundFluidWrapper(
+ dimension,
+ fluidEntry.getValue().Chance * 10000 / maxChance,
+ fluidEntry.getValue().MaxAmount,
+ fluidEntry.getValue().MinAmount);
+ if (fluidMap.containsKey(fluid.getName())) {
+ fluidMap.get(fluid.getName()).add(wrapper);
+ } else {
+ fluidMap.put(fluid.getName(), new ArrayList<>(Collections.singletonList(wrapper)));
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ for (List<UndergroundFluidWrapper> wrappers : fluidMap.values()) {
+ wrappers.sort(
+ Comparator.comparingInt(w -> Arrays.asList(DimensionHelper.DimNameDisplayed).indexOf(w.dimension)));
+ }
+ }
+
+ public static List<UndergroundFluidWrapper> getEntry(String fluidName) {
+ return fluidMap.get(fluidName);
+ }
+
+ public static Map<String, List<UndergroundFluidWrapper>> getAllEntries() {
+ return fluidMap;
+ }
+
+ @SuppressWarnings("SwitchStatementWithTooFewBranches")
+ private static String getDimensionFromID(int id) {
+ return switch (id) {
+ case 0 -> "Ow";
+ default -> null;
+ };
+ }
+
+ private static String getDimensionForEdgeCase(String rawDimension) {
+ return switch (rawDimension) {
+ case "aCentauriBb" -> "CB";
+ case "BarnardaC" -> "BC";
+ case "BarnardaE" -> "BE";
+ case "BarnardaF" -> "BF";
+ case "TCetiE" -> "TE";
+ default -> {
+ LOG.warn("Unknown dimension name while parsing: " + rawDimension);
+ yield null;
+ }
+ };
+ }
+
+ public static class UndergroundFluidWrapper {
+
+ /**
+ * Using {@link DimensionHelper#DimNameDisplayed}
+ */
+ public final String dimension;
+ /**
+ * Chance of this fluid field being generated. 10000 means 100% of the dimension
+ */
+ public final int chance;
+
+ public final int maxAmount;
+ public final int minAmount;
+
+ public UndergroundFluidWrapper(String dimension, int chance, int maxAmount, int minAmount) {
+ this.dimension = dimension;
+ this.chance = chance;
+ this.maxAmount = maxAmount;
+ this.minAmount = minAmount;
+ }
+ }
+}
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/OreVeinLayer.java b/src/main/java/pers/gwyog/gtneioreplugin/util/OreVeinLayer.java
new file mode 100644
index 0000000000..bc32f2ce46
--- /dev/null
+++ b/src/main/java/pers/gwyog/gtneioreplugin/util/OreVeinLayer.java
@@ -0,0 +1,18 @@
+package pers.gwyog.gtneioreplugin.util;
+
+public class OreVeinLayer {
+
+ public static final int VEIN_PRIMARY = 0;
+ public static final int VEIN_SECONDARY = 1;
+ public static final int VEIN_BETWEEN = 2;
+ public static final int VEIN_SPORADIC = 3;
+
+ private static final String[] LAYER_NAMES = { "gtnop.gui.nei.primaryOre", "gtnop.gui.nei.secondaryOre",
+ "gtnop.gui.nei.betweenOre", "gtnop.gui" + ".nei.sporadicOre" };
+
+ public static String getOreVeinLayerName(int layerId) {
+ return LAYER_NAMES[layerId];
+ }
+
+ private OreVeinLayer() {}
+}
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/Oremix.java b/src/main/java/pers/gwyog/gtneioreplugin/util/Oremix.java
new file mode 100644
index 0000000000..401cadc09f
--- /dev/null
+++ b/src/main/java/pers/gwyog/gtneioreplugin/util/Oremix.java
@@ -0,0 +1,600 @@
+package pers.gwyog.gtneioreplugin.util;
+
+import com.opencsv.bean.CsvBindByName;
+import com.opencsv.bean.CsvCustomBindByName;
+
+@SuppressWarnings("unused")
+public class Oremix {
+
+ @CsvCustomBindByName(column = "Moon", converter = XtoBool.class)
+ public boolean mo;
+
+ @CsvCustomBindByName(column = "End Asteroids", converter = XtoBool.class)
+ public boolean ea;
+
+ @CsvCustomBindByName(column = "AstroidBelt", converter = XtoBool.class)
+ public boolean as;
+
+ @CsvCustomBindByName(column = "Barnard C", converter = XtoBool.class)
+ public boolean bc;
+
+ @CsvCustomBindByName(column = "Barnard E", converter = XtoBool.class)
+ public boolean be;
+
+ @CsvCustomBindByName(column = "Barnard F", converter = XtoBool.class)
+ public boolean bf;
+
+ @CsvCustomBindByName(column = "Mars", converter = XtoBool.class)
+ public boolean ma;
+
+ @CsvCustomBindByName(column = "Callisto", converter = XtoBool.class)
+ public boolean ca;
+
+ @CsvCustomBindByName(column = "Centauri Bb", converter = XtoBool.class)
+ public boolean cb;
+
+ @CsvCustomBindByName(column = "Ceres", converter = XtoBool.class)
+ public boolean ce;
+
+ @CsvCustomBindByName(column = "Twilight Forest", converter = XtoBool.class)
+ public boolean tf;
+
+ @CsvCustomBindByName(column = "Deep Dark", converter = XtoBool.class)
+ public boolean dd;
+
+ @CsvCustomBindByName(column = "Phobos", converter = XtoBool.class)
+ public boolean ph;
+
+ @CsvCustomBindByName(column = "Deimos", converter = XtoBool.class)
+ public boolean de;
+
+ @CsvCustomBindByName(column = "Europa", converter = XtoBool.class)
+ public boolean eu;
+
+ @CsvCustomBindByName(column = "Ganymede", converter = XtoBool.class)
+ public boolean ga;
+
+ @CsvCustomBindByName(column = "Io", converter = XtoBool.class)
+ public boolean io;
+
+ @CsvCustomBindByName(column = "Venus", converter = XtoBool.class)
+ public boolean ve;
+
+ @CsvCustomBindByName(column = "Mercury", converter = XtoBool.class)
+ public boolean me;
+
+ @CsvCustomBindByName(column = "Enceladus", converter = XtoBool.class)
+ public boolean en;
+
+ @CsvCustomBindByName(column = "Titan", converter = XtoBool.class)
+ public boolean ti;
+
+ @CsvCustomBindByName(column = "Miranda", converter = XtoBool.class)
+ public boolean mi;
+
+ @CsvCustomBindByName(column = "Oberon", converter = XtoBool.class)
+ public boolean ob;
+
+ @CsvCustomBindByName(column = "Triton", converter = XtoBool.class)
+ public boolean tr;
+
+ @CsvCustomBindByName(column = "Proteus", converter = XtoBool.class)
+ public boolean pr;
+
+ @CsvCustomBindByName(column = "Pluto", converter = XtoBool.class)
+ public boolean pl;
+
+ @CsvCustomBindByName(column = "Kuiper Belt", converter = XtoBool.class)
+ public boolean kb;
+
+ @CsvCustomBindByName(column = "Haumea", converter = XtoBool.class)
+ public boolean ha;
+
+ @CsvCustomBindByName(column = "Makemake", converter = XtoBool.class)
+ public boolean make;
+
+ @CsvCustomBindByName(column = "Vega B", converter = XtoBool.class)
+ public boolean vb;
+
+ @CsvCustomBindByName(column = "T Ceti E", converter = XtoBool.class)
+ public boolean tcetie;
+
+ @CsvCustomBindByName(column = "Anubis", required = false, converter = XtoBool.class)
+ public boolean an;
+
+ @CsvCustomBindByName(column = "Horus", required = false, converter = XtoBool.class)
+ public boolean ho;
+
+ @CsvCustomBindByName(column = "Neper", required = false, converter = XtoBool.class)
+ public boolean np;
+
+ @CsvCustomBindByName(column = "Maahes", required = false, converter = XtoBool.class)
+ public boolean mh;
+
+ @CsvCustomBindByName(column = "Mehen Belt", required = false, converter = XtoBool.class)
+ public boolean mb;
+
+ @CsvCustomBindByName(column = "Seth", required = false, converter = XtoBool.class)
+ public boolean se;
+
+ @CsvCustomBindByName(column = "Ore Name", required = true, converter = Veinrenamer.class)
+ private String oreName;
+
+ @CsvBindByName(column = "Primary")
+ private String primary = "";
+
+ @CsvBindByName(column = "Secondary")
+ private String secondary = "";
+
+ @CsvBindByName(column = "Inbetween")
+ private String inbetween = "";
+
+ @CsvBindByName(column = "Around")
+ private String around = "";
+
+ @CsvBindByName(column = "ID ")
+ private String mix = "";
+
+ @CsvBindByName(column = "Tier")
+ private String tier = "";
+
+ @CsvBindByName(column = "Height")
+ private String height = "";
+
+ @CsvBindByName(column = "Density")
+ private int density;
+
+ @CsvBindByName(column = "Size")
+ private int size;
+
+ @CsvBindByName(column = "Weight")
+ private int weight;
+
+ @CsvCustomBindByName(column = "Overworld", converter = XtoBool.class)
+ private boolean overworld;
+
+ @CsvCustomBindByName(column = "Nether", converter = XtoBool.class)
+ private boolean nether;
+
+ @CsvCustomBindByName(column = "End", converter = XtoBool.class)
+ private boolean end;
+
+ private int miny, maxy;
+
+ public Oremix() {}
+
+ public boolean isMo() {
+ return mo;
+ }
+
+ public void setMo(boolean mo) {
+ this.mo = mo;
+ }
+
+ public boolean isEa() {
+ return ea;
+ }
+
+ public void setEa(boolean ea) {
+ this.ea = ea;
+ }
+
+ public boolean isAs() {
+ return as;
+ }
+
+ public void setAs(boolean as) {
+ this.as = as;
+ }
+
+ public boolean isBc() {
+ return bc;
+ }
+
+ public void setBc(boolean bc) {
+ this.bc = bc;
+ }
+
+ public boolean isBe() {
+ return be;
+ }
+
+ public void setBe(boolean be) {
+ this.be = be;
+ }
+
+ public boolean isBf() {
+ return bf;
+ }
+
+ public void setBf(boolean bf) {
+ this.bf = bf;
+ }
+
+ public boolean isMa() {
+ return ma;
+ }
+
+ public void setMa(boolean ma) {
+ this.ma = ma;
+ }
+
+ public boolean isCa() {
+ return ca;
+ }
+
+ public void setCa(boolean ca) {
+ this.ca = ca;
+ }
+
+ public boolean isCb() {
+ return cb;
+ }
+
+ public void setCb(boolean cb) {
+ this.cb = cb;
+ }
+
+ public boolean isCe() {
+ return ce;
+ }
+
+ public void setCe(boolean ce) {
+ this.ce = ce;
+ }
+
+ public boolean isTf() {
+ return tf;
+ }
+
+ public void setTf(boolean tf) {
+ this.tf = tf;
+ }
+
+ public boolean isDd() {
+ return dd;
+ }
+
+ public void setDd(boolean dd) {
+ this.dd = dd;
+ }
+
+ public boolean isPh() {
+ return ph;
+ }
+
+ public void setPh(boolean ph) {
+ this.ph = ph;
+ }
+
+ public boolean isDe() {
+ return de;
+ }
+
+ public void setDe(boolean de) {
+ this.de = de;
+ }
+
+ public boolean isEu() {
+ return eu;
+ }
+
+ public void setEu(boolean eu) {
+ this.eu = eu;
+ }
+
+ public boolean isGa() {
+ return ga;
+ }
+
+ public void setGa(boolean ga) {
+ this.ga = ga;
+ }
+
+ public boolean isIo() {
+ return io;
+ }
+
+ public void setIo(boolean io) {
+ this.io = io;
+ }
+
+ public boolean isVe() {
+ return ve;
+ }
+
+ public void setVe(boolean ve) {
+ this.ve = ve;
+ }
+
+ public boolean isMe() {
+ return me;
+ }
+
+ public void setMe(boolean me) {
+ this.me = me;
+ }
+
+ public boolean isEn() {
+ return en;
+ }
+
+ public void setEn(boolean en) {
+ this.en = en;
+ }
+
+ public boolean isTi() {
+ return ti;
+ }
+
+ public void setTi(boolean ti) {
+ this.ti = ti;
+ }
+
+ public boolean isMi() {
+ return mi;
+ }
+
+ public void setMi(boolean mi) {
+ this.mi = mi;
+ }
+
+ public boolean isOb() {
+ return ob;
+ }
+
+ public void setOb(boolean ob) {
+ this.ob = ob;
+ }
+
+ public boolean isTr() {
+ return tr;
+ }
+
+ public void setTr(boolean tr) {
+ this.tr = tr;
+ }
+
+ public boolean isPr() {
+ return pr;
+ }
+
+ public void setPr(boolean pr) {
+ this.pr = pr;
+ }
+
+ public boolean isPl() {
+ return pl;
+ }
+
+ public void setPl(boolean pl) {
+ this.pl = pl;
+ }
+
+ public boolean isKb() {
+ return kb;
+ }
+
+ public void setKb(boolean kb) {
+ this.kb = kb;
+ }
+
+ public boolean isHa() {
+ return ha;
+ }
+
+ public void setHa(boolean ha) {
+ this.ha = ha;
+ }
+
+ public boolean isMake() {
+ return make;
+ }
+
+ public void setMake(boolean make) {
+ this.make = make;
+ }
+
+ public boolean isVb() {
+ return vb;
+ }
+
+ public void setVb(boolean vb) {
+ this.vb = vb;
+ }
+
+ public boolean isTcetie() {
+ return tcetie;
+ }
+
+ public void setTcetie(boolean tcetie) {
+ this.tcetie = tcetie;
+ }
+
+ public boolean isAn() {
+ return an;
+ }
+
+ public void setAn(boolean an) {
+ this.an = an;
+ }
+
+ public boolean isHo() {
+ return ho;
+ }
+
+ public void setHo(boolean ho) {
+ this.ho = ho;
+ }
+
+ public boolean isNp() {
+ return np;
+ }
+
+ public void setNp(boolean np) {
+ this.np = np;
+ }
+
+ public boolean isMh() {
+ return mh;
+ }
+
+ public void setMh(boolean mh) {
+ this.mh = mh;
+ }
+
+ public boolean isMb() {
+ return mb;
+ }
+
+ public void setMb(boolean mb) {
+ this.mb = mb;
+ }
+
+ public boolean isSe() {
+ return se;
+ }
+
+ public void setSe(boolean se) {
+ this.se = se;
+ }
+
+ public String getOreName() {
+ return this.oreName;
+ }
+
+ public void setOreName(String s) {
+ this.oreName = s;
+ }
+
+ public String getPrimary() {
+ return this.primary;
+ }
+
+ public void setPrimary(String s) {
+ this.primary = s;
+ }
+
+ public String getSecondary() {
+ return this.secondary;
+ }
+
+ public void setSecondary(String s) {
+ this.secondary = s;
+ }
+
+ public String getInbetween() {
+ return this.inbetween;
+ }
+
+ public void setInbetween(String s) {
+ this.inbetween = s;
+ }
+
+ public String getAround() {
+ return this.around;
+ }
+
+ public void setAround(String s) {
+ this.around = s;
+ }
+
+ public String getMix() {
+ return this.mix;
+ }
+
+ public void setMix(String s) {
+ this.mix = s;
+ }
+
+ public String getTier() {
+ return this.tier;
+ }
+
+ public void setTier(String s) {
+ this.tier = s;
+ }
+
+ public String getHeight() {
+ return this.height;
+ }
+
+ public void setHeight(String s) {
+ this.height = s;
+ }
+
+ public int getDensity() {
+ return this.density;
+ }
+
+ public void setDensity(int i) {
+ this.density = i;
+ }
+
+ public int getSize() {
+ return this.size;
+ }
+
+ public void setSize(int i) {
+ this.size = i;
+ }
+
+ public int getWeight() {
+ return this.weight;
+ }
+
+ public void setWeight(int i) {
+ this.weight = i;
+ }
+
+ public int getMinY() {
+ calculateminmax();
+ return this.miny;
+ }
+
+ public void setMinY(int i) {
+ this.miny = i;
+ }
+
+ public int getMaxY() {
+ calculateminmax();
+ return this.maxy;
+ }
+
+ public void setMaxY(int i) {
+ this.maxy = i;
+ }
+
+ public boolean getOverworld() {
+ return this.overworld;
+ }
+
+ public void setOverworld(boolean s) {
+ this.overworld = s;
+ }
+
+ public boolean getNether() {
+ return this.nether;
+ }
+
+ public void setNether(boolean s) {
+ this.nether = s;
+ }
+
+ public boolean getEnd() {
+ return this.end;
+ }
+
+ public void setEnd(boolean s) {
+ this.end = s;
+ }
+
+ private void calculateminmax() {
+ this.miny = Integer.parseInt(this.height.split("-")[0]);
+ this.maxy = Integer.parseInt(this.height.split("-")[1]);
+ }
+
+ public String getHeightcalced() {
+ return this.miny + "-" + this.maxy;
+ }
+}
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/StringPaddingHack.java b/src/main/java/pers/gwyog/gtneioreplugin/util/StringPaddingHack.java
new file mode 100644
index 0000000000..0b1d391a08
--- /dev/null
+++ b/src/main/java/pers/gwyog/gtneioreplugin/util/StringPaddingHack.java
@@ -0,0 +1,131 @@
+package pers.gwyog.gtneioreplugin.util;
+
+import java.util.Arrays;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+
+import com.google.common.base.Strings;
+
+public class StringPaddingHack {
+
+ private static final int SPACE_WIDTH = 4;
+ private static final int BOLD_SPACE_WIDTH = 5;
+
+ /**
+ * Given a list of strings, arrange them into the requested number of columns with the specified spacing. Up to 3
+ * additional spaces might be added between columns because this function relies on quirky font behaviors.
+ *
+ * @param strings List of strings to wrap into columns
+ * @param numColumns Number of columns, minimum of 1
+ * @param minColumnSpacing Minimum amount of extra spaces between columns.
+ * @return strings wrapped into columns
+ */
+ public static String[] stringsToSpacedColumns(String[] strings, int numColumns, int minColumnSpacing) {
+ if (numColumns < 1) {
+ throw new IllegalArgumentException(
+ String.format("Argument numColumns must be 1 or higher, got value %d", numColumns));
+ }
+ if (numColumns > 1) {
+ int sliceSize = strings.length / numColumns;
+ int remainder = strings.length % numColumns;
+ String[][] columns = new String[numColumns][];
+ int totalExtra = 0;
+
+ // Arrange all strings into their proper columns so that the list of strings wraps through all columns
+ for (int i = 0; i < numColumns; i++) {
+ int extra = 0;
+ if (remainder > 0) {
+ remainder--;
+ extra = 1;
+ }
+ columns[i] = Arrays
+ .copyOfRange(strings, (sliceSize * i) + totalExtra, (sliceSize * (i + 1) + totalExtra + extra));
+
+ totalExtra += extra;
+ }
+
+ // Add extra padding to all but the last columns to align the text
+ for (int i = 0; i < numColumns - 1; i++) {
+ columns[i] = padStrings(columns[i], minColumnSpacing);
+ }
+
+ // Concatenate all columns into the final result
+ strings = columns[0];
+ for (int i = 0; i < sliceSize; i++) {
+ for (int j = 1; j < numColumns; j++) {
+ strings[i] += columns[j][i];
+ }
+ }
+ }
+
+ return strings;
+ }
+
+ /**
+ * Pads strings with spaces so that they are of equal length and adds to that the number of spaces specified and up
+ * to 3 if minExtraSpaces is below 3. Added spaces might be bold.
+ * <p>
+ * Relies on the quirk of bold space characters being 1 pixel wider than regular space characters in the default
+ * font renderer.
+ *
+ * @param strings List of strings
+ * @param minExtraSpaces The minimum number of extra spaces to add
+ * @return Array of strings padded with spaces to an equal length
+ */
+ public static String[] padStrings(String[] strings, int minExtraSpaces) {
+ int[] widths = getStringWidths(strings);
+ int maxUnPaddedStrLength = 0;
+ int numSpacesAddedToLongestString = 0;
+ int maxPaddedStrLength = 0;
+
+ // Making string width a multiple of 4 by adding bold spaces of width 5
+ for (int i = 0; i < strings.length; i++) {
+ int mod = widths[i] % SPACE_WIDTH;
+ int numBoldSpacesToAdd = (SPACE_WIDTH - mod) % SPACE_WIDTH;
+
+ // Keep track of the number of spaces added to the longest string
+ if (widths[i] > maxUnPaddedStrLength) {
+ numSpacesAddedToLongestString = numBoldSpacesToAdd;
+ maxUnPaddedStrLength = widths[i];
+ }
+
+ strings[i] += "§l" + Strings.repeat(" ", numBoldSpacesToAdd) + "§r";
+ widths[i] += numBoldSpacesToAdd * BOLD_SPACE_WIDTH;
+
+ // Keep track of the current widest string we currently have
+ if (widths[i] > maxPaddedStrLength) {
+ maxPaddedStrLength = widths[i];
+ }
+ }
+
+ // Make sure we pad at least up to the desired number of spaces from the longest string
+ if (numSpacesAddedToLongestString < minExtraSpaces) {
+ maxPaddedStrLength += (minExtraSpaces - numSpacesAddedToLongestString) * SPACE_WIDTH;
+ }
+
+ // Add required spaces to equalize length of all strings to at least the target width
+ for (int i = 0; i < strings.length; i++) {
+ int numSpacesToAdd = (maxPaddedStrLength - widths[i]) / SPACE_WIDTH;
+ strings[i] += Strings.repeat(" ", numSpacesToAdd);
+ widths[i] += numSpacesToAdd * SPACE_WIDTH;
+ }
+
+ return strings;
+ }
+
+ /**
+ * Returns an array of font widths for the given array of strings
+ *
+ * @param strList Array of strings
+ * @return Array of font widths
+ */
+ protected static int[] getStringWidths(String[] strList) {
+ FontRenderer font = Minecraft.getMinecraft().fontRenderer;
+ int[] widths = new int[strList.length];
+ for (int i = 0; i < strList.length; ++i) {
+ widths[i] = font.getStringWidth(strList[i]);
+ }
+ return widths;
+ }
+}
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/Veinrenamer.java b/src/main/java/pers/gwyog/gtneioreplugin/util/Veinrenamer.java
new file mode 100644
index 0000000000..346573e2a9
--- /dev/null
+++ b/src/main/java/pers/gwyog/gtneioreplugin/util/Veinrenamer.java
@@ -0,0 +1,23 @@
+package pers.gwyog.gtneioreplugin.util;
+
+import com.opencsv.bean.AbstractBeanField;
+
+public class Veinrenamer<T> extends AbstractBeanField<T> {
+
+ @Override
+ protected Object convert(String value) {
+ String ret;
+ CharSequence s = "/";
+
+ if (value.contains(s)) {
+ ret = value.split("/")[1];
+ ret = ret.replaceAll("&", "");
+ ret = ret.replaceAll(" ", "");
+ ret = ret.replaceAll("\\.", "");
+ ret = ret.toLowerCase();
+ } else ret = value;
+ ret = ret.replaceAll(" ", "");
+ ret = ret.toLowerCase();
+ return ret;
+ }
+}
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/XtoBool.java b/src/main/java/pers/gwyog/gtneioreplugin/util/XtoBool.java
new file mode 100644
index 0000000000..f3426d53dd
--- /dev/null
+++ b/src/main/java/pers/gwyog/gtneioreplugin/util/XtoBool.java
@@ -0,0 +1,33 @@
+package pers.gwyog.gtneioreplugin.util;
+
+import java.util.ResourceBundle;
+
+import org.apache.commons.beanutils.ConversionException;
+import org.apache.commons.beanutils.Converter;
+import org.apache.commons.beanutils.converters.BooleanConverter;
+
+import com.opencsv.bean.AbstractBeanField;
+import com.opencsv.exceptions.CsvDataTypeMismatchException;
+
+public class XtoBool<T> extends AbstractBeanField<T> {
+
+ @Override
+ protected Object convert(String value) throws CsvDataTypeMismatchException {
+ if (value.isEmpty()) {
+ return null;
+ }
+ String[] trueStrings = { "x", "X" };
+ String[] falseStrings = { "" };
+ Converter bc = new BooleanConverter(trueStrings, falseStrings);
+ try {
+ return bc.convert(Boolean.class, value.trim());
+ } catch (ConversionException e) {
+ CsvDataTypeMismatchException csve = new CsvDataTypeMismatchException(
+ value,
+ field.getType(),
+ ResourceBundle.getBundle("convertGermanToBoolean", errorLocale).getString("input.not.boolean"));
+ csve.initCause(e);
+ throw csve;
+ }
+ }
+}