diff options
| author | YannickMG <yannickmg@gmail.com> | 2022-07-06 15:35:36 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-06 20:35:36 +0100 |
| commit | 7836eea57a199661e1ac4b41d9ae678e62588ee2 (patch) | |
| tree | ed9c71b33553fcdc58b52664b1efb3dbe4e3cb45 /src/main/java/pers/gwyog/gtneioreplugin/util | |
| parent | 1cb11f470f296eb4db63174f7e58b17c7af7000d (diff) | |
| download | GT5-Unofficial-7836eea57a199661e1ac4b41d9ae678e62588ee2.tar.gz GT5-Unofficial-7836eea57a199661e1ac4b41d9ae678e62588ee2.tar.bz2 GT5-Unofficial-7836eea57a199661e1ac4b41d9ae678e62588ee2.zip | |
Enhanced NEI discoverability (#17)
* Removed unused code
* Addressed IDE warnings
* Refactored PluginGT5VeinStat::loadCraftingRecipes for readability
* Refactored PluginGT5VeinStat::drawExtras for readability
* Added OreVeinLayer class for the concept of ore layer
* Updated buildscript
* Ran spotlessApply
* Addressed some trivial IDE warnings
* Load both Small Ores and regular Ores when either is queried.
* Refactored PluginGT5SmallOreStat::loadCraftingRecipes for readability
* Refactored PluginGT5SmallOreStat::drawExtras for readability
Diffstat (limited to 'src/main/java/pers/gwyog/gtneioreplugin/util')
11 files changed, 379 insertions, 259 deletions
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java b/src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java index f12405a7ae..24cc1dd023 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java @@ -4,10 +4,6 @@ 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; - import java.io.BufferedWriter; import java.nio.file.Files; import java.nio.file.Paths; @@ -15,12 +11,13 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; +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 CSVMaker() {} public static List<Oremix> Combsort(List<Oremix> liste) { try { @@ -37,7 +34,13 @@ public class CSVMaker implements Runnable { schritt = (int) (schritt / 1.3); } for (int i = 0; i < liste2.size() - schritt; i++) { - if (liste2.get(i).getOreName().substring(0, 3).compareTo((liste2.get(i + schritt).getOreName().substring(0, 3))) > 0) { + if (liste2.get(i) + .getOreName() + .substring(0, 3) + .compareTo((liste2.get(i + schritt) + .getOreName() + .substring(0, 3))) + > 0) { Oremix tmp = (Oremix) liste2.get(i); liste2.set(i, liste2.get(i + schritt)); liste2.set(i + schritt, (Oremix) tmp); @@ -107,14 +110,17 @@ public class CSVMaker implements Runnable { BufferedWriter one = Files.newBufferedWriter(Paths.get(GTNEIOrePlugin.CSVnameSmall)); ColumnPositionMappingStrategy 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".split("\\,"); + 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" + .split("\\,"); strat.setColumnMapping(columns); StatefulBeanToCsv<Oremix> beanToCsv = new StatefulBeanToCsvBuilder(one) .withQuotechar(CSVWriter.NO_QUOTE_CHARACTER) .withMappingStrategy(strat) .build(); List 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"); + 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"); one.newLine(); beanToCsv.write(towrite); one.flush(); @@ -149,7 +155,8 @@ public class CSVMaker implements Runnable { 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.setMix(Integer.toString(oreLayer.Meta[0]) + "|" + Integer.toString(oreLayer.Meta[1]) + "|" + + Integer.toString(oreLayer.Meta[2]) + "|" + Integer.toString(oreLayer.Meta[3])); oremix.as = Dims.contains("As"); oremix.bc = Dims.contains("BC"); oremix.be = Dims.contains("BE"); @@ -186,21 +193,23 @@ public class CSVMaker implements Runnable { 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 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".split("\\,"); + 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" + .split("\\,"); strat.setColumnMapping(columns); StatefulBeanToCsv<Oremix> beanToCsv = new StatefulBeanToCsvBuilder(one) .withQuotechar(CSVWriter.NO_QUOTE_CHARACTER) .withMappingStrategy(strat) .build(); List 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"); + 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"); one.newLine(); beanToCsv.write(towrite); one.flush(); @@ -209,5 +218,4 @@ public class CSVMaker implements Runnable { e.printStackTrace(); } } - } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java index fb422ed074..16be409b61 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java @@ -1,111 +1,111 @@ 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.client.resources.I18n; -import static pers.gwyog.gtneioreplugin.GTNEIOrePlugin.maxTooltipLines; - public class DimensionHelper { - public static 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", - // T4 - "GalaxySpace_Io", - "GalaxySpace_Mercury", - "GalaxySpace_Venus", - // T5 - "GalaxySpace_Enceladus", - "GalaxySpace_Miranda", - "GalaxySpace_Oberon", - "GalaxySpace_Titan", - // 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", - "Underdark", - "GalaxySpace_VegaB", - }; + public static 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", + // T4 + "GalaxySpace_Io", + "GalaxySpace_Mercury", + "GalaxySpace_Venus", + // T5 + "GalaxySpace_Enceladus", + "GalaxySpace_Miranda", + "GalaxySpace_Oberon", + "GalaxySpace_Titan", + // 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", + "Underdark", + "GalaxySpace_VegaB", + }; - public static 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 - "EN", // 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 - // T4 - "Io", // GalaxySpace_Io - "Me", // GalaxySpace_Mercury - "Ve", // GalaxySpace_Venus - // T5 - "En", // GalaxySpace_Enceladus - "Mi", // GalaxySpace_Miranda - "Ob", // GalaxySpace_Oberon - "Ti", // GalaxySpace_Titan - // 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 - "DD", // Underdark - "VB", // GalaxySpace_VegaB - }; + public static 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 + "EN", // 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 + // T4 + "Io", // GalaxySpace_Io + "Me", // GalaxySpace_Mercury + "Ve", // GalaxySpace_Venus + // T5 + "En", // GalaxySpace_Enceladus + "Mi", // GalaxySpace_Miranda + "Ob", // GalaxySpace_Oberon + "Ti", // GalaxySpace_Titan + // 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 + "DD", // Underdark + "VB", // GalaxySpace_VegaB + }; - private static HashMap<String, List<String>> tooltipBuffer = new HashMap<>(); + private static final HashMap<String, List<String>> tooltipBuffer = new HashMap<>(); private static List<String> computeString(String line) { String[] dims = line.split(","); @@ -115,7 +115,11 @@ public class DimensionHelper { s = s.trim(); for (int i = 0; i < DimNameDisplayed.length; i++) { if (s.equals(DimNameDisplayed[i])) { - String k = DimName[i].replaceAll("GalacticraftCore_", "").replaceAll("GalacticraftMars_", "").replaceAll("GalaxySpace_", "").replaceAll("Vanilla_", "Vanilla "); + String k = DimName[i] + .replaceAll("GalacticraftCore_", "") + .replaceAll("GalacticraftMars_", "") + .replaceAll("GalaxySpace_", "") + .replaceAll("Vanilla_", "Vanilla "); s = I18n.format("gtnop.world." + k); switch (k) { case "Moon": @@ -170,9 +174,9 @@ public class DimensionHelper { } } - if (dims.length > maxTooltipLines ) { + if (dims.length > maxTooltipLines) { dims = StringPaddingHack.stringsToSpacedColumns( - dims, dims.length / maxTooltipLines + (dims.length % maxTooltipLines == 0 ? 0 : 1) , 2); + dims, dims.length / maxTooltipLines + (dims.length % maxTooltipLines == 0 ? 0 : 1), 2); } return Arrays.asList(dims); @@ -181,4 +185,4 @@ public class DimensionHelper { public static List<String> convertCondensedStringToToolTip(String line) { return tooltipBuffer.computeIfAbsent(line, (String tmp) -> computeString(line)); } -}
\ No newline at end of file +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java index 94b826808f..1a62c31ec1 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java @@ -2,11 +2,6 @@ package pers.gwyog.gtneioreplugin.util; import cpw.mods.fml.common.FMLLog; import gregtech.api.GregTech_API; -import net.minecraftforge.common.config.ConfigCategory; -import net.minecraftforge.common.config.Configuration; -import net.minecraftforge.common.config.Property; -import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; - import java.io.BufferedReader; import java.io.File; import java.io.FileReader; @@ -14,7 +9,10 @@ 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 pers.gwyog.gtneioreplugin.GTNEIOrePlugin; public class GT5CFGHelper { @@ -34,8 +32,7 @@ public class GT5CFGHelper { if (!raw.isEmpty()) for (int i = 0; i < raw.size(); i++) { for (int j = 0; j < DimensionHelper.DimName.length; j++) - if (raw.get(i).contains(DimensionHelper.DimName[j])) - rawbools.add(raw.get(i)); + if (raw.get(i).contains(DimensionHelper.DimName[j])) rawbools.add(raw.get(i)); } else GTNEIOrePlugin.LOG.info("Config entry not found for Vein: " + Veinname); @@ -44,7 +41,12 @@ public class GT5CFGHelper { HashSet<String> rawboolsset = new HashSet<String>(); if (!rawbools.isEmpty()) { for (int i = 0; i < rawbools.size(); i++) { - st = rawbools.get(i).replace("B:", "").replace("_true", "").replace("_false", "").replaceAll(" ", "").replaceAll("\"", ""); + st = rawbools.get(i) + .replace("B:", "") + .replace("_true", "") + .replace("_false", "") + .replaceAll(" ", "") + .replaceAll("\"", ""); rawboolsset.add(st); } rawbools = new ArrayList<String>(rawboolsset); @@ -52,33 +54,30 @@ public class GT5CFGHelper { for (int i = 0; i < rawbools.size(); i++) { st = rawbools.get(i); if (st.contains(DimensionHelper.DimName[j])) - if (st.contains("=true")) - ret = (ret + DimensionHelper.DimNameDisplayed[j] + ","); + if (st.contains("=true")) ret = (ret + DimensionHelper.DimNameDisplayed[j] + ","); } } } ret = ret.trim(); - if (ret.equals("") || ret.equals(" ")) - ret = "Not available in any Galactic Dim!"; + if (ret.equals("") || ret.equals(" ")) ret = "Not available in any Galactic Dim!"; return ret; } public static String GT5CFG(String Veinname) { - //FMLLog.info(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]"); + 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"); + // FMLLog.info("FileReader created"); BufferedReader reader = new BufferedReader(in, buffer); - //FMLLog.info("BufferedReader" +Integer.toString(buffer)+"created"); + // FMLLog.info("BufferedReader" +Integer.toString(buffer)+"created"); String st = null; List<String> raw = new ArrayList<String>(); List<String> rawbools = new ArrayList<String>(); @@ -87,24 +86,23 @@ public class GT5CFGHelper { found[1] = false; do { - //FMLLog.info("erste"); - //read until reached eof or mix { + // FMLLog.info("erste"); + // read until reached eof or mix { st = reader.readLine(); - //FMLLog.info("st: "+st); + // FMLLog.info("st: "+st); if (st != null && st.trim().equals("mix {")) { while (!((st == null) || ((st != null) && found[0]))) { - //FMLLog.info("zweite"); + // FMLLog.info("zweite"); st = reader.readLine(); - //read until reached eof or Veinname { - //FMLLog.info("MIXst: "+st); + // read until reached eof or Veinname { + // FMLLog.info("MIXst: "+st); if (st != null && st.trim().equals(Veinname + " {")) { - //FMLLog.info("VEINNAMEst: "+st); + // FMLLog.info("VEINNAMEst: "+st); while (!((st == null) || ((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 + if ((!(st == null)) && st.trim().equals("}")) found[0] = true; + // FMLLog.info("dritte"); + // add everything below Veinname { undtil } to raw raw.add(st); } } @@ -113,22 +111,21 @@ public class GT5CFGHelper { if (st != null && st.trim().equals("dimensions {")) { while (!((st == null) || ((st != null) && found[1]))) { - //FMLLog.info("zweite"); + // FMLLog.info("zweite"); st = reader.readLine(); if (st != null && (st.trim().equals("mix {"))) { while (!((st == null) || ((st != null) && found[1]))) { - //FMLLog.info("dritte"); + // FMLLog.info("dritte"); st = reader.readLine(); - //read until reached eof or Veinname { - //FMLLog.info("MIXst: "+st); + // read until reached eof or Veinname { + // FMLLog.info("MIXst: "+st); if (st != null && st.trim().equals(Veinname + " {")) { - //FMLLog.info("VEINNAMEst: "+st); + // FMLLog.info("VEINNAMEst: "+st); while (!((st == null) || ((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 + if ((!(st == null)) && st.trim().equals("}")) found[1] = true; + // FMLLog.info("vierte"); + // add everything below Veinname { undtil } to raw raw.add(st); } } @@ -137,16 +134,15 @@ public class GT5CFGHelper { } } } while (st != null); - reader.close();//not needed anymore + reader.close(); // not needed anymore if (!raw.isEmpty()) for (int i = 0; i < raw.size(); i++) { - //filter needed booleans from raw - ///FMLLog.info("raw contains"+raw.get(i)); + // filter needed booleans from raw + /// FMLLog.info("raw contains"+raw.get(i)); for (int j = 0; j < DimensionHelper.DimName.length; j++) - if (raw.get(i).contains(DimensionHelper.DimName[j])) - rawbools.add(raw.get(i)); - //FMLLog.info("rawbools: "+rawbools.get(i)); + if (raw.get(i).contains(DimensionHelper.DimName[j])) rawbools.add(raw.get(i)); + // FMLLog.info("rawbools: "+rawbools.get(i)); } else GTNEIOrePlugin.LOG.info("Config entry not found for Vein: " + Veinname); @@ -154,27 +150,30 @@ public class GT5CFGHelper { HashSet<String> rawboolsset = new HashSet<String>(); if (!rawbools.isEmpty()) { - //remove dublicates + // remove dublicates for (int i = 0; i < rawbools.size(); i++) { - st = rawbools.get(i).replace("B:", "").replace("_true", "").replace("_false", "").replaceAll(" ", "").replaceAll("\"", ""); + st = rawbools.get(i) + .replace("B:", "") + .replace("_true", "") + .replace("_false", "") + .replaceAll(" ", "") + .replaceAll("\"", ""); rawboolsset.add(st); } rawbools = new ArrayList<String>(rawboolsset); - //filter for dims set to true + // filter for dims set to true for (int j = 0; j < DimensionHelper.DimName.length; j++) { - //FMLLog.info("RawBools:"+st); + // FMLLog.info("RawBools:"+st); for (int i = 0; i < rawbools.size(); i++) { st = rawbools.get(i); if (st.contains(DimensionHelper.DimName[j])) - if (st.contains("=true")) - ret = (ret + DimensionHelper.DimNameDisplayed[j] + ","); + if (st.contains("=true")) ret = (ret + DimensionHelper.DimNameDisplayed[j] + ","); } } } ret = ret.trim(); - //FMLLog.info("ret:"+ret); - if (ret.equals("") || ret.equals(" ")) - ret = "Not available in any Galactic Dim!"; + // FMLLog.info("ret:"+ret); + if (ret.equals("") || ret.equals(" ")) ret = "Not available in any Galactic Dim!"; return ret; } catch (IOException e) { e.printStackTrace(); diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java index 9e8a608405..ac3873d9bc 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java @@ -1,23 +1,26 @@ package pers.gwyog.gtneioreplugin.util; -import gregtech.common.GT_Worldgen_GT_Ore_Layer; +import static pers.gwyog.gtneioreplugin.util.OreVeinLayer.*; +import gregtech.api.GregTech_API; +import gregtech.common.GT_Worldgen_GT_Ore_Layer; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; +import net.minecraft.item.ItemStack; public class GT5OreLayerHelper { - public static Integer weightPerWorld[] = new Integer[33]; - public static Integer DimIDs[] = new Integer[33]; - public static HashMap<String, OreLayerWrapper> mapOreLayerWrapper = new HashMap<String, OreLayerWrapper>(); + private static final int DIMENSION_COUNT = 33; + public static Integer[] weightPerWorld = new Integer[DIMENSION_COUNT]; + public static Integer[] DimIDs = new Integer[DIMENSION_COUNT]; + public static HashMap<String, OreLayerWrapper> mapOreLayerWrapper = new HashMap<>(); public static HashMap<OreLayerWrapper, String> bufferedDims = new HashMap<>(); public GT5OreLayerHelper() { - for (int i = 0; i < DimIDs.length; i++) - weightPerWorld[i] = 0; - for (int i = 0; i < DimIDs.length; i++) - DimIDs[i] = 0; + 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()) { @@ -26,15 +29,15 @@ public class GT5OreLayerHelper { } public static String getDims(OreLayerWrapper oreLayer) { - return GT5CFGHelper.GT5CFG(oreLayer.veinName.replace("ore.mix.custom.", "").replace("ore.mix.", "")); + return GT5CFGHelper.GT5CFG( + oreLayer.veinName.replace("ore.mix.custom" + ".", "").replace("ore.mix.", "")); } - - public class OreLayerWrapper { + public static class OreLayerWrapper { public String veinName, worldGenHeightRange; public short[] Meta = new short[4]; public short randomWeight, size, density; - public List<Integer> Weight = new ArrayList<Integer>(); + public List<Integer> Weight = new ArrayList<>(); public OreLayerWrapper(GT_Worldgen_GT_Ore_Layer worldGen) { this.veinName = worldGen.mWorldGenName; @@ -47,6 +50,24 @@ public class GT5OreLayerHelper { 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; + } } } -
\ No newline at end of file diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java index 6dc155e9fd..a730b3d148 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java @@ -6,20 +6,20 @@ import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.world.GT_Worldgen; import gregtech.common.GT_Worldgen_GT_Ore_SmallPieces; -import net.minecraft.item.ItemStack; - import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import net.minecraft.item.ItemStack; public class GT5OreSmallHelper { + private static final int SMALL_ORE_BASE_META = 16000; public static boolean restrictBiomeSupport = false; public static boolean gcBasicSupport = false; - public static List<ItemStack> oreSmallList = new ArrayList<ItemStack>(); - public static HashMap<String, OreSmallWrapper> mapOreSmallWrapper = new HashMap<String, OreSmallWrapper>(); - public static HashMap<String, Short> mapOreDropUnlocalizedNameToOreMeta = new HashMap<String, Short>(); - public static HashMap<Short, List<ItemStack>> mapOreMetaToOreDrops = new HashMap<Short, List<ItemStack>>(); + public static List<ItemStack> oreSmallList = new ArrayList<>(); + public static HashMap<String, OreSmallWrapper> mapOreSmallWrapper = new HashMap<>(); + public static HashMap<String, Short> mapOreDropUnlocalizedNameToOreMeta = new HashMap<>(); + public static HashMap<Short, List<ItemStack>> mapOreMetaToOreDrops = new HashMap<>(); public s |
