diff options
Diffstat (limited to 'src/main/java')
15 files changed, 1436 insertions, 1195 deletions
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/Config.java b/src/main/java/pers/gwyog/gtneioreplugin/Config.java index 62a94de43b..c31ebc63a6 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/Config.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/Config.java @@ -1,19 +1,22 @@ package pers.gwyog.gtneioreplugin; -import java.io.File; - import cpw.mods.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.common.config.Configuration; +import java.io.File; + public class Config { public Configuration tConfig; - public Config(FMLPreInitializationEvent preinit,String cfgname) { - File tFile = new File(preinit.getModConfigurationDirectory(), cfgname); - tConfig = new Configuration(tFile); - tConfig.load(); - } - public void save () { - tConfig.save(); - } - + + public Config(FMLPreInitializationEvent preinit, String cfgname) { + File tFile = new File(preinit.getModConfigurationDirectory(), cfgname); + tConfig = new Configuration(tFile); + tConfig.load(); + } + + public void save() { + if (tConfig.hasChanged()) + tConfig.save(); + } + } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java b/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java index c781991fe6..c62a196bb4 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java @@ -1,45 +1,53 @@ package pers.gwyog.gtneioreplugin; -import java.util.HashSet; - import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLLoadCompleteEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.relauncher.Side; -import net.minecraft.init.Items; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper; import pers.gwyog.gtneioreplugin.util.GT5OreSmallHelper; +import java.util.HashSet; + @Mod(modid = GTNEIOrePlugin.MODID, name = GTNEIOrePlugin.NAME, version = GTNEIOrePlugin.VERSION, dependencies = "required-after:gregtech;required-after:NotEnoughItems") 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 = "@version@"; + public static final Logger LOG = LogManager.getLogger(NAME); public static boolean csv = false; - public static String CSVname; - public static HashSet OreV=new HashSet(); - + public static String CSVname; + public static String CSVnameSmall; + public static HashSet OreV = new HashSet(); + public static boolean hideBackground = true; + public static boolean toolTips = true; @Mod.Instance(MODID) public static GTNEIOrePlugin instance; - + @EventHandler public void preinit(FMLPreInitializationEvent event) { - Config c = new Config(event, this.MODID+".cfg"); - csv = c.tConfig.getBoolean("print csv","ALL", false, "princsv, you need apache commons collections to be injected in the minecraft jar."); - CSVname = c.tConfig.getString("CSV_name", "ALL", event.getModConfigurationDirectory()+"/GTNH-Oresheet.csv", "rename the oresheet here, it will appear in /config"); - c.save(); + Config c = new Config(event, this.MODID + ".cfg"); + csv = c.tConfig.getBoolean("print csv", "ALL", false, "princsv, you need apache commons collections to be injected in the minecraft jar."); + CSVname = c.tConfig.getString("CSV_name", "ALL", event.getModConfigurationDirectory() + "/GTNH-Oresheet.csv", "rename the oresheet here, it will appear in /config"); + CSVnameSmall= c.tConfig.getString("CSV_name_for_Small_Ore_Sheet", "ALL", event.getModConfigurationDirectory() + "/GTNH-Small-Ores-Sheet.csv", "rename the oresheet here, it will appear in /config"); + hideBackground = c.tConfig.getBoolean("Hide Background", "ALL", true, "Hides the Background when the tooltip for the Dimensions is rendered"); + toolTips = c.tConfig.getBoolean("DimTooltip", "ALL", true, "Activates Dimensison Tooltips"); + + c.save(); } - + @EventHandler public void onLoadComplete(FMLLoadCompleteEvent event) { if (event.getSide() == Side.CLIENT) { - new GT5OreLayerHelper(); + new GT5OreLayerHelper(); new GT5OreSmallHelper(); - if (csv) { - new pers.gwyog.gtneioreplugin.util.CSVMaker().run(); - } - } + if (csv) { + new pers.gwyog.gtneioreplugin.util.CSVMaker().run(); } + } + } } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java index 06133bebcc..8283b3b263 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java @@ -2,12 +2,11 @@ package pers.gwyog.gtneioreplugin.plugin; import codechicken.nei.api.API; import codechicken.nei.api.IConfigureNEI; -import cpw.mods.fml.common.Loader; import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; -//import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5AsteroidStat; import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5SmallOreStat; import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5VeinStat; -import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper; + +//import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5AsteroidStat; public class NEIPluginConfig implements IConfigureNEI { @@ -23,14 +22,14 @@ public class NEIPluginConfig implements IConfigureNEI { @Override public void loadConfig() { - PluginGT5VeinStat pluginVeinStat = new PluginGT5VeinStat(); - //PluginGT5AsteroidStat pluginAsteriodStat = new PluginGT5AsteroidStat(); - PluginGT5SmallOreStat pluginSmallOreStat = new PluginGT5SmallOreStat(); - API.registerRecipeHandler(pluginVeinStat); - API.registerUsageHandler(pluginVeinStat); - //API.registerRecipeHandler(pluginAsteriodStat); - //API.registerUsageHandler(pluginAsteriodStat); - API.registerRecipeHandler(pluginSmallOreStat); - API.registerUsageHandler(pluginSmallOreStat); - } + PluginGT5VeinStat pluginVeinStat = new PluginGT5VeinStat(); + //PluginGT5AsteroidStat pluginAsteriodStat = new PluginGT5AsteroidStat(); + PluginGT5SmallOreStat pluginSmallOreStat = new PluginGT5SmallOreStat(); + API.registerRecipeHandler(pluginVeinStat); + API.registerUsageHandler(pluginVeinStat); + //API.registerRecipeHandler(pluginAsteriodStat); + //API.registerUsageHandler(pluginAsteriodStat); + API.registerRecipeHandler(pluginSmallOreStat); + API.registerUsageHandler(pluginSmallOreStat); } +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java index cbca2a66c6..9186eddcbd 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java @@ -1,20 +1,19 @@ package pers.gwyog.gtneioreplugin.plugin; -import java.awt.Rectangle; - import codechicken.lib.gui.GuiDraw; import codechicken.nei.recipe.TemplateRecipeHandler; -import codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRect; import net.minecraft.client.resources.I18n; import net.minecraft.util.EnumChatFormatting; +import java.awt.*; + public class PluginBase extends TemplateRecipeHandler { @Override public int recipiesPerPage() { return 1; } - + @Override public String getRecipeName() { return null; @@ -24,17 +23,17 @@ public class PluginBase extends TemplateRecipeHandler { public String getGuiTexture() { return "gtneioreplugin:textures/gui/nei/guiBase.png"; } - + @Override public void loadTransferRects() { int stringLength = GuiDraw.getStringWidth(EnumChatFormatting.BOLD + I18n.format("gui.nei.seeAll")); - transferRects.add(new RecipeTransferRect(new Rectangle(getGuiWidth()-stringLength-3, 5, stringLength, 9), getOutputId())); + transferRects.add(new RecipeTransferRect(new Rectangle(getGuiWidth() - stringLength - 3, 5, stringLength, 9), getOutputId())); } - + public String getOutputId() { return null; } - + public String getWorldNameTranslated(boolean genOverworld) { String worldNameTranslated = ""; if (genOverworld) { @@ -44,9 +43,9 @@ public class PluginBase extends TemplateRecipeHandler { } return worldNameTranslated; } - + public int getGuiWidth() { return 166; } - + } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java index 1d612d8c9c..88775c3e14 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java @@ -1,31 +1,88 @@ package pers.gwyog.gtneioreplugin.plugin.gregtech5; +import codechicken.lib.gui.GuiDraw; +import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.util.GT_LanguageManager; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; import pers.gwyog.gtneioreplugin.plugin.PluginBase; +import pers.gwyog.gtneioreplugin.util.DimensionHelper; + +import java.util.List; + +import static pers.gwyog.gtneioreplugin.GTNEIOrePlugin.hideBackground; +import static pers.gwyog.gtneioreplugin.GTNEIOrePlugin.toolTips; public class PluginGT5Base extends PluginBase { - - public int getMaximumMaterialIndex(short meta, boolean smallOre) { - int offset = smallOre? 16000: 0; - if (!getGTOreLocalizedName((short)(meta+offset+5000)).equals(getGTOreUnlocalizedName((short)(meta+offset+5000)))) - return 7; - else if (!getGTOreLocalizedName((short)(meta+offset+5000)).equals(getGTOreUnlocalizedName((short)(meta+offset+5000)))) - return 6; - else - return 5; + + protected boolean ttDisplayed = false; + + protected static String getLocalizedNameForItem(Materials aMaterial, String aFormat) { + return String.format(aFormat.replace("%s", "%temp").replace("%material", "%s"), aMaterial.mDefaultLocalName).replace("%temp", "%s"); + } + + protected static int calculateMaxW(List L) { + int w = 0; + FontRenderer font = GuiDraw.fontRenderer; + for (int i = 0; i < L.size(); ++i) { + String s = (String) L.get(i); + w = Math.max(font.getStringWidth(s), w); + } + return w; + } + + protected static String getLocalizedNameForItem(String aFormat, int aMaterialID) { + if (aMaterialID >= 0 && aMaterialID < 1000) { + Materials aMaterial = GregTech_API.sGeneratedMaterials[aMaterialID]; + if (aMaterial != null) { + return getLocalizedNameForItem(aMaterial, aFormat); + } + } + return aFormat; } - + public static 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"; + + if (!getLocalizedNameForItem(GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(index)), index % 1000).contains("Awakened")) + return getLocalizedNameForItem(GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(index)), index % 1000); + else + return "Aw. Draconium Ore"; } - - public static String getGTOreUnlocalizedName(short index) { + + protected static String getGTOreUnlocalizedName(short index) { return "gt.blockores." + index + ".name"; } + protected void drawToolTip(String sDimNames) { + if (toolTips) { + ttDisplayed = false; + if (GuiDraw.getMousePosition().y > (int) (Minecraft.getMinecraft().currentScreen.height * 0.6f) && GuiDraw.getMousePosition().y < (int) (Minecraft.getMinecraft().currentScreen.height * 0.8f)) { + List<String> dims = DimensionHelper.convertCondensedStringToToolTip(sDimNames); + int w = calculateMaxW(dims); + int x = GuiDraw.getMousePosition().x > Minecraft.getMinecraft().currentScreen.width / 2 ? this.getGuiWidth() - w - 8 : 0; + if (dims.size() > 10) { + List<String> dims2 = dims.subList(11, dims.size()); + int w2 = calculateMaxW(dims2); + dims = dims.subList(0, 11); + w = calculateMaxW(dims); + GuiDraw.drawMultilineTip(x == 0 ? 16 + w : x - (w2 + 8), 108 - (dims.size() * 8), dims2); + } + GuiDraw.drawMultilineTip(x, 108 - (dims.size() * 8), dims); + + ttDisplayed = hideBackground; + } + } + } + + protected int getMaximumMaterialIndex(short meta, boolean smallOre) { + int offset = smallOre ? 16000 : 0; + if (!getGTOreLocalizedName((short) (meta + offset + 5000)).equals(getGTOreUnlocalizedName((short) (meta + offset + 5000)))) + return 7; + else if (!getGTOreLocalizedName((short) (meta + offset + 5000)).equals(getGTOreUnlocalizedName((short) (meta + offset + 5000)))) + return 6; + else + return 5; + } + } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java index 66ede68225..4a8e2174e3 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java @@ -1,135 +1,140 @@ package pers.gwyog.gtneioreplugin.plugin.gregtech5; -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.List; - import codechicken.lib.gui.GuiDraw; import codechicken.nei.PositionedStack; import gregtech.api.GregTech_API; -import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; -import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_OreDictUnificator; -import gregtech.common.blocks.GT_Block_Ores_Abstract; import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; -import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5VeinStat.CachedVeinStatRecipe; -import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper; import pers.gwyog.gtneioreplugin.util.GT5OreSmallHelper; -import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper.OreLayerWrapper; import pers.gwyog.gtneioreplugin.util.GT5OreSmallHelper.OreSmallWrapper; -public class PluginGT5SmallOreStat extends PluginGT5Base { - - public class CachedOreSmallRecipe extends CachedRecipe { - public String oreGenName; - public PositionedStack positionedStackOreSmall; - public PositionedStack positionedStackMaterialDust; - public List<PositionedStack> positionedDropStackList; +import java.util.ArrayList; +import java.util.List; - public CachedOreSmallRecipe(String oreGenName, List<ItemStack> stackList, List<ItemStack> materialDustStackList, List<ItemStack> dropStackList) { - this.oreGenName = oreGenName; - this.positionedStackOreSmall = new PositionedStack(stackList, 2, 0); - this.positionedStackMaterialDust = new PositionedStack(materialDustStackList, 43, 79+getRestrictBiomeOffset()); - List<PositionedStack> positionedDropStackList = new ArrayList<PositionedStack>(); - int i = 1; - for (ItemStack stackDrop: dropStackList) - positionedDropStackList.add(new PositionedStack(stackDrop, 43+20*(i%4), 79+16*((i++)/4)+getRestrictBiomeOffset())); - this.positionedDropStackList = positionedDropStackList; - } +public class PluginGT5SmallOreStat extends PluginGT5Base { - @Override - public List<PositionedStack> getIngredients() { - positionedStackOreSmall.setPermutationToRender((cycleticks / 20) % positionedStackOreSmall.items.length); - positionedStackMaterialDust.setPermutationToRender((cycleticks / 20) % positionedStackMaterialDust.items.length); - positionedDropStackList.add(positionedStackOreSmall); - positionedDropStackList.add(positionedStackMaterialDust); - return positionedDropStackList; - - } - - @Override - public PositionedStack getResult() { - return null; - } - - } - @Override public void drawExtras(int recipe) { CachedOreSmallRecipe crecipe = (CachedOreSmallRecipe) this.arecipes.get(recipe); OreSmallWrapper oreSmall = GT5OreSmallHelper.mapOreSmallWrapper.get(crecipe.oreGenName); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.oreName") + ": " + getGTOreLocalizedName((short)(oreSmall.oreMeta+16000)), 2, 18, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.genHeight") + ": " + oreSmall.worldGenHeightRange, 2, 31, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.amount") + ": " + oreSmall.amountPerChunk, 2, 44, 0x404040, false); - // GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": " + getWorldNameTranslated(oreSmall.genOverworld, oreSmall.genNether, oreSmall.genEnd, oreSmall.genMoon, oreSmall.genMars), 2, 57, 0x404040, false); - // if (GT5OreSmallHelper.restrictBiomeSupport) GuiDraw.drawString(I18n.format("gtnop.gui.nei.restrictBiome") + ": " + getBiomeTranslated(oreSmall.restrictBiome), 2, 70, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.chanceDrops") + ": ", 2, 83+getRestrictBiomeOffset(), 0x404040, false); - GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gtnop.gui.nei.seeAll"), getGuiWidth()-3, 5, 0x404040, false); + String sDimNames = GT5OreSmallHelper.bufferedDims.get(oreSmall); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.oreName") + ": " + getGTOreLocalizedName((short) (oreSmall.oreMeta + 16000)), 2, 18, 0x404040, false); + drawToolTip(sDimNames); + if (!ttDisplayed) { + GuiDraw.drawString(I18n.format("gtnop.gui.nei.genHeight") + ": " + oreSmall.worldGenHeightRange, 2, 31, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.amount") + ": " + oreSmall.amountPerChunk, 2, 44, 0x404040, false); + // GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": " + getWorldNameTranslated(oreSmall.genOverworld, oreSmall.genNether, oreSmall.genEnd, oreSmall.genMoon, oreSmall.genMars), 2, 57, 0x404040, false); + // if (GT5OreSmallHelper.restrictBiomeSupport) GuiDraw.drawString(I18n.format("gtnop.gui.nei.restrictBiome") + ": " + getBiomeTranslated(oreSmall.restrictBiome), 2, 70, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.chanceDrops") + ": ", 2, 83 + getRestrictBiomeOffset(), 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": ", 2, 110, 0x404040, false); + if (sDimNames.length() > 36) { + GuiDraw.drawString(I18n.format("") + sDimNames.substring(0, 36), 2, 120, 0x404040, false); + if (sDimNames.length() > 70) { + GuiDraw.drawString(I18n.format("") + sDimNames.substring(36, 70), 2, 130, 0x404040, false); + GuiDraw.drawString(I18n.format("") + sDimNames.substring(70, sDimNames.length() - 1), 2, 140, 0x404040, false); + } else + GuiDraw.drawString(I18n.format("") + sDimNames.substring(36, sDimNames.length() - 1), 2, 130, 0x404040, false); + } else + GuiDraw.drawString(I18n.format("") + sDimNames.substring(0, sDimNames.length() - 1), 2, 120, 0x404040, false); + } + GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gtnop.gui.nei.seeAll"), getGuiWidth() - 3, 5, 0x404040, false); } - + public int getRestrictBiomeOffset() { - return GT5OreSmallHelper.restrictBiomeSupport? 0: -13; + return GT5OreSmallHelper.restrictBiomeSupport ? 0 : -13; } - + @Override public void loadCraftingRecipes(String outputId, Object... results) { if (outputId.equals(getOutputId())) - for (ItemStack stack: GT5OreSmallHelper.oreSmallList) + for (ItemStack stack : GT5OreSmallHelper.oreSmallList) loadCraftingRecipes(stack); else super.loadCraftingRecipes(outputId, results); } - + @Override public void loadCraftingRecipes(ItemStack stack) { if (stack.getUnlocalizedName().startsWith("gt.blockores")) { - if (stack.getItemDamage()<16000) { + if (stack.getItemDamage() < 16000) { super.loadCraftingRecipes(stack); return; } - short baseMeta = (short)(stack.getItemDamage() % 1000); - for (OreSmallWrapper oreSmallWorldGen: GT5OreSmallHelper.mapOreSmallWrapper.values()) { + short baseMeta = (short) (stack.getItemDamage() % 1000); + for (OreSmallWrapper oreSmallWorldGen : GT5OreSmallHelper.mapOreSmallWrapper.values()) { if (oreSmallWorldGen.oreMeta == baseMeta) { List<ItemStack> stackList = new ArrayList<ItemStack>(); int maximumIndex = getMaximumMaterialIndex(baseMeta, true); - for (int i=0;i<maximumIndex;i++) - stackList.add(new ItemStack(GregTech_API.sBlockOres1, 1, oreSmallWorldGen.oreMeta+16000+i*1000)); + for (int i = 0; i < maximumIndex; i++) + stackList.add(new ItemStack(GregTech_API.sBlockOres1, 1, oreSmallWorldGen.oreMeta + 16000 + i * 1000)); List<ItemStack> materialDustStackList = new ArrayList<ItemStack>(); - for (int i=0;i<maximumIndex;i++) + for (int i = 0; i < maximumIndex; i++) materialDustStackList.add(GT_OreDictUnificator.get(OrePrefixes.dust, GT5OreSmallHelper.getDroppedDusts()[i], 1L)); this.arecipes.add(new CachedOreSmallRecipe(oreSmallWorldGen.oreGenName, stackList, materialDustStackList, GT5OreSmallHelper.mapOreMetaToOreDrops.get(baseMeta))); } } - } - else if (GT5OreSmallHelper.mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) { + } else if (GT5OreSmallHelper.mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) { short baseMeta = GT5OreSmallHelper.mapOreDropUnlocalizedNameToOreMeta.get(stack.getUnlocalizedName()); - for (String oreGenName: GT5OreSmallHelper.mapOreSmallWrapper.keySet()) { + for (String oreGenName : GT5OreSmallHelper.mapOreSmallWrapper.keySet()) { OreSmallWrapper oreSmallWrapper = GT5OreSmallHelper.mapOreSmallWrapper.get(oreGenName); if (oreSmallWrapper.oreMeta == baseMeta) { List<ItemStack> stackList = new ArrayList<ItemStack>(); - for (int i=0;i<7;i++) - stackList.add(new ItemStack(GregTech_API.sBlockOres1, 1, baseMeta+16000+i*1000)); + for (int i = 0; i < 7; i++) + stackList.add(new ItemStack(GregTech_API.sBlockOres1, 1, baseMeta + 16000 + i * 1000)); List<ItemStack> materialDustStackList = new ArrayList<ItemStack>(); - for (int i=0;i<7;i++) + for (int i = 0; i < 7; i++) materialDustStackList.add(GT_OreDictUnificator.get(OrePrefixes.dust, GT5OreSmallHelper.getDroppedDusts()[i], 1L)); this.arecipes.add(new CachedOreSmallRecipe(GT5OreSmallHelper.mapOreSmallWrapper.get(oreGenName).oreGenName, stackList, materialDustStackList, GT5OreSmallHelper.mapOreMetaToOreDrops.get(baseMeta))); } } - } - else + } else super.loadCraftingRecipes(stack); } - + @Override public String getOutputId() { return "GTOrePluginOreSmall"; } - + @Override public String getRecipeName() { return I18n.format("gtnop.gui.smallOreStat.name"); } + + public class CachedOreSmallRecipe extends CachedRecipe { + public String oreGenName; + public PositionedStack positionedStackOreSmall; + public PositionedStack positionedStackMaterialDust; + public List<PositionedStack> positionedDropStackList; + + public CachedOreSmallRecipe(String oreGenName, List<ItemStack> stackList, List<ItemStack> materialDustStackList, List<ItemStack> dropStackList) { + this.oreGenName = oreGenName; + this.positionedStackOreSmall = new PositionedStack(stackList, 2, 0); + this.positionedStackMaterialDust = new PositionedStack(materialDustStackList, 43, 79 + getRestrictBiomeOffset()); + List<PositionedStack> positionedDropStackList = new ArrayList<PositionedStack>(); + int i = 1; + for (ItemStack stackDrop : dropStackList) + positionedDropStackList.add(new PositionedStack(stackDrop, 43 + 20 * (i % 4), 79 + 16 * ((i++) / 4) + getRestrictBiomeOffset())); + this.positionedDropStackList = positionedDropStackList; + } + + @Override + public List<PositionedStack> getIngredients() { + positionedStackOreSmall.setPermutationToRender((cycleticks / 20) % positionedStackOreSmall.items.length); + positionedStackMaterialDust.setPermutationToRender((cycleticks / 20) % positionedStackMaterialDust.items.length); + positionedDropStackList.add(positionedStackOreSmall); + positionedDropStackList.add(positionedStackMaterialDust); + return positionedDropStackList; + + } + + @Override + public PositionedStack getResult() { + return null; + } + + } } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java index 4cc76f2bf4..2c9f9d3298 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java @@ -1,129 +1,171 @@ package pers.gwyog.gtneioreplugin.plugin.gregtech5; -import java.io.FileWriter; -import java.io.IOException; -import java.io.StringWriter; -import java.io.Writer; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import com.opencsv.bean.ColumnPositionMappingStrategy; -import com.opencsv.bean.StatefulBeanToCsv; -import com.opencsv.bean.StatefulBeanToCsvBuilder; -import com.opencsv.exceptions.CsvDataTypeMismatchException; -import com.opencsv.exceptions.CsvRequiredFieldEmptyException; - import codechicken.lib.gui.GuiDraw; import codechicken.nei.PositionedStack; import gregtech.api.GregTech_API; import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; -import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; -import pers.gwyog.gtneioreplugin.util.GT5CFGHelper; import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper; import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper.OreLayerWrapper; -import pers.gwyog.gtneioreplugin.util.Oremix; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; public class PluginGT5VeinStat extends PluginGT5Base { - public class CachedVeinStatRecipe extends CachedRecipe { - public String veinName; - public PositionedStack positionedStackPrimary; - public PositionedStack positionedStackSecondary; - public PositionedStack positionedStackBetween; - public PositionedStack positionedStackSporadic; - - public CachedVeinStatRecipe(String veinName, List<ItemStack> stackListPrimary, List<ItemStack> stackListSecondary, - List<ItemStack> stackListBetween, List<ItemStack> stackListSporadic) { - this.veinName = veinName; - positionedStackPrimary = new PositionedStack(stackListPrimary, 2, 0); - positionedStackSecondary = new PositionedStack(stackListSecondary, 22, 0); - positionedStackBetween = new PositionedStack(stackListBetween, 42, 0); - positionedStackSporadic = new PositionedStack(stackListSporadic, 62, 0); + public static String[] getLocalizedVeinName(OreLayerWrapper oreLayer) { + String unlocalizedName = oreLayer.veinName; + if (unlocalizedName.startsWith("ore.mix.custom.")) + return get_Cnames(oreLayer);//I18n.format("gtnop.ore.custom.name") + I18n.format("gtnop.ore.vein.name") + unlocalizedName.substring(15); + else + return new String[]{I18n.format("gtnop." + unlocalizedName) + I18n.format("gtnop.ore.vein.name")}; + } + + public static String coustomVeinRenamer(OreLayerWrapper oreLayer) { + Set<String> s = new HashSet<String>(); + for (int i = 0; i < 4; i++) + s.add(getGTOreLocalizedName(oreLayer.Meta[i]).replaceAll(" ", "")); + return s.toString() + .replace("[".charAt(0), ",".charAt(0)) + .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(); + } + + /*public String getWeightedChance(OreLayerWrapper oreLayer) { + String weightedChance = ""; + for (int i=0; i < oreLayer.alloweddims.size(); i++) { + if (oreLayer.alloweddims.get(i) && (oreLayer.Weight.get(i) != 0)) { + if (!weightedChance.isEmpty()) + weightedChance += ", "; + weightedChance += String.format("%.2f%%", (100.0f*oreLayer.Weight.get(i))/GT5OreLayerHelper.weightPerWorld[i]); } - - @Override - public List<PositionedStack> getIngredients() { - List<PositionedStack> ingredientsList = new ArrayList<PositionedStack>(); - positionedStackPrimary.setPermutationToRender((cycleticks / 20) % positionedStackPrimary.items.length);; - positionedStackSecondary.setPermutationToRender((cycleticks / 20) % positionedStackPrimary.items.length);; - positionedStackBetween.setPermutationToRender((cycleticks / 20) % positionedStackPrimary.items.length);; - positionedStackSporadic.setPermutationToRender((cycleticks / 20) % positionedStackPrimary.items.length);; - ingredientsList.add(positionedStackPrimary); - ingredientsList.add(positionedStackSecondary); - ingredientsList.add(positionedStackBetween); - ingredientsList.add(positionedStackSporadic); - return ingredientsList; } - - @Override - public PositionedStack getResult() { - return null; + return weightedChance; + }*/ + + public static 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 < ret.length; i++) { + ret[i] = ret[i].trim(); + } + 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() <= 70 && !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() > 70) && ret[2].length() + splt[i].length() <= 70 && !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() <= 65) + 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[2].isEmpty() && !ret[0].isEmpty()) { + ret1[0] = ret[0]; + return ret1; + } else + return ret; } - + @Override public void loadCraftingRecipes(String outputId, Object... results) { if (outputId.equals(getOutputId())) { OreLayerWrapper oreLayerWrapper; - for (String veinName: GT5OreLayerHelper.mapOreLayerWrapper.keySet()) { + for (String veinName : GT5OreLayerHelper.mapOreLayerWrapper.keySet()) { oreLayerWrapper = GT5OreLayerHelper.mapOreLayerWrapper.get(veinName); List<ItemStack> stackListPrimary = new ArrayList<ItemStack>(); List<ItemStack> stackListSecondary = new ArrayList<ItemStack>(); List<ItemStack> stackListBetween = new ArrayList<ItemStack>(); List<ItemStack> stackListSporadic = new ArrayList<ItemStack>(); - for (int i=0;i<7;i++) { - stackListPrimary.add(new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.Meta[0]+i*1000)); - stackListSecondary.add(new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.Meta[1]+i*1000)); - stackListBetween.add(new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.Meta[2]+i*1000)); - stackListSporadic.add(new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.Meta[3]+i*1000)); - } + for (int i = 0; i < 7; i++) { + stackListPrimary.add(new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.Meta[0] + i * 1000)); + stackListSecondary.add(new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.Meta[1] + i * 1000)); + stackListBetween.add(new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.Meta[2] + i * 1000)); + stackListSporadic.add(new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.Meta[3] + i * 1000)); + } this.arecipes.add(new CachedVeinStatRecipe(veinName, stackListPrimary, stackListSecondary, stackListBetween, stackListSporadic)); } - } - else + } else super.loadCraftingRecipes(outputId, results); } - + @Override public void loadCraftingRecipes(ItemStack stack) { if (stack.getUnlocalizedName().startsWith("gt.blockores")) { - if (stack.getItemDamage()>16000) { + if (stack.getItemDamage() > 16000) { super.loadCraftingRecipes(stack); return; } - short baseMeta = (short)(stack.getItemDamage() % 1000); - for (OreLayerWrapper worldGen: GT5OreLayerHelper.mapOreLayerWrapper.values()) { + short baseMeta = (short) (stack.getItemDamage() % 1000); + for (OreLayerWrapper worldGen : GT5OreLayerHelper.mapOreLayerWrapper.values()) { if (worldGen.Meta[0] == baseMeta || worldGen.Meta[1] == baseMeta || worldGen.Meta[2] == baseMeta || worldGen.Meta[3] == baseMeta) { List<ItemStack> stackListPrimary = new ArrayList<ItemStack>(); List<ItemStack> stackListSecondary = new ArrayList<ItemStack>(); List<ItemStack> stackListBetween = new ArrayList<ItemStack>(); List<ItemStack> stackListSporadic = new ArrayList<ItemStack>(); - for (int i=0;i<getMaximumMaterialIndex(baseMeta, false);i++) { - stackListPrimary.add(new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.Meta[0]+i*1000)); - stackListSecondary.add(new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.Meta[1]+i*1000)); - stackListBetween.add(new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.Meta[2]+i*1000)); - stackListSporadic.add(new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.Meta[3]+i*1000)); + for (int i = 0; i < getMaximumMaterialIndex(baseMeta, false); i++) { + stackListPrimary.add(new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.Meta[0] + i * 1000)); + stackListSecondary.add(new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.Meta[1] + i * 1000)); + stackListBetween.add(new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.Meta[2] + i * 1000)); + stackListSporadic.add(new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.Meta[3] + i * 1000)); } this.arecipes.add(new CachedVeinStatRecipe(worldGen.veinName, stackListPrimary, stackListSecondary, stackListBetween, stackListSporadic)); } } - } - else + } else super.loadCraftingRecipes(stack); } - + @Override public void drawExtras(int recipe) { CachedVeinStatRecipe crecipe = (CachedVeinStatRecipe) this.arecipes.get(recipe); OreLayerWrapper oreLayer = GT5OreLayerHelper.mapOreLayerWrapper.get(crecipe.veinName); - - String Dims = getDims(oreLayer); - + + String sDimNames = GT5OreLayerHelper.bufferedDims.get(oreLayer); + /*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) { @@ -135,147 +177,89 @@ public class PluginGT5VeinStat extends PluginGT5Base { } else*/ if (getGTOreLocalizedName(oreLayer.Meta[0]).contains("Ore")) - GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getGTOreLocalizedName(oreLayer.Meta[0]).split("Ore")[0] + " " +I18n.format("gtnop.gui.nei.vein"), 2, 20, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getGTOreLocalizedName(oreLayer.Meta[0]).split("Ore")[0] + "" + I18n.format("gtnop.gui.nei.vein"), 2, 20, 0x404040, false); else if (getGTOreLocalizedName(oreLayer.Meta[0]).contains("Sand")) - GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getGTOreLocalizedName(oreLayer.Meta[0]).split("Sand")[0] + " " +I18n.format("gtnop.gui.nei.vein"), 2, 20, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getGTOreLocalizedName(oreLayer.Meta[0]).split("Sand")[0] + "" + I18n.format("gtnop.gui.nei.vein"), 2, 20, 0x404040, false); else - GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getGTOreLocalizedName(oreLayer.Meta[0]) + " " +I18n.format("gtnop.gui.nei.vein"), 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); - if (Dims.length()>36) { - GuiDraw.drawString(I18n.format("") + Dims.substring(0, 36), 2, 110, 0x404040, false); - if (Dims.length()>70) { - GuiDraw.drawString(I18n.format("") + Dims.substring(36, 70), 2, 120, 0x404040, false); - GuiDraw.drawString(I18n.format("") + Dims.substring(70, Dims.length()-1), 2, 130, 0x404040, false); - } - else - GuiDraw.drawString(I18n.format("") + Dims.substring(36, Dims.length()-1), 2, 120, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getGTOreLocalizedName(oreLayer.Meta[0]) + " " + I18n.format("gtnop.gui.nei.vein"), 2, 20, 0x404040, false); + drawToolTip(sDimNames); + if (!ttDisplayed) { + 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); + if (sDimNames.length() > 36) { + GuiDraw.drawString(I18n.format("") + sDimNames.substring(0, 36), 2, 110, 0x404040, false); + if (sDimNames.length() > 70) { + GuiDraw.drawString(I18n.format("") + sDimNames.substring(36, 70), 2, 120, 0x404040, false); + GuiDraw.drawString(I18n.format("") + sDimNames.substring(70, sDimNames.length() - 1), 2, 130, 0x404040, false); + } else + GuiDraw.drawString(I18n.format("") + sDimNames.substring(36, sDimNames.length() - 1), 2, 120, 0x404040, false); + } else + GuiDraw.drawString(I18n.format("") + sDimNames.substring(0, sDimNames.length() - 1), 2, 110, 0x404040, false); } - else - GuiDraw.drawString(I18n.format("") + Dims.substring(0, Dims.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); - - } - - public static String[] getLocalizedVeinName(OreLayerWrapper oreLayer) { - - String unlocalizedName = oreLayer.veinName; - if (unlocalizedName.startsWith("ore.mix.custom.")) - return get_Cnames(oreLayer);//I18n.format("gtnop.ore.custom.name") + I18n.format("gtnop.ore.vein.name") + unlocalizedName.substring(15); - else - return new String[] {I18n.format("gtnop." + unlocalizedName) + I18n.format("gtnop.ore.vein.name")}; - } - - public static String coustomVeinRenamer(OreLayerWrapper oreLayer) { - Set<String> s = new HashSet<String>(); - for (int i=0; i < 4; i++) - s.add(getGTOreLocalizedName(oreLayer.Meta[i]).replaceAll(" ", "")); - return s.toString() - .replace("[".charAt(0), ",".charAt(0)) - .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(); - } - - /*public String getWeightedChance(OreLayerWrapper oreLayer) { - String weightedChance = ""; - for (int i=0; i < oreLayer.alloweddims.size(); i++) { - if (oreLayer.alloweddims.get(i) && (oreLayer.Weight.get(i) != 0)) { - if (!weightedChance.isEmpty()) - weightedChance += ", "; - weightedChance += String.format("%.2f%%", (100.0f*oreLayer.Weight.get(i))/GT5OreLayerHelper.weightPerWorld[i]); - } - } - return weightedChance; - }*/ - - public static String getDims(OreLayerWrapper oreLayer) { - return GT5CFGHelper.GT5CFG(GregTech_API.sWorldgenFile.mConfig.getConfigFile(), oreLayer.veinName.replace("ore.mix.custom.", "").replace("ore.mix.", "")); + GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gtnop.gui.nei.seeAll"), getGuiWidth() - 3, 5, 0x404040, false); } - - public static 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()<=70&&!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()>70)&&ret[2].length()+splt[i].length()<=70&&!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()<=65) - 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"; } - + @Override public String getRecipeName() { return I18n.format("gtnop.gui.veinStat.name"); } - + + public class CachedVeinStatRecipe extends CachedRecipe { + public String veinName; + public PositionedStack positionedStackPrimary; + public PositionedStack positionedStackSecondary; + public PositionedStack positionedStackBetween; + public PositionedStack positionedStackSporadic; + + public CachedVeinStatRecipe(String veinName, List<ItemStack> stackListPrimary, List<ItemStack> stackListSecondary, + List<ItemStack> stackListBetween, List<ItemStack> stackListSporadic) { + this.veinName = veinName; + positionedStackPrimary = new PositionedStack(stackListPrimary, 2, 0); + positionedStackSecondary = new PositionedStack(stackListSecondary, 22, 0); + positionedStackBetween = new PositionedStack(stackListBetween, 42, 0); + positionedStackSporadic = new PositionedStack(stackListSporadic, 62, 0); + } + + @Override + public List<PositionedStack> getIngredients() { + List<PositionedStack> ingredientsList = new ArrayList<PositionedStack>(); + positionedStackPrimary.setPermutationToRender((cycleticks / 20) % positionedStackPrimary.items.length); + ; + positionedStackSecondary.setPermutationToRender((cycleticks / 20) % positionedStackPrimary.items.length); + ; + positionedStackBetween.setPermutationToRender((cycleticks / 20) % positionedStackPrimary.items.length); + ; + positionedStackSporadic.setPermutationToRender((cycleticks / 20) % positionedStackPrimary.items.length); + ; + ingredientsList.add(positionedStackPrimary); + ingredientsList.add(positionedStackSecondary); + ingredientsList.add(positionedStackBetween); + ingredientsList.add(positionedStackSporadic); + return ingredientsList; + } + + @Override + public PositionedStack getResult() { + return null; + } + + } + } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java b/src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java index 82a2f4f341..f12405a7ae 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java @@ -1,5 +1,13 @@ package pers.gwyog.gtneioreplugin.util; +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; @@ -8,60 +16,129 @@ 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; +public class CSVMaker implements Runnable { -import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; -import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5VeinStat; -import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper.OreLayerWrapper; + public CSVMaker() { -public class CSVMaker implements Runnable { + } + + public static List<Oremix> Combsort(List<Oremix> liste) { + try { + List<Oremix> liste2 = new ArrayList<Oremix>(liste.size()); + for (Oremix element : liste) { + liste2.add(element); + } - public CSVMaker() { - - } - - public static <T> List<Oremix> Combsort(List<Oremix> liste) { - try { - List<Oremix> liste2 = new ArrayList<Oremix>(liste.size()); - for (Oremix element : liste) { - liste2.add(element); - } - - int schritt = liste2.size(); - boolean vertauscht = false; - do { - vertauscht = false; - if (schritt > 1) { - 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) { - T tmp = (T) liste2.get(i); - liste2.set(i, liste2.get(i + schritt)); - liste2.set(i + schritt, (Oremix) tmp); - vertauscht = true; - } - } - } while (vertauscht || schritt > 1); - return liste2; - }catch (Exception e) { - e.printStackTrace(); - return null; - } + int schritt = liste2.size(); + boolean vertauscht = false; + do { + vertauscht = false; + if (schritt > 1) { + 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) { + Oremix tmp = (Oremix) liste2.get(i); + liste2.set(i, liste2.get(i + schritt)); + liste2.set(i + schritt, (Oremix) tmp); + vertauscht = true; + } + } + } while (vertauscht || schritt > 1); + return liste2; + } catch (Exception e) { + e.printStackTrace(); + return null; + } } - - public void run() { - try { - Iterator it = GT5OreLayerHelper.mapOreLayerWrapper.entrySet().iterator(); - List<Oremix> OreVeins=new ArrayList(); - while (it.hasNext()) { - Oremix oremix = new Oremix(); - - Map.Entry pair = (Map.Entry)it.next(); - String Dims = PluginGT5VeinStat.getDims((OreLayerWrapper)pair.getValue()); + + public void runSmallOres() { + try { + Iterator it = GT5OreSmallHelper.mapOreSmallWrapper.entrySet().iterator(); + List<Oremix> OreVeins = new ArrayList(); + while (it.hasNext()) { + Oremix oremix = new Oremix(); + + Map.Entry pair = (Map.Entry) it.next(); + String Dims = GT5OreSmallHelper.bufferedDims.get(pair.getValue()); + GT5OreSmallHelper.OreSmallWrapper oreLayer = (GT5OreSmallHelper.OreSmallWrapper) pair.getValue(); + oremix.setOreName(oreLayer.oreGenName.split("\\.")[2]); + oremix.setHeight(oreLayer.worldGenHeightRange); + oremix.setDensity(oreLayer.amountPerChunk); + 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.io = Dims.contains("Io"); + oremix.kb = Dims.contains("KB"); + oremix.make = Dims.contains("MM"); + oremix.ma = Dims.contains("Ma"); + oremix.me = Dims.contains("Me"); + oremix.mi = Dims.contains("Mi"); + oremix.mo = Dims.contains("Mo"); + oremix.ob = Dims.contains("Ob"); + oremix.ph = Dims.contains("Ph"); + oremix.pl = Dims.contains("Pl"); + oremix.pr = Dims.contains("Pr"); + 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 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("\\,"); + 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.newLine(); + beanToCsv.write(towrite); + one.flush(); + one.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void run() { + runVeins(); + runSmallOres(); + } + + public void runVeins() { + try { + Iterator it = GT5OreLayerHelper.mapOreLayerWrapper.entrySet().iterator(); + List<Oremix> OreVeins = new ArrayList(); + while (it.hasNext()) { + Oremix oremix = new Oremix(); + + Map.Entry pair = (Map.Entry) it.next(); + String Dims = GT5OreLayerHelper.bufferedDims.get(pair.getValue()); OreLayerWrapper oreLayer = (OreLayerWrapper) pair.getValue(); oremix.setOreName(oreLayer.veinName.split("\\.")[2]); oremix.setPrimary(PluginGT5VeinStat.getGTOreLocalizedName(oreLayer.Meta[0])); @@ -72,66 +149,65 @@ 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.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.io=Dims.contains("Io"); - oremix.kb=Dims.contains("KB"); - oremix.make=Dims.contains("MM"); - oremix.ma=Dims.contains("Ma"); - oremix.me=Dims.contains("Me"); - oremix.mi=Dims.contains("Mi"); - oremix.mo=Dims.contains("Mo"); - oremix.ob=Dims.contains("Ob"); - oremix.ph=Dims.contains("Ph"); - oremix.pl=Dims.contains("Pl"); - oremix.pr=Dims.contains("Pr"); - 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.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"); + 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.io = Dims.contains("Io"); + oremix.kb = Dims.contains("KB"); + oremix.make = Dims.contains("MM"); + oremix.ma = Dims.contains("Ma"); + oremix.me = Dims.contains("Me"); + oremix.mi = Dims.contains("Mi"); + oremix.mo = Dims.contains("Mo"); + oremix.ob = Dims.contains("Ob"); + oremix.ph = Dims.contains("Ph"); + oremix.pl = Dims.contains("Pl"); + oremix.pr = Dims.contains("Pr"); + 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)); + } + 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("\\,"); strat.setColumnMapping(columns); - StatefulBeanToCsv<Oremix> beanToCsv = new StatefulBeanToCsvBuilder(one) + 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.newLine(); - beanToCsv.write(towrite); - one.flush(); - one.close(); - - }catch (Exception e) { - e.printStackTrace(); - } - } + 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.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 index c0842bfbfa..1d4b0e0025 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java @@ -1,85 +1,114 @@ package pers.gwyog.gtneioreplugin.util; -import net.minecraft.world.World; -import net.minecraft.world.WorldProvider; -import net.minecraft.world.WorldServer; -import net.minecraftforge.common.DimensionManager; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; public class DimensionHelper { - - public static String[] DimName = - { - "EndAsteroid", - "GalacticraftCore_Moon", - "GalacticraftMars_Asteroids", - "GalacticraftMars_Mars", - "GalaxySpace_BarnardC", - "GalaxySpace_BarnardE", - "GalaxySpace_BarnardF", - "GalaxySpace_Callisto", - "GalaxySpace_CentauriA", - "GalaxySpace_Ceres", - "GalaxySpace_Deimos", - "GalaxySpace_Enceladus", - "GalaxySpace_Europa", - "GalaxySpace_Ganymede", - "GalaxySpace_Haumea", - "GalaxySpace_Io", - "GalaxySpace_Kuiperbelt", - "GalaxySpace_MakeMake", - "GalaxySpace_Mercury", - "GalaxySpace_Miranda", - "GalaxySpace_Oberon", - "GalaxySpace_Phobos", - "GalaxySpace_Pluto", - "GalaxySpace_Proteus", - "GalaxySpace_TcetiE", - "GalaxySpace_Titan", - "GalaxySpace_Triton", - "GalaxySpace_VegaB", - "GalaxySpace_Venus", - "Nether", - "Overworld", - "TheEnd", - "Vanilla_EndAsteroids", - "Twilight", - "Underdark"}; - - public static String[] DimNameDisplayed = - {// first 2 letters if one word else 1 letter of every word, execpt capital letter in name, then 1rst + capital Moon = Mo, BarnardC = BC, EndAsteroid = EA - "EA", - "Mo", - "As", - "Ma", - "BC", - "BE", - "BF", - "Ca", - "CA", - "Ce", - "De", - "En", - "Eu", - "Ga", - "Ha", - "Io", - "KB", - "MM", - "Me", - "Mi", - "Ob", - "Ph", - "Pl", - "Pr", - "TE", - "Ti", - "Tr", - "VB", - "Ve", - "Ne", - "Ow", - "EN",//End = EN bc En = Encalus - "VA", - "TF", - "DD"}; + + public static String[] DimName = + { + "EndAsteroid", + "GalacticraftCore_Moon", + "GalacticraftMars_Asteroids", + "GalacticraftMars_Mars", + "GalaxySpace_BarnardC", + "GalaxySpace_BarnardE", + "GalaxySpace_BarnardF", + "GalaxySpace_Callisto", + "GalaxySpace_CentauriA", + "GalaxySpace_Ceres", + "GalaxySpace_Deimos", + "GalaxySpace_Enceladus", + "GalaxySpace_Europa", + "GalaxySpace_Ganymede", + "GalaxySpace_Haumea", + "GalaxySpace_Io", + "GalaxySpace_Kuiperbelt", + "GalaxySpace_MakeMake", + "GalaxySpace_Mercury", + "GalaxySpace_Miranda", + "GalaxySpace_Oberon", + "GalaxySpace_Phobos", + "GalaxySpace_Pluto", + "GalaxySpace_Proteus", + "GalaxySpace_TcetiE", + "GalaxySpace_Titan", + "GalaxySpace_Triton", + "GalaxySpace_VegaB", + "GalaxySpace_Venus", + "Nether", + "Overworld", + "TheEnd", + "Vanilla_EndAsteroids", + "Twilight", + "Underdark" + }; + + public static String[] DimNameDisplayed = + {// first 2 letters if one word else 1 letter of every word, execpt capital letter in name, then 1rst + capital Moon = Mo, BarnardC = BC, EndAsteroid = EA + "EA", + "Mo", + "As", + "Ma", + "BC", + "BE", + "BF", + "Ca", + "CA", + "Ce", + "De", + "En", + "Eu", + "Ga", + "Ha", + "Io", + "KB", + "MM", + "Me", + "Mi", + "Ob", + "Ph", + "Pl", + "Pr", + "TE", + "Ti", + "Tr", + "VB", + "Ve", + "Ne", + "Ow", + "EN",//End = EN bc En = Encalus + "VA", + "TF", + "DD" + }; + + private static HashMap<String, List<String>> tooltipBuffer = new HashMap<>(); + + private static List<String> computeString(String line) { + String[] dims = line.split(","); + for (int j = 0; j < dims.length; j++) { + String s = dims[j]; + s = s.replaceAll(",", ""); + s = s.trim(); + for (int i = 0; i < DimNameDisplayed.length; i++) { + if (s.equals(DimNameDisplayed[i])) { + s = DimName[i].replaceAll("GalacticraftCore_", "").replaceAll("GalacticraftMars_", "").replaceAll("GalaxySpace_", "").replaceAll("Vanilla_", "Vanilla "); + if (s.equals("Twilight")) + s = "Twilight Forrest"; + else if (s.equals("Underdark")) + s = "Deep Dark"; + else if (s.equals("EndAsteroid")) + s = "Far End Asteroids"; + dims[j] = s; + } + } + } + return Arrays.asList(dims); + } + + 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 c616534d8d..00260020da 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java @@ -1,5 +1,12 @@ 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; @@ -8,128 +15,170 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; -import cpw.mods.fml.common.FMLLog; - public class GT5CFGHelper { - - public static String GT5CFG(File F, 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 aviable - //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=null; - List<String> raw= new ArrayList<String>(); - List<String> rawbools = new ArrayList<String>(); - 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)||((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)||((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)||((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 == 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 (int i=0; i < raw.size();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)); - } - else FMLLog.info("raw is empty"); - - String ret=" "; - - 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(" ", "").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.trim(); - //FMLLog.info("ret:"+ret); - if(ret.equals("")||ret.equals(" ")) - ret ="Not aviable in any Galactic Dim!"; + + private static File F = GregTech_API.sWorldgenFile.mConfig.getConfigFile(); + + public static String GT5CFGSmallOres(String Veinname) { + List<String> raw = new ArrayList<String>(); + List<String> rawbools = new ArrayList<String>(); + String st = null; + 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 (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)); + } + else GTNEIOrePlugin.LOG.info("Config entry not found for Vein: " + Veinname); + + String ret = " "; + + 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("\"", ""); + rawboolsset.add(st); + } + rawbools = new ArrayList<String>(rawboolsset); + for (int i = 0; i < rawbools.size(); i++) { + st = rawbools.get(i); + 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.trim(); + if (ret.equals("") || ret.equals(" ")) + ret = "Not aviable in any Galactic Dim!"; return ret; - } catch (IOException e) { - e.printStackTrace(); - return "Error while Loading CFG"; - } - } + } + + 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 aviable + //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 = null; + List<String> raw = new ArrayList<String>(); + List<String> rawbools = new ArrayList<String>(); + 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) || ((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) || ((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) || ((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 == 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 (int i = 0; i < raw.size(); 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)); + } + else GTNEIOrePlugin.LOG.info("Config entry not found for Vein: " + Veinname); + + String ret = " "; + + 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(" ", "").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.trim(); + //FMLLog.info("ret:"+ret); + if (ret.equals("") || ret.equals(" ")) + ret = "Not aviable in any Galactic Dim!"; + return ret; + } 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 index 2b6e286174..9e8a608405 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java @@ -1,57 +1,41 @@ package pers.gwyog.gtneioreplugin.util; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.FileWriter; -import java.io.IOException; -import java.lang.reflect.Field; -import java.nio.file.Files; -import java.nio.file.Paths; +import gregtech.common.GT_Worldgen_GT_Ore_Layer; + import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.List; -import java.util.Map; -import java.util.function.BiConsumer; - -import com.opencsv.CSVReader; -import com.opencsv.CSVWriter; -import com.opencsv.bean.ColumnPositionMappingStrategy; -import com.opencsv.bean.CsvToBean; -import com.opencsv.bean.StatefulBeanToCsv; -import com.opencsv.bean.StatefulBeanToCsvBuilder; - -import cpw.mods.fml.common.Loader; -import gregtech.GT_Mod; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Materials; -import gregtech.common.GT_Worldgen_GT_Ore_Layer; -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; -import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; -import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5VeinStat; 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>(); + 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; - for (GT_Worldgen_GT_Ore_Layer tWorldGen: GT_Worldgen_GT_Ore_Layer.sList) + for (int i = 0; i < DimIDs.length; i++) + weightPerWorld[i] = 0; + for (int i = 0; i < DimIDs.length; i++) + DimIDs[i] = 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)); + } + } + + public static String getDims(OreLayerWrapper oreLayer) { + return GT5CFGHelper.GT5CFG(oreLayer.veinName.replace("ore.mix.custom.", "").replace("ore.mix.", "")); + } + + public class OreLayerWrapper { - public String veinName, worldGenHeightRange, weightedIEChance; + public String veinName, worldGenHeightRange; public short[] Meta = new short[4]; public short randomWeight, size, density; public List<Integer> Weight = new ArrayList<Integer>(); - + public OreLayerWrapper(GT_Worldgen_GT_Ore_Layer worldGen) { this.veinName = worldGen.mWorldGenName; this.Meta[0] = worldGen.mPrimaryMeta; @@ -62,7 +46,7 @@ public class GT5OreLayerHelper { this.density = worldGen.mDensity; this.worldGenHeightRange = worldGen.mMinY + "-" + worldGen.mMaxY; this.randomWeight = worldGen.mWeight; - } } } +}
\ 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 18aca0e5d8..6dc155e9fd 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java @@ -1,19 +1,17 @@ package pers.gwyog.gtneioreplugin.util; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; 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.client.resources.I18n; import net.minecraft.item.ItemStack; -import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; public class GT5OreSmallHelper { public static boolean restrictBiomeSupport = false; @@ -21,8 +19,9 @@ public class GT5OreSmallHelper { 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 HashMap<Short, List<ItemStack>> mapOreMetaToOreDrops = new HashMap<Short, List<ItemStack>>(); + public static HashMap<OreSmallWrapper, String> bufferedDims = new HashMap<>(); + public GT5OreSmallHelper() { checkExtraSupport(); ItemStack stack; @@ -30,68 +29,95 @@ public class GT5OreSmallHelper { 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; + GT_Worldgen_GT_Ore_SmallPieces worldGenSmallPieces = (GT_Worldgen_GT_Ore_SmallPieces) worldGen; meta = worldGenSmallPieces.mMeta; - if (meta<0) - break; + if (meta < 0) + break; material = GregTech_API.sGeneratedMaterials[meta]; mapOreSmallWrapper.put(worldGen.mWorldGenName, new OreSmallWrapper(worldGenSmallPieces)); if (!mapOreMetaToOreDrops.keySet().contains(meta)) { List<ItemStack> stackList = new ArrayList<ItemStack>(); stack = GT_OreDictUnificator.get(OrePrefixes.gemExquisite, material, GT_OreDictUnificator.get(OrePrefixes.gem, material, 1L), 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(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.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) { + mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); + stackList.add(stack); + } stack = GT_OreDictUnificator.get(OrePrefixes.gem, material, 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(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.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) { + mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); + stackList.add(stack); + } stack = GT_OreDictUnificator.get(OrePrefixes.crushed, material, 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(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.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) { + mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); + stackList.add(stack); + } stack = GT_OreDictUnificator.get(OrePrefixes.dustImpure, material, 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} - oreSmallList.add(new ItemStack(GregTech_API.sBlockOres1, 1, meta+16000)); + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) { + mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); + stackList.add(stack); + } + oreSmallList.add(new ItemStack(GregTech_API.sBlockOres1, 1, meta + 16000)); mapOreMetaToOreDrops.put(meta, stackList); } } + for (OreSmallWrapper oreSmallWrapper : mapOreSmallWrapper.values()) { + bufferedDims.put(oreSmallWrapper, GT5CFGHelper.GT5CFGSmallOres(oreSmallWrapper.oreGenName)); + } } - + private static void checkExtraSupport() { - Class clazzGTOreSmall = null; + Class clazzGTOreSmall = null; + try { + clazzGTOreSmall = Class.forName("gregtech.common.GT_Worldgen_GT_Ore_SmallPieces"); + } catch (ClassNotFoundException e) { + } + if (clazzGTOreSmall != null) { try { - clazzGTOreSmall = Class.forName("gregtech.common.GT_Worldgen_GT_Ore_SmallPieces"); - } catch (ClassNotFoundException e) {} - if (clazzGTOreSmall != null) { - try { - Field fieldRestrictBiome = clazzGTOreSmall.getField("mRestrictBiome");; - restrictBiomeSupport = true; - } catch (Exception e) {} - try { - Field fieldGCMoon = clazzGTOreSmall.getField("mMoon"); - Field fieldGCMars = clazzGTOreSmall.getField("mMars"); - gcBasicSupport = true; - } catch (Exception e) {} - } + Field fieldRestrictBiome = clazzGTOreSmall.getField("mRestrictBiome"); + restrictBiomeSupport = true; + } catch (Exception e) { + } + try { + Field fieldGCMoon = clazzGTOreSmall.getField("mMoon"); + Field fieldGCMars = clazzGTOreSmall.getField("mMars"); + gcBasicSupport = true; + } catch (Exception e) { + } + } } - + public static Materials[] getDroppedDusts() { return new Materials[]{Materials.Stone, Materials.Netherrack, Materials.Endstone, Materials.GraniteBlack, Materials.GraniteRed, Materials.Marble, Materials.Basalt, Materials.Stone}; } - + public class OreSmallWrapper { public String oreGenName; public short oreMeta; public String worldGenHeightRange; public short amountPerChunk; public String restrictBiome; - + 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; - } } } +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/Oremix.java b/src/main/java/pers/gwyog/gtneioreplugin/util/Oremix.java index 1b1f44df67..559a11cca8 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/Oremix.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/Oremix.java @@ -4,463 +4,487 @@ import com.opencsv.bean.CsvBindByName; import com.opencsv.bean.CsvCustomBindByName; public class Oremix { - - @CsvCustomBindByName(column = "Ore Name", required = true, converter = Veinrenamer.class) - private String oreName; - @CsvBindByName(column = "Primary", required = false) - private String primary = ""; - @CsvBindByName(column = "Secondary", required = false) - private String secondary = ""; - @CsvBindByName(column = "Inbetween", required = false) - private String inbetween = ""; - @CsvBindByName(column = "Around", required = false) - private String around = ""; - @CsvBindByName(column = "ID ", required = false) - private String mix = ""; - @CsvBindByName(column = "Tier", required = false) - private String tier = ""; - @CsvBindByName(column = "Height", required = false) - private String height = ""; - @CsvBindByName(column = "Density", required = false) - private int density; - @CsvBindByName(column = "Size", required = false) - private int size; - @CsvBindByName(column = "Weight", required = false) - private int weight; - @CsvCustomBindByName(column = "Overworld", required = false, converter = XtoBool.class) - private boolean overworld; - @CsvCustomBindByName(column = "Nether", required = false, converter = XtoBool.class) - private boolean nether; - @CsvCustomBindByName(column = "End", required = false, converter = XtoBool.class) - private boolean end; - @CsvCustomBindByName(column = "Moon", required = false, converter = XtoBool.class) - public boolean mo; - 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; - } + @CsvCustomBindByName(column = "Moon", required = false, converter = XtoBool.class) + public boolean mo; + @CsvCustomBindByName(column = "End Asteroids", required = false, converter = XtoBool.class) + public boolean ea; + @CsvCustomBindByName(column = "AstroidBelt", required = false, converter = XtoBool.class) + public boolean as; + @CsvCustomBindByName(column = "Barnard C", required = false, converter = XtoBool.class) + public boolean bc; + @CsvCustomBindByName(column = "Barnard E", required = false, converter = XtoBool.class) + public boolean be; + @CsvCustomBindByName(column = "Barnard F", required = false, converter = XtoBool.class) + public boolean bf; + @CsvCustomBindByName(column = "Mars", required = false, converter = XtoBool.class) + public boolean ma; + @CsvCustomBindByName(column = "Callisto", required = false, converter = XtoBool.class) + public boolean ca; + @CsvCustomBindByName(column = "Centauri Bb", required = false, converter = XtoBool.class) + public boolean cb; + @CsvCustomBindByName(column = "Ceres", required = false, converter = XtoBool.class) + public boolean ce; + @CsvCustomBindByName(column = "Twilight Forest", required = false, converter = XtoBool.class) + public boolean tf; + @CsvCustomBindByName(column = "Deep Dark", required = false, converter = XtoBool.class) + public boolean dd; + @CsvCustomBindByName(column = "Phobos", required = false, converter = XtoBool.class) + public boolean ph; + @CsvCustomBindByName(column = "Deimos", required = false, converter = XtoBool.class) + public boolean de; + @CsvCustomBindByName(column = "Europa", required = false, converter = XtoBool.class) + public boolean eu; + @CsvCustomBindByName(column = "Ganymede", required = false, converter = XtoBool.class) + public boolean ga; + @CsvCustomBindByName(column = "Io", required = false, converter = XtoBool.class) + public boolean io; + @CsvCustomBindByName(column = "Venus", required = false, converter = XtoBool.class) + public boolean ve; + @CsvCustomBindByName(column = "Mercury", required = false, converter = XtoBool.class) + public boolean me; + @CsvCustomBindByName(column = "Enceladus", required = false, converter = XtoBool.class) + public boolean en; + @CsvCustomBindByName(column = "Titan", required = false, converter = XtoBool.class) + public boolean ti; + @CsvCustomBindByName(column = "Miranda", required = false, converter = XtoBool.class) + public boolean mi; + @CsvCustomBindByName(column = "Oberon", required = false, converter = XtoBool.class) + public boolean ob; + @CsvCustomBindByName(column = "Triton", required = false, converter = XtoBool.class) + public boolean tr; + @CsvCustomBindByName(column = "Proteus", required = false, converter = XtoBool.class) + public boolean pr; + @CsvCustomBindByName(column = "Pluto", required = false, converter = XtoBool.class) + public boolean pl; + @CsvCustomBindByName(column = "Kuiper Belt", required = false, converter = XtoBool.class) + public boolean kb; + @CsvCustomBindByName(column = "Haumea", required = false, converter = XtoBool.class) + public boolean ha; + @CsvCustomBindByName(column = "Makemake", required = false, converter = XtoBool.class) + public boolean make; + @CsvCustomBindByName(column = "Vega B", required = false, converter = XtoBool.class) + public boolean vb; + @CsvCustomBindByName(column = "T Ceti E", required = false, converter = XtoBool.class) + public boolean tcetie; + @CsvCustomBindByName(column = "Ore Name", required = true, converter = Veinrenamer.class) + private String oreName; + @CsvBindByName(column = "Primary", required = false) + private String primary = ""; + @CsvBindByName(column = "Secondary", required = false) + private String secondary = ""; + @CsvBindByName(column = "Inbetween", required = false) + private String inbetween = ""; + @CsvBindByName(column = "Around", required = false) + private String around = ""; + @CsvBindByName(column = "ID ", required = false) + private String mix = ""; + @CsvBindByName(column = "Tier", required = false) + private String tier = ""; + @CsvBindByName(column = "Height", required = false) + private String height = ""; + @CsvBindByName(column = "Density", required = false) + private int density; + @CsvBindByName(column = "Size", required = false) + private int size; + @CsvBindByName(column = "Weight", required = false) + private int weight; + @CsvCustomBindByName(column = "Overworld", required = false, converter = XtoBool.class) + private boolean overworld; + @CsvCustomBindByName(column = "Nether", required = false, converter = XtoBool.class) + private boolean nether; + @CsvCustomBindByName(column = "End", required = false, 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 boolean isDe() { - return de; - } + public void setDd(boolean dd) { + this.dd = dd; + } - public void setDe(boolean de) { - this.de = de; - } + public boolean isPh() { + return ph; + } - public boolean isEu() { - return eu; - } + public void setPh(boolean ph) { + this.ph = ph; + } - public void setEu(boolean eu) { - this.eu = eu; - } + public boolean isDe() { + return de; + } - public boolean isGa() { - return ga; - } + public void setDe(boolean de) { + this.de = de; + } - public void setGa(boolean ga) { - this.ga = ga; - } + public boolean isEu() { + return eu; + } - public boolean isIo() { - return io; - } + public void setEu(boolean eu) { + this.eu = eu; + } - public void setIo(boolean io) { - this.io = io; - } + public boolean isGa() { + return ga; + } - public boolean isVe() { - return ve; - } + public void setGa(boolean ga) { + this.ga = ga; + } - public void setVe(boolean ve) { - this.ve = ve; - } + public boolean isIo() { + return io; + } - public boolean isMe() { - return me; - } + public void setIo(boolean io) { + this.io = io; + } - public void setMe(boolean me) { - this.me = me; - } + 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 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 new String(this.miny + "-" + this.maxy); + } - 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; - } - - @CsvCustomBindByName(column = "End Asteroids", required = false, converter = XtoBool.class) - public boolean ea; - @CsvCustomBindByName(column = "AstroidBelt", required = false, converter = XtoBool.class) - public boolean as; - @CsvCustomBindByName(column = "Barnard C", required = false, converter = XtoBool.class) - public boolean bc; - @CsvCustomBindByName(column = "Barnard E", required = false, converter = XtoBool.class) - public boolean be; - @CsvCustomBindByName(column = "Barnard F", required = false, converter = XtoBool.class) - public boolean bf; - @CsvCustomBindByName(column = "Mars", required = false, converter = XtoBool.class) - public boolean ma; - @CsvCustomBindByName(column = "Callisto", required = false, converter = XtoBool.class) - public boolean ca; - @CsvCustomBindByName(column = "Centauri Bb", required = false, converter = XtoBool.class) - public boolean cb; - @CsvCustomBindByName(column = "Ceres", required = false, converter = XtoBool.class) - public boolean ce; - @CsvCustomBindByName(column = "Twilight Forest", required = false, converter = XtoBool.class) - public boolean tf; - @CsvCustomBindByName(column = "Deep Dark", required = false, converter = XtoBool.class) - public boolean dd; - @CsvCustomBindByName(column = "Phobos", required = false, converter = XtoBool.class) - public boolean ph; - @CsvCustomBindByName(column = "Deimos", required = false, converter = XtoBool.class) - public boolean de; - @CsvCustomBindByName(column = "Europa", required = false, converter = XtoBool.class) - public boolean eu; - @CsvCustomBindByName(column = "Ganymede", required = false, converter = XtoBool.class) - public boolean ga; - @CsvCustomBindByName(column = "Io", required = false, converter = XtoBool.class) - public boolean io; - @CsvCustomBindByName(column = "Venus", required = false, converter = XtoBool.class) - public boolean ve; - @CsvCustomBindByName(column = "Mercury", required = false, converter = XtoBool.class) - public boolean me; - @CsvCustomBindByName(column = "Enceladus", required = false, converter = XtoBool.class) - public boolean en; - @CsvCustomBindByName(column = "Titan", required = false, converter = XtoBool.class) - public boolean ti; - @CsvCustomBindByName(column = "Miranda", required = false, converter = XtoBool.class) - public boolean mi; - @CsvCustomBindByName(column = "Oberon", required = false, converter = XtoBool.class) - public boolean ob; - @CsvCustomBindByName(column = "Triton", required = false, converter = XtoBool.class) - public boolean tr; - @CsvCustomBindByName(column = "Proteus", required = false, converter = XtoBool.class) - public boolean pr; - @CsvCustomBindByName(column = "Pluto", required = false, converter = XtoBool.class) - public boolean pl; - @CsvCustomBindByName(column = "Kuiper Belt", required = false, converter = XtoBool.class) - public boolean kb; - @CsvCustomBindByName(column = "Haumea", required = false, converter = XtoBool.class) - public boolean ha; - @CsvCustomBindByName(column = "Makemake", required = false, converter = XtoBool.class) - public boolean make; - @CsvCustomBindByName(column = "Vega B", required = false, converter = XtoBool.class) - public boolean vb; - @CsvCustomBindByName(column = "T Ceti E", required = false, converter = XtoBool.class) - public boolean tcetie; - - - - - public Oremix() { - } - - public void setOreName(String s) { - this.oreName = s; - } - public void setPrimary(String s) { - this.primary = s; - } - public void setSecondary(String s) { - this.secondary = s; - } - public void setInbetween(String s) { - this.inbetween = s; - } - public void setAround(String s) { - this.around = s; - } - public void setMix(String s) { - this.mix = s; - } - public void setTier(String s) { - this.tier = s; - } - public void setHeight(String s) { - this.height = s; - } - public void setDensity(int i) { - this.density = i; - } - public void setSize(int i) { - this.size = i; - } - public void setWeight(int i) { - this.weight = i; - } - public void setOverworld(boolean s) { - this.overworld = s; - } - public void setNether(boolean s) { - this.nether = s; - } - public void setEnd(boolean s) { - this.end = s; - } - - public String getOreName() { - return this.oreName; - } - - public String getPrimary() { - return this.primary; - } - public String getSecondary() { - return this.secondary; - } - public String getInbetween() { - return this.inbetween; - } - public String getAround() { - return this.around; - } - public String getMix() { - return this.mix; - } - public String getTier() { - return this.tier; - } - public String getHeight() { - return this.height; - } - public int getDensity() { - return this.density; - } - public int getSize() { - return this.size; - } - public int getWeight() { - return this.weight; - } - public int getMinY() { - calculateminmax(); - return this.miny; - } - public int getMaxY() { - calculateminmax(); - return this.maxy; - } - public boolean getOverworld() { - return this.overworld; - } - public boolean getNether() { - return this.nether; - } - public boolean getEnd() { - return this.end; - } - - private int miny,maxy; - - private void calculateminmax() { - this.miny=Integer.parseInt(this.height.split("-")[0]); - this.maxy=Integer.parseInt(this.height.split("-")[1]); - } - - public void setMinY(int i) { - this.miny=i; - } - public void setMaxY(int i) { - this.maxy=i; - } - - public String getHeightcalced() { - return new String (this.miny+"-"+this.maxy); - } - } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/Veinrenamer.java b/src/main/java/pers/gwyog/gtneioreplugin/util/Veinrenamer.java index 8c0ca7df58..a721d88e82 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/Veinrenamer.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/Veinrenamer.java @@ -6,23 +6,22 @@ import com.opencsv.exceptions.CsvDataTypeMismatchException; public class Veinrenamer<T> extends AbstractBeanField<T> { - @Override - protected Object convert(String value) throws CsvDataTypeMismatchException, CsvConstraintViolationException { - String ret = null; - CharSequence s = "/"; + @Override + protected Object convert(String value) throws CsvDataTypeMismatchException, CsvConstraintViolationException { + String ret = null; + 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; - } + 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 index 7839221630..c27a480557 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/XtoBool.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/XtoBool.java @@ -1,23 +1,22 @@ package pers.gwyog.gtneioreplugin.util; -import java.util.ResourceBundle; - +import com.opencsv.bean.AbstractBeanField; +import com.opencsv.exceptions.CsvConstraintViolationException; +import com.opencsv.exceptions.CsvDataTypeMismatchException; 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.CsvConstraintViolationException; -import com.opencsv.exceptions.CsvDataTypeMismatchException; +import java.util.ResourceBundle; public class XtoBool<T> extends AbstractBeanField<T> { - @Override - protected Object convert(String value) throws CsvDataTypeMismatchException, CsvConstraintViolationException { - if (value.isEmpty()) { + @Override + protected Object convert(String value) throws CsvDataTypeMismatchException, CsvConstraintViolationException { + if (value.isEmpty()) { return null; } - String[] trueStrings = {"x","X"}; + String[] trueStrings = {"x", "X"}; String[] falseStrings = {""}; Converter bc = new BooleanConverter(trueStrings, falseStrings); try { @@ -25,12 +24,12 @@ public class XtoBool<T> extends AbstractBeanField<T> { } catch (ConversionException e) { CsvDataTypeMismatchException csve = new CsvDataTypeMismatchException( value, field.getType(), ResourceBundle - .getBundle("convertGermanToBoolean", errorLocale) - .getString("input.not.boolean")); + .getBundle("convertGermanToBoolean", errorLocale) + .getString("input.not.boolean")); csve.initCause(e); throw csve; } } - + } |