From a0bfd778cc565865f31653e4c82b9c219a3fe69c Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Wed, 27 Mar 2019 08:23:29 +0100 Subject: 1.0.7 + updated Java 7 -> 8 + Buffered Input from cfg + refractor, code improvements + small ores completely working + added tooltip + added logger + added ic2 to gradle + updated gradle deps + restored base gt compability + small ore csv (untested) Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> --- .../java/pers/gwyog/gtneioreplugin/Config.java | 25 +- .../pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java | 42 +- .../gtneioreplugin/plugin/NEIPluginConfig.java | 25 +- .../gwyog/gtneioreplugin/plugin/PluginBase.java | 19 +- .../plugin/gregtech5/PluginGT5Base.java | 91 +- .../plugin/gregtech5/PluginGT5SmallOreStat.java | 149 ++-- .../plugin/gregtech5/PluginGT5VeinStat.java | 394 +++++---- .../pers/gwyog/gtneioreplugin/util/CSVMaker.java | 272 +++--- .../gwyog/gtneioreplugin/util/DimensionHelper.java | 189 +++-- .../gwyog/gtneioreplugin/util/GT5CFGHelper.java | 291 ++++--- .../gtneioreplugin/util/GT5OreLayerHelper.java | 60 +- .../gtneioreplugin/util/GT5OreSmallHelper.java | 104 ++- .../pers/gwyog/gtneioreplugin/util/Oremix.java | 914 +++++++++++---------- .../gwyog/gtneioreplugin/util/Veinrenamer.java | 33 +- .../pers/gwyog/gtneioreplugin/util/XtoBool.java | 23 +- 15 files changed, 1436 insertions(+), 1195 deletions(-) (limited to 'src/main/java') 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 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 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 positionedDropStackList; +import java.util.ArrayList; +import java.util.List; - public CachedOreSmallRecipe(String oreGenName, List stackList, List materialDustStackList, List dropStackList) { - this.oreGenName = oreGenName; - this.positionedStackOreSmall = new PositionedStack(stackList, 2, 0); - this.positionedStackMaterialDust = new PositionedStack(materialDustStackList, 43, 79+getRestrictBiomeOffset()); - List positionedDropStackList = new ArrayList(); - 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 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 stackList = new ArrayList(); int maximumIndex = getMaximumMaterialIndex(baseMeta, true); - for (int i=0;i materialDustStackList = new ArrayList(); - for (int i=0;i stackList = new ArrayList(); - 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 materialDustStackList = new ArrayList(); - 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 positionedDropStackList; + + public CachedOreSmallRecipe(String oreGenName, List stackList, List materialDustStackList, List dropStackList) { + this.oreGenName = oreGenName; + this.positionedStackOreSmall = new PositionedStack(stackList, 2, 0); + this.positionedStackMaterialDust = new PositionedStack(materialDustStackList, 43, 79 + getRestrictBiomeOffset()); + List positionedDropStackList = new ArrayList(); + 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 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 stackListPrimary, List stackListSecondary, - List stackListBetween, List 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 s = new HashSet(); + 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 getIngredients() { - List ingredientsList = new ArrayList(); - 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 h = new HashSet(); + 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 stackListPrimary = new ArrayList(); List stackListSecondary = new ArrayList(); List stackListBetween = new ArrayList(); List stackListSporadic = new ArrayList(); - 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 stackListPrimary = new ArrayList(); List stackListSecondary = new ArrayList(); List stackListBetween = new ArrayList(); List stackListSporadic = new ArrayList(); - for (int i=0;i1) { 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 s = new HashSet(); - 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 h = new HashSet(); - 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 stackListPrimary, List stackListSecondary, + List stackListBetween, List 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 getIngredients() { + List ingredientsList = new ArrayList(); + 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 Combsort(List liste) { + try { + List liste2 = new ArrayList(liste.size()); + for (Oremix element : liste) { + liste2.add(element); + } - public CSVMaker() { - - } - - public static List Combsort(List liste) { - try { - List liste2 = new ArrayList(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 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 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 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 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"); +