Skip to content

Commit

Permalink
Fixed it. upgrade to V1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
bartimaeusnek committed Jan 26, 2018
1 parent 9066c13 commit 139001b
Show file tree
Hide file tree
Showing 8 changed files with 186 additions and 96 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildscript {

apply plugin: 'forge'

version = "1.7.10-1.0.4-GT-NH"
version = "1.7.10-1.0.5-GT-NH"
group= "pers.gwyog.gtneioreplugin"
archivesBaseName = "gtneioreplugin"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class GTNEIOrePlugin {
public static final String MODID = "gtneioreplugin";
public static final String NAME = "GT NEI Ore Plugin GT:NH Mod";
public static final String VERSION = "1.0.4-GTNH";
public static final String VERSION = "1.0.5-GTNH";

public static String GTVersion = "GT5";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ else if (!getGTOreLocalizedName((short)(meta+offset+5000)).equals(getGTOreUnloca
}

public String getGTOreLocalizedName(short index) {

if (!Materials.getLocalizedNameForItem(GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(index)), index%1000).contains("Awakened"))
return Materials.getLocalizedNameForItem(GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(index)), index%1000);
else
return "Aw. Draconium Ore";
}

public String getGTOreUnlocalizedName(short index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRect;
import cpw.mods.fml.common.FMLLog;
import gregtech.api.GregTech_API;
import gregtech.api.enums.Materials;
import gregtech.api.util.GT_LanguageManager;
Expand Down Expand Up @@ -121,36 +122,46 @@ public void drawExtras(int recipe) {
CachedVeinStatRecipe crecipe = (CachedVeinStatRecipe) this.arecipes.get(recipe);
OreLayerWrapper oreLayer = GT5OreLayerHelper.mapOreLayerWrapper.get(crecipe.veinName);

if (getLocalizedVeinName(oreLayer).length()>20) {
GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getLocalizedVeinName(oreLayer).substring(0, 20), 2, 20, 0x404040, false);
if (getLocalizedVeinName(oreLayer).length()>40) {
GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getLocalizedVeinName(oreLayer).substring(20, 40), 2, 30, 0x404040, false);
GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getLocalizedVeinName(oreLayer).substring(40, getLocalizedVeinName(oreLayer).length()), 2, 40, 0x404040, false);
if (getLocalizedVeinName(oreLayer).length>1) {
GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getLocalizedVeinName(oreLayer)[0], 2, 20, 0x404040, false);
if (getLocalizedVeinName(oreLayer).length>2) {
GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getLocalizedVeinName(oreLayer)[1], 2, 30, 0x404040, false);
GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getLocalizedVeinName(oreLayer)[2], 2, 40, 0x404040, false);
}
else
GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getLocalizedVeinName(oreLayer).substring(20, getLocalizedVeinName(oreLayer).length()), 2, 30, 0x404040, false);
GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getLocalizedVeinName(oreLayer)[1], 2, 30, 0x404040, false);
}
else
GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getLocalizedVeinName(oreLayer), 2, 20, 0x404040, false);
GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getLocalizedVeinName(oreLayer)[0], 2, 20, 0x404040, false);
GuiDraw.drawString(I18n.format("gtnop.gui.nei.primaryOre") + ": " + getGTOreLocalizedName(oreLayer.Meta[0]), 2, 50, 0x404040, false);
GuiDraw.drawString(I18n.format("gtnop.gui.nei.secondaryOre") + ": " + getGTOreLocalizedName(oreLayer.Meta[1]), 2, 60, 0x404040, false);
GuiDraw.drawString(I18n.format("gtnop.gui.nei.betweenOre") + ": " + getGTOreLocalizedName(oreLayer.Meta[2]), 2, 70, 0x404040, false);
GuiDraw.drawString(I18n.format("gtnop.gui.nei.sporadicOre") + ": " + getGTOreLocalizedName(oreLayer.Meta[3]), 2, 80, 0x404040, false);
GuiDraw.drawString(I18n.format("gtnop.gui.nei.genHeight") + ": " + oreLayer.worldGenHeightRange, 2, 90, 0x404040, false);
GuiDraw.drawString(I18n.format("gtnop.gui.nei.weightedChance") + ": " + Integer.toString(oreLayer.randomWeight), 100, 90, 0x404040, false);
GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": ", 2, 100, 0x404040, false);
GuiDraw.drawString(I18n.format("") + getDims(oreLayer), 2, 110, 0x404040, false);
// GuiDraw.drawString(I18n.format("gtnop.gui.nei.weightedChance") + ": " + getWeightedChance(oreLayer), 2, 122, 0x404040, false);
if (getDims(oreLayer).length()>36) {
GuiDraw.drawString(I18n.format("") + getDims(oreLayer).substring(0, 36), 2, 110, 0x404040, false);
if (getDims(oreLayer).length()>70) {
GuiDraw.drawString(I18n.format("") + getDims(oreLayer).substring(36, 70), 2, 120, 0x404040, false);
GuiDraw.drawString(I18n.format("") + getDims(oreLayer).substring(70, getDims(oreLayer).length()-1), 2, 130, 0x404040, false);
}
else
GuiDraw.drawString(I18n.format("") + getDims(oreLayer).substring(36, getDims(oreLayer).length()-1), 2, 120, 0x404040, false);
}
else
GuiDraw.drawString(I18n.format("") + getDims(oreLayer).substring(0, getDims(oreLayer).length()-1), 2, 110, 0x404040, false);
//if (GT5OreLayerHelper.restrictBiomeSupport) GuiDraw.drawString(I18n.format("gtnop.gui.nei.restrictBiome") + ": " + getBiomeTranslated(oreLayer.restrictBiome), 2, 122, 0x404040, false);
//GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gtnop.gui.nei.seeAll"), getGuiWidth()-3, 5, 0x404040, false);
GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gtnop.gui.nei.seeAll"), getGuiWidth()-3, 5, 0x404040, false);
}

public String getLocalizedVeinName(OreLayerWrapper oreLayer) {
public String[] getLocalizedVeinName(OreLayerWrapper oreLayer) {

String unlocalizedName = oreLayer.veinName;
if (unlocalizedName.startsWith("ore.mix.custom."))
return I18n.format(coustomVeinRenamer(oreLayer));//I18n.format("gtnop.ore.custom.name") + I18n.format("gtnop.ore.vein.name") + unlocalizedName.substring(15);
return get_Cnames(oreLayer);//I18n.format("gtnop.ore.custom.name") + I18n.format("gtnop.ore.vein.name") + unlocalizedName.substring(15);
else
return I18n.format("gtnop." + unlocalizedName) + I18n.format("gtnop.ore.vein.name");
return new String[] {I18n.format("gtnop." + unlocalizedName) + I18n.format("gtnop.ore.vein.name")};
}

public String coustomVeinRenamer(OreLayerWrapper oreLayer) {
Expand All @@ -162,9 +173,16 @@ public String coustomVeinRenamer(OreLayerWrapper oreLayer) {
.replace("]".charAt(0), ",".charAt(0))
.replaceAll(" Ore", ",")
.replaceAll("Ore", ",")
.replaceAll(" Sand", ",")
.replaceAll("Sand", ",")
.replaceAll("Stone", ",")
.replaceAll(" Stone", ",")
.replaceAll("Earth", ",")
.replaceAll(" Earth", ",")
.replaceAll("Infused", ",")
.replaceAll(" Infused", ",")
.replaceAll(",","")
.trim()
.concat(" Vein");
.trim();
}

/*public String getWeightedChance(OreLayerWrapper oreLayer) {
Expand All @@ -183,6 +201,57 @@ public String getDims(OreLayerWrapper oreLayer) {
return GT5CFGHelper.GT5CFG(GregTech_API.sWorldgenFile.mConfig.getConfigFile(), oreLayer.veinName.replace("ore.mix.custom.", "").replace("ore.mix.", ""));
}

public String[] get_Cnames(OreLayerWrapper oreLayer) {

String[] splt = coustomVeinRenamer(oreLayer).split("\\s");
/*HashSet<String> h = new HashSet<String>();
for (int i=0; i < splt.length;i++) {
h.add(splt[i]);
}
h.toArray(splt);*/

String[] ret = {oreLayer.veinName.replace("ore.mix.custom.", "")," "," "};
for (int i=0; i < splt.length;i++) {
//FMLLog.info("Split:"+splt[i]);
//FMLLog.info("I:"+Integer.toString(i));
if(ret[0].length()+splt[i].length()<=20)
ret[0]=ret[0]+splt[i]+" ";
if((ret[0].length()+splt[i].length()>20)&&ret[1].length()+splt[i].length()<=20&&!ret[0].contains(splt[i]))
ret[1]=ret[1]+splt[i]+" ";
if((ret[0].length()+splt[i].length()>20)&&(ret[1].length()+splt[i].length()>20)&&ret[2].length()+splt[i].length()<=20&&!ret[1].contains(splt[i]))
ret[2]=ret[2]+splt[i]+" ";
}
for (int i=0; i < ret.length;i++) {
ret[i]=ret[i].trim();
}

if(ret[2].isEmpty()&&!ret[1].isEmpty())
if(ret[1].length()<=15)
ret[1]=ret[1]+" Vein";
else
ret[2]=ret[2]+"Vein";
else if(ret[1].isEmpty()&&ret[2].isEmpty()&&!ret[0].isEmpty())
if(ret[0].length()<=15)
ret[0]=ret[0]+" Vein";
else
ret[1]=ret[1]+"Vein";
else if (!(ret[1].isEmpty()&&ret[2].isEmpty()))
ret[2]=ret[2]+"Vein";
String[] ret2 = new String[2];
if (ret[2].isEmpty()&&!ret[1].isEmpty()) {
ret2[0] = ret[0];
ret2[1] = ret[1];
return ret2;
}
String[] ret1 = new String[1];
if (ret[1].isEmpty()&&ret[1].isEmpty()&&!ret[0].isEmpty()) {
ret1[0] = ret[0];
return ret1;
}
else
return ret;
}

@Override
public String getOutputId() {
return "GTOrePluginVein";
Expand Down
70 changes: 37 additions & 33 deletions src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,41 +41,45 @@ public class DimensionHelper {
"Nether",
"Overworld",
"TheEnd",
"Vanilla_EndAsteroids"};
"Vanilla_EndAsteroids",
"Twilight",
"Underdark"};

public static String[] DimNameDisplayed =
{
"End Asteroids",
"Moon",
"Asteroids",
"Mars",
"BarnardC",
"BarnardE",
"BarnardF",
"Callisto",
"CentauriA",
"Ceres",
"Deimos",
"Enceladus",
"Europa",
"Ganymede",
"Haumea",
"EA",
"MO",
"AS",
"MA",
"BC",
"BE",
"BF",
"Ca",
"CeA",
"Ce",
"De",
"En",
"Eu",
"Ga",
"Ha",
"Io",
"Kuiperbelt",
"MakeMake",
"Mercury",
"Miranda",
"Oberon",
"Phobos",
"Pluto",
"Proteus",
"TcetiE",
"Titan",
"Triton",
"VegaB",
"Venus",
"The Nether",
"Overworld",
"The End",
"Far End Asteroids"};
"KB",
"MM",
"Me",
"Mi",
"Ob",
"Ph",
"Pu",
"Pr",
"TE",
"Ti",
"Tr",
"VB",
"Ve",
"Ne",
"OW",
"EN",
"VA",
"TF",
"DD"};
}
82 changes: 54 additions & 28 deletions src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
Expand All @@ -17,7 +16,7 @@ public class GT5CFGHelper {
public static String GT5CFG(File F, String Veinname) {
//FMLLog.info(Veinname);
if (F == null) {
FMLLog.bigWarning("GT_CFG_NOT_FOUND");
FMLLog.bigWarning("GT_CFG_NOT_found[0]");
return "Error while Loading CFG";
}
else
Expand All @@ -26,41 +25,70 @@ public static String GT5CFG(File F, String Veinname) {
if (buffer > F.length())
buffer = (int) F.length();
//allocate 10% of free memory for read-in-buffer, if there is less than filesize memory aviable
//FMLLog.info("GT_CFG_FOUND");
//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="";
String st=null;
List<String> raw= new ArrayList<String>();
List<String> rawbools = new ArrayList<String>();
boolean found = false;
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 ((reader.readLine() != null))
if (st.contains("mix {")) {
do{
//read until reached eof or Veinname {
if (st != null && st.trim().equals("mix {")) {
while(!((st == null)||((st != null)&&found[0]))){
//FMLLog.info("zweite");
st = reader.readLine();
//read until reached eof or Veinname {
//FMLLog.info("MIXst: "+st);
if ((reader.readLine() != null))
if (st.contains(Veinname)) {
//FMLLog.info("VEINNAMEst: "+st);
//for (int i=0; i < 44;i++)
do{
//add everything below Veinname { undtil } to raw
raw.add(reader.readLine());
}while (!reader.readLine().contains("}")&&(reader.readLine() != null));
found = true;
if (st != null && st.trim().equals(Veinname+" {")) {
//FMLLog.info("VEINNAMEst: "+st);
while (!((st == null)||((st != null)&&found[0]))){
st = reader.readLine();
if (st.trim().equals("}"))
found[0] = true;
//FMLLog.info("dritte");
//add everything below Veinname { undtil } to raw
raw.add(st);
}
}
}
}while((!found) || (reader.readLine() != null));
}
}while((!found) || (reader.readLine() != null));

reader.close();//not needed anymore

if (st != null && st.trim().equals("dimensions {")) {
while(!((st == null)||((st != null)&&found[1]))){
//FMLLog.info("zweite");
st = reader.readLine();
if (st != null && (st.trim().equals("mix {"))) {
while(!((st == null)||((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)||((st != null)&&found[1]))){
st = reader.readLine();
if (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 (int i=0; i < raw.size();i++) {
Expand All @@ -75,31 +103,29 @@ public static String GT5CFG(File F, String Veinname) {

String ret=" ";

//HashSet<String> rawboolsset = new HashSet<String>();
HashSet<String> rawboolsset = new HashSet<String>();
if (!rawbools.isEmpty()) {
//remove dublicats
/*
for (int i=0; i < rawbools.size();i++){
st = rawbools.get(i).replace("B:", "").replace("_true", "").replace("_false", "").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
for (int i=0; i < rawbools.size();i++) {
st = rawbools.get(i);
//FMLLog.info("RawBools:"+st);
for (int j=0; j < DimensionHelper.DimName.length;j++) {
if(st.contains(DimensionHelper.DimName[j]))
if(st.contains("=true"))
ret=(ret+DimensionHelper.DimNameDisplayed[j]+" ");
ret=(ret+DimensionHelper.DimNameDisplayed[j]+",");
}
}
}
ret = ret.trim();
//FMLLog.info("ret:"+ret);
if(ret.equals("")||ret.equals(" "))
ret ="Not aviable in any Galactic Dim, maybe Deep Dark or Bedrock Dim";
ret ="Not aviable in any Galactic Dim!";
return ret;
} catch (IOException e) {
e.printStackTrace();
Expand Down
Loading

0 comments on commit 139001b

Please sign in to comment.