From 96a346cbe022086815d014e3616182df05b9bfd8 Mon Sep 17 00:00:00 2001 From: GWYOG Date: Thu, 10 Nov 2016 12:51:44 +0800 Subject: Add 3 plugins supporting GT6 and refactor some code --- .../pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java | 29 ++-- .../gtneioreplugin/plugin/NEIPluginConfig.java | 48 +++++-- .../gtneioreplugin/plugin/PluginAsteroidStat.java | 142 -------------------- .../gwyog/gtneioreplugin/plugin/PluginBase.java | 22 +-- .../gtneioreplugin/plugin/PluginIEVeinStat.java | 134 ------------------- .../gtneioreplugin/plugin/PluginSmallOreStat.java | 136 ------------------- .../gtneioreplugin/plugin/PluginVeinStat.java | 147 --------------------- .../plugin/gregtech5/PluginGT5AsteroidStat.java | 142 ++++++++++++++++++++ .../plugin/gregtech5/PluginGT5Base.java | 33 +++++ .../plugin/gregtech5/PluginGT5IEVeinStat.java | 133 +++++++++++++++++++ .../plugin/gregtech5/PluginGT5SmallOreStat.java | 135 +++++++++++++++++++ .../plugin/gregtech5/PluginGT5VeinStat.java | 147 +++++++++++++++++++++ .../plugin/gregtech6/PluginGT6BedrockOreStat.java | 114 ++++++++++++++++ .../plugin/gregtech6/PluginGT6SmallOreStat.java | 139 +++++++++++++++++++ .../plugin/gregtech6/PluginGT6VeinStat.java | 138 +++++++++++++++++++ .../gtneioreplugin/util/GT5OreLayerHelper.java | 128 ++++++++++++++++++ .../gtneioreplugin/util/GT5OreSmallHelper.java | 111 ++++++++++++++++ .../gtneioreplugin/util/GT6OreBedrockHelper.java | 56 ++++++++ .../gtneioreplugin/util/GT6OreLayerHelper.java | 76 +++++++++++ .../gtneioreplugin/util/GT6OreSmallHelper.java | 100 ++++++++++++++ .../gtneioreplugin/util/GTOreLayerHelper.java | 126 ------------------ .../gtneioreplugin/util/GTSmallOreHelper.java | 108 --------------- 22 files changed, 1508 insertions(+), 836 deletions(-) delete mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginAsteroidStat.java delete mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginIEVeinStat.java delete mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginSmallOreStat.java delete mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginVeinStat.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5AsteroidStat.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5IEVeinStat.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech6/PluginGT6BedrockOreStat.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech6/PluginGT6SmallOreStat.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech6/PluginGT6VeinStat.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/util/GT6OreBedrockHelper.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/util/GT6OreLayerHelper.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/util/GT6OreSmallHelper.java delete mode 100644 src/main/java/pers/gwyog/gtneioreplugin/util/GTOreLayerHelper.java delete mode 100644 src/main/java/pers/gwyog/gtneioreplugin/util/GTSmallOreHelper.java (limited to 'src/main/java/pers') diff --git a/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java b/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java index d50011b4ec..a023a21d5b 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java @@ -1,17 +1,16 @@ package pers.gwyog.gtneioreplugin; -import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLLoadCompleteEvent; import cpw.mods.fml.common.event.FMLServerStartingEvent; import cpw.mods.fml.relauncher.Side; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.util.GT_OreDictUnificator; -import net.minecraft.item.ItemStack; -import pers.gwyog.gtneioreplugin.util.GTOreLayerHelper; -import pers.gwyog.gtneioreplugin.util.GTSmallOreHelper; +import pers.gwyog.gtneioreplugin.util.GT6OreLayerHelper; +import pers.gwyog.gtneioreplugin.util.GT6OreSmallHelper; +import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper; +import pers.gwyog.gtneioreplugin.util.GT5OreSmallHelper; +import pers.gwyog.gtneioreplugin.util.GT6OreBedrockHelper; @Mod(modid = GTNEIOrePlugin.MODID, name = GTNEIOrePlugin.NAME, version = GTNEIOrePlugin.VERSION, dependencies = "required-after:gregtech;required-after:NotEnoughItems") public class GTNEIOrePlugin { @@ -19,14 +18,28 @@ public class GTNEIOrePlugin { public static final String NAME = "GT NEI Ore Plugin"; public static final String VERSION = "1.0.2"; + // default is GT5, however it will be "GT6" when GT6 is installed + public static String GTVersion = "GT5"; + @Mod.Instance(MODID) public static GTNEIOrePlugin instance; @EventHandler public void onLoadComplete(FMLLoadCompleteEvent event) { if (event.getSide() == Side.CLIENT) { - new GTOreLayerHelper(); - new GTSmallOreHelper(); + try { + Class clazzGT6API = Class.forName("gregapi.GT_API"); + GTVersion = "GT6"; + } catch (ClassNotFoundException e) {} + if (GTVersion.equals("GT5")) { + new GT5OreLayerHelper(); + new GT5OreSmallHelper(); + } + else { + new GT6OreLayerHelper(); + new GT6OreSmallHelper(); + new GT6OreBedrockHelper(); + } } } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java index 738834c8f0..76cd9c4d18 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java @@ -4,7 +4,14 @@ 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.util.GTOreLayerHelper; +import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5AsteroidStat; +import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5IEVeinStat; +import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5SmallOreStat; +import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5VeinStat; +import pers.gwyog.gtneioreplugin.plugin.gregtech6.PluginGT6BedrockOreStat; +import pers.gwyog.gtneioreplugin.plugin.gregtech6.PluginGT6SmallOreStat; +import pers.gwyog.gtneioreplugin.plugin.gregtech6.PluginGT6VeinStat; +import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper; public class NEIPluginConfig implements IConfigureNEI { @@ -20,20 +27,33 @@ public class NEIPluginConfig implements IConfigureNEI { @Override public void loadConfig() { - PluginVeinStat pluginVeinStat = new PluginVeinStat(); - PluginAsteroidStat pluginAsteriodStat = new PluginAsteroidStat(); - PluginSmallOreStat pluginSmallOreStat = new PluginSmallOreStat(); - API.registerRecipeHandler(pluginVeinStat); - API.registerUsageHandler(pluginVeinStat); - API.registerRecipeHandler(pluginAsteriodStat); - API.registerUsageHandler(pluginAsteriodStat); - API.registerRecipeHandler(pluginSmallOreStat); - API.registerUsageHandler(pluginSmallOreStat); - if (GTOreLayerHelper.immersiveEngineeringSupport) { - PluginIEVeinStat pluginIEVeinStat = new PluginIEVeinStat(); - API.registerRecipeHandler(pluginIEVeinStat); - API.registerUsageHandler(pluginIEVeinStat); + if (GTNEIOrePlugin.GTVersion.equals("GT5")) { + 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); + if (GT5OreLayerHelper.immersiveEngineeringSupport) { + PluginGT5IEVeinStat pluginIEVeinStat = new PluginGT5IEVeinStat(); + API.registerRecipeHandler(pluginIEVeinStat); + API.registerUsageHandler(pluginIEVeinStat); + } } + else { + PluginGT6VeinStat pluginGT6VeinStat = new PluginGT6VeinStat(); + PluginGT6SmallOreStat pluginGT6SmallOreStat = new PluginGT6SmallOreStat(); + PluginGT6BedrockOreStat pluginGT6BedrockOreStat = new PluginGT6BedrockOreStat(); + API.registerRecipeHandler(pluginGT6VeinStat); + API.registerUsageHandler(pluginGT6VeinStat); + API.registerRecipeHandler(pluginGT6SmallOreStat); + API.registerUsageHandler(pluginGT6SmallOreStat); + API.registerRecipeHandler(pluginGT6BedrockOreStat); + API.registerUsageHandler(pluginGT6BedrockOreStat); + } } } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginAsteroidStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginAsteroidStat.java deleted file mode 100644 index 9cdc5e7108..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginAsteroidStat.java +++ /dev/null @@ -1,142 +0,0 @@ -package pers.gwyog.gtneioreplugin.plugin; - -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.List; - -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRect; -import gregtech.api.GregTech_API; -import gregtech.api.util.GT_LanguageManager; -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import pers.gwyog.gtneioreplugin.plugin.PluginVeinStat.CachedVeinStatRecipe; -import pers.gwyog.gtneioreplugin.util.GTOreLayerHelper; -import pers.gwyog.gtneioreplugin.util.GTSmallOreHelper; -import pers.gwyog.gtneioreplugin.util.GTOreLayerHelper.OreLayerWrapper; - -public class PluginAsteroidStat extends PluginBase { - - public class CachedAsteroidStatRecipe extends CachedRecipe { - public String veinName; - public PositionedStack positionedStackPrimary; - public PositionedStack positionedStackSecondary; - public PositionedStack positionedStackBetween; - public PositionedStack positionedStackSporadic; - - public CachedAsteroidStatRecipe(String veinName, ItemStack stackListPrimary, ItemStack stackListSecondary, - ItemStack stackListBetween, 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 getIngredients() { - List ingredientsList = new ArrayList(); - ingredientsList.add(positionedStackPrimary); - ingredientsList.add(positionedStackSecondary); - ingredientsList.add(positionedStackBetween); - ingredientsList.add(positionedStackSporadic); - return ingredientsList; - } - - @Override - public PositionedStack getResult() { - return null; - } - - } - - @Override - public void drawExtras(int recipe) { - CachedAsteroidStatRecipe crecipe = (CachedAsteroidStatRecipe) this.arecipes.get(recipe); - OreLayerWrapper oreLayer = GTOreLayerHelper.mapOreLayerWrapper.get(crecipe.veinName); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getLocalizedAsteroidName(oreLayer.veinName), 2, 18, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.asteroidPrimary") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.primaryMeta)), 2, 31, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.asteroidSecondary") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.secondaryMeta)), 2, 44, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.asteroidBetween") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.betweenMeta)), 2, 57, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.asteroidSporadic") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.sporadicMeta)), 2, 70, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": " + getWorldNameTranslated(oreLayer.genEndAsteroid, oreLayer.genGCAsteroid), 2, 83, 0x404040, false); - GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gtnop.gui.nei.seeAll"), getGuiWidth()-3, 5, 0x404040, false); - } - - public String getWorldNameTranslated(boolean genEndAsteroid, boolean genGCAsteroid) { - String worldNameTranslatedAsteroid = ""; - if (genEndAsteroid) { - if (!worldNameTranslatedAsteroid.isEmpty()) - worldNameTranslatedAsteroid += ", "; - worldNameTranslatedAsteroid += I18n.format("gtnop.world.end.name"); - } - if (genGCAsteroid) { - if (!worldNameTranslatedAsteroid.isEmpty()) - worldNameTranslatedAsteroid += ", "; - worldNameTranslatedAsteroid += I18n.format("gtnop.world.asteroid.name"); - } - return worldNameTranslatedAsteroid; - } - - public String getLocalizedAsteroidName(String unlocalizedName) { - if (unlocalizedName.startsWith("ore.mix.custom.")) - return I18n.format("gtnop.ore.custom.name") + I18n.format("gtnop.ore.asteroid.name") + unlocalizedName.substring(15); - else - return I18n.format("gtnop." + unlocalizedName) + I18n.format("gtnop.ore.asteroid.name"); - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equals(getOutputId())) { - OreLayerWrapper oreLayerWrapper; - for (String veinName: GTOreLayerHelper.mapOreLayerWrapper.keySet()) { - oreLayerWrapper = GTOreLayerHelper.mapOreLayerWrapper.get(veinName); - if (oreLayerWrapper.genEndAsteroid || oreLayerWrapper.genGCAsteroid) { - ItemStack stackPrimary = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.primaryMeta+2000); - ItemStack stackSecondary = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.secondaryMeta+2000); - ItemStack stackBetween = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.betweenMeta+2000); - ItemStack stackSporadic = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.sporadicMeta+2000); - this.arecipes.add(new CachedAsteroidStatRecipe(veinName, stackPrimary, stackSecondary, stackBetween, stackSporadic)); - } - } - } - else - super.loadCraftingRecipes(outputId, results); - } - - @Override - public void loadCraftingRecipes(ItemStack stack) { - if (stack.getUnlocalizedName().startsWith("gt.blockores")) { - if (stack.getItemDamage()>16000) { - super.loadCraftingRecipes(stack); - return; - } - short baseMeta = (short)(stack.getItemDamage() % 1000); - for (OreLayerWrapper worldGen: GTOreLayerHelper.mapOreLayerWrapper.values()) { - if (worldGen.primaryMeta == baseMeta || worldGen.secondaryMeta == baseMeta || worldGen.betweenMeta == baseMeta || worldGen.sporadicMeta == baseMeta) { - if (worldGen.genEndAsteroid || worldGen.genGCAsteroid) { - ItemStack stackPrimary = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.primaryMeta+2000); - ItemStack stackSecondary = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.secondaryMeta+2000); - ItemStack stackBetween = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.betweenMeta+2000); - ItemStack stackSporadic = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.sporadicMeta+2000); - this.arecipes.add(new CachedAsteroidStatRecipe(worldGen.veinName, stackPrimary, stackSecondary, stackBetween, stackSporadic)); - } - } - } - } - else - super.loadCraftingRecipes(stack); - } - - @Override - public String getOutputId() { - return "GTOrePluginAsteroid"; - } - - @Override - public String getRecipeName() { - return I18n.format("gtnop.gui.asteroidStat.name"); - } -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java index 33102a8248..a554cf5f46 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java @@ -5,7 +5,6 @@ import java.awt.Rectangle; import codechicken.lib.gui.GuiDraw; import codechicken.nei.recipe.TemplateRecipeHandler; import codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRect; -import gregtech.api.util.GT_LanguageManager; import net.minecraft.client.resources.I18n; import net.minecraft.util.EnumChatFormatting; @@ -35,25 +34,7 @@ public class PluginBase extends TemplateRecipeHandler { public String getOutputId() { return null; } - - 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; - } - - public String getGTOreLocalizedName(short index) { - return GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(index)); - } - - public String getGTOreUnlocalizedName(short index) { - return "gt.blockores." + index + ".name"; - } - + public String getBiomeTranslated(String unlocalizedBiome) { return unlocalizedBiome.equals("None")? I18n.format("gtnop.biome.none.name"): unlocalizedBiome; } @@ -91,5 +72,4 @@ public class PluginBase extends TemplateRecipeHandler { public int getGuiWidth() { return 166; } - } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginIEVeinStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginIEVeinStat.java deleted file mode 100644 index 430490d18a..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginIEVeinStat.java +++ /dev/null @@ -1,134 +0,0 @@ -package pers.gwyog.gtneioreplugin.plugin; - -import java.util.ArrayList; -import java.util.List; - -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler.CachedRecipe; -import gregtech.api.GregTech_API; -import gregtech.api.util.GT_LanguageManager; -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import pers.gwyog.gtneioreplugin.plugin.PluginAsteroidStat.CachedAsteroidStatRecipe; -import pers.gwyog.gtneioreplugin.util.GTOreLayerHelper; -import pers.gwyog.gtneioreplugin.util.GTOreLayerHelper.OreLayerWrapper; - -public class PluginIEVeinStat extends PluginBase { - - public class CachedIEVeinStatRecipe extends CachedRecipe { - public String veinName; - public PositionedStack positionedStackPrimary; - public PositionedStack positionedStackSecondary; - public PositionedStack positionedStackBetween; - public PositionedStack positionedStackSporadic; - - public CachedIEVeinStatRecipe(String veinName, ItemStack stackListPrimary, ItemStack stackListSecondary, - ItemStack stackListBetween, 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 getIngredients() { - List ingredientsList = new ArrayList(); - ingredientsList.add(positionedStackPrimary); - ingredientsList.add(positionedStackSecondary); - ingredientsList.add(positionedStackBetween); - ingredientsList.add(positionedStackSporadic); - return ingredientsList; - } - - @Override - public PositionedStack getResult() { - return null; - } - - } - - @Override - public void drawExtras(int recipe) { - CachedIEVeinStatRecipe crecipe = (CachedIEVeinStatRecipe) this.arecipes.get(recipe); - OreLayerWrapper oreLayer = GTOreLayerHelper.mapOreLayerWrapper.get(crecipe.veinName); - int stringLength1 = GuiDraw.getStringWidth(I18n.format("gtnop.gui.nei.weightedChance") + ": "); - int stringLength2 = GuiDraw.getStringWidth("40%"); - int beginXCoord = (stringLength1-stringLength2)/2; - GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getLocalizedVeinName(oreLayer.veinName), 2, 18, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.ieVeinComponent") + ": ", 2, 31, 0x404040, false); - GuiDraw.drawString("40%", beginXCoord, 44, 0x404040, false); - GuiDraw.drawString(GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.primaryMeta)), 2+stringLength1, 44, 0x404040, false); - GuiDraw.drawString("40%", beginXCoord, 57, 0x404040, false); - GuiDraw.drawString(GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.secondaryMeta)), 2+stringLength1, 57, 0x404040, false); - GuiDraw.drawString("15%", beginXCoord, 70, 0x404040, false); - GuiDraw.drawString(GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.betweenMeta)), 2+stringLength1, 70, 0x404040, false); - GuiDraw.drawString("5% ", beginXCoord, 83, 0x404040, false); - GuiDraw.drawString(GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.sporadicMeta)), 2+stringLength1, 83, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.weightedChance") + ": " + oreLayer.weightedIEChance, 2, 96, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.fromMod") + ": " + "Immersive Engineering", 2, 109, 0x404040, false); - GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gtnop.gui.nei.seeAll"), getGuiWidth()-3, 5, 0x404040, false); - } - - public String getLocalizedVeinName(String unlocalizedName) { - if (unlocalizedName.startsWith("ore.mix.custom.")) - return I18n.format("gtnop.ore.custom.name") + I18n.format("gtnop.ore.vein.name") + unlocalizedName.substring(15); - else - return I18n.format("gtnop." + unlocalizedName) + I18n.format("gtnop.ore.vein.name"); - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equals(getOutputId())) { - OreLayerWrapper oreLayerWrapper; - for (String veinName: GTOreLayerHelper.mapOreLayerWrapper.keySet()) { - oreLayerWrapper = GTOreLayerHelper.mapOreLayerWrapper.get(veinName); - if (oreLayerWrapper.genIEVein) { - ItemStack stackPrimary = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.primaryMeta); - ItemStack stackSecondary = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.secondaryMeta); - ItemStack stackBetween = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.betweenMeta); - ItemStack stackSporadic = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.sporadicMeta); - this.arecipes.add(new CachedIEVeinStatRecipe(veinName, stackPrimary, stackSecondary, stackBetween, stackSporadic)); - } - } - } - else - super.loadCraftingRecipes(outputId, results); - } - - @Override - public void loadCraftingRecipes(ItemStack stack) { - if (stack.getUnlocalizedName().startsWith("gt.blockores")) { - if (stack.getItemDamage()>16000) { - super.loadCraftingRecipes(stack); - return; - } - short baseMeta = (short)(stack.getItemDamage() % 1000); - for (OreLayerWrapper worldGen: GTOreLayerHelper.mapOreLayerWrapper.values()) { - if (worldGen.primaryMeta == baseMeta || worldGen.secondaryMeta == baseMeta || worldGen.betweenMeta == baseMeta || worldGen.sporadicMeta == baseMeta) { - if (worldGen.genIEVein) { - ItemStack stackPrimary = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.primaryMeta); - ItemStack stackSecondary = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.secondaryMeta); - ItemStack stackBetween = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.betweenMeta); - ItemStack stackSporadic = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.sporadicMeta); - this.arecipes.add(new CachedIEVeinStatRecipe(worldGen.veinName, stackPrimary, stackSecondary, stackBetween, stackSporadic)); - } - } - } - } - else - super.loadCraftingRecipes(stack); - } - - @Override - public String getOutputId() { - return "GTOrePluginIEVeinCompat"; - } - - @Override - public String getRecipeName() { - return I18n.format("gtnop.gui.ieVeinStat.name"); - } -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginSmallOreStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginSmallOreStat.java deleted file mode 100644 index 1aba8c8992..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginSmallOreStat.java +++ /dev/null @@ -1,136 +0,0 @@ -package pers.gwyog.gtneioreplugin.plugin; - -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.PluginAsteroidStat.CachedAsteroidStatRecipe; -import pers.gwyog.gtneioreplugin.plugin.PluginVeinStat.CachedVeinStatRecipe; -import pers.gwyog.gtneioreplugin.util.GTOreLayerHelper; -import pers.gwyog.gtneioreplugin.util.GTSmallOreHelper; -import pers.gwyog.gtneioreplugin.util.GTOreLayerHelper.OreLayerWrapper; -import pers.gwyog.gtneioreplugin.util.GTSmallOreHelper.SmallOreWrapper; - -public class PluginSmallOreStat extends PluginBase { - - public class CachedSmallOreRecipe extends CachedRecipe { - public String oreGenName; - public PositionedStack positionedStackSmallOre; - public PositionedStack positionedStackMaterialDust; - public List positionedDropStackList; - - public CachedSmallOreRecipe(String oreGenName, List stackList, List materialDustStackList, List dropStackList) { - this.oreGenName = oreGenName; - this.positionedStackSmallOre = 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() { - positionedStackSmallOre.setPermutationToRender((cycleticks / 20) % positionedStackSmallOre.items.length); - positionedStackMaterialDust.setPermutationToRender((cycleticks / 20) % positionedStackMaterialDust.items.length); - positionedDropStackList.add(positionedStackSmallOre); - positionedDropStackList.add(positionedStackMaterialDust); - return positionedDropStackList; - - } - - @Override - public PositionedStack getResult() { - return null; - } - - } - - @Override - public void drawExtras(int recipe) { - CachedSmallOreRecipe crecipe = (CachedSmallOreRecipe) this.arecipes.get(recipe); - SmallOreWrapper smallOre = GTSmallOreHelper.mapSmallOreWrapper.get(crecipe.oreGenName); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.oreName") + ": " + getGTOreLocalizedName((short)(smallOre.oreMeta+16000)), 2, 18, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.genHeight") + ": " + smallOre.worldGenHeightRange, 2, 31, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.amount") + ": " + smallOre.amountPerChunk, 2, 44, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": " + getWorldNameTranslated(smallOre.genOverworld, smallOre.genNether, smallOre.genEnd, smallOre.genMoon, smallOre.genMars), 2, 57, 0x404040, false); - if (GTSmallOreHelper.restrictBiomeSupport) GuiDraw.drawString(I18n.format("gtnop.gui.nei.restrictBiome") + ": " + getBiomeTranslated(smallOre.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); - } - - public int getRestrictBiomeOffset() { - return GTSmallOreHelper.restrictBiomeSupport? 0: -13; - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equals(getOutputId())) - for (ItemStack stack: GTSmallOreHelper.smallOreList) - loadCraftingRecipes(stack); - else - super.loadCraftingRecipes(outputId, results); - } - - @Override - public void loadCraftingRecipes(ItemStack stack) { - if (stack.getUnlocalizedName().startsWith("gt.blockores")) { - if (stack.getItemDamage()<16000) { - super.loadCraftingRecipes(stack); - return; - } - short baseMeta = (short)(stack.getItemDamage() % 1000); - for (SmallOreWrapper smallOreWorldGen: GTSmallOreHelper.mapSmallOreWrapper.values()) { - if (smallOreWorldGen.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)); - List materialDustStackList = new ArrayList(); - for (int i=0;i<7;i++) - materialDustStackList.add(GT_OreDictUnificator.get(OrePrefixes.dust, GTSmallOreHelper.getDroppedDusts()[i], 1L)); - this.arecipes.add(new CachedSmallOreRecipe(GTSmallOreHelper.mapSmallOreWrapper.get(oreGenName).oreGenName, stackList, materialDustStackList, GTSmallOreHelper.mapOreMetaToOreDrops.get(baseMeta))); - } - } - } - else - super.loadCraftingRecipes(stack); - } - - @Override - public String getOutputId() { - return "GTOrePluginSmallOre"; - } - - @Override - public String getRecipeName() { - return I18n.format("gtnop.gui.smallOreStat.name"); - } -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginVeinStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginVeinStat.java deleted file mode 100644 index e2b43cf482..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginVeinStat.java +++ /dev/null @@ -1,147 +0,0 @@ -package pers.gwyog.gtneioreplugin.plugin; - -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.List; - -import org.apache.http.impl.conn.tsccm.ConnPoolByRoute; - -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler; -import codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRect; -import gregtech.api.GregTech_API; -import gregtech.api.util.GT_LanguageManager; -import gregtech.common.GT_Worldgen_GT_Ore_Layer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.resources.I18n; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import pers.gwyog.gtneioreplugin.util.GTOreLayerHelper; -import pers.gwyog.gtneioreplugin.util.GTOreLayerHelper.OreLayerWrapper; - -public class PluginVeinStat extends PluginBase { - - 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((3 + cycleticks / 20) % positionedStackPrimary.items.length);; - positionedStackBetween.setPermutationToRender((2 + cycleticks / 20) % positionedStackPrimary.items.length);; - positionedStackSporadic.setPermutationToRender((1 + 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; - } - - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equals(getOutputId())) { - OreLayerWrapper oreLayerWrapper; - for (String veinName: GTOreLayerHelper.mapOreLayerWrapper.keySet()) { - oreLayerWrapper = GTOreLayerHelper.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.primaryMeta+i*1000)); - stackListSecondary.add(new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.secondaryMeta+i*1000)); - stackListBetween.add(new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.betweenMeta+i*1000)); - stackListSporadic.add(new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.sporadicMeta+i*1000)); - } - this.arecipes.add(new CachedVeinStatRecipe(veinName, stackListPrimary, stackListSecondary, stackListBetween, stackListSporadic)); - } - } - else - super.loadCraftingRecipes(outputId, results); - } - - @Override - public void loadCraftingRecipes(ItemStack stack) { - if (stack.getUnlocalizedName().startsWith("gt.blockores")) { - if (stack.getItemDamage()>16000) { - super.loadCraftingRecipes(stack); - return; - } - short baseMeta = (short)(stack.getItemDamage() % 1000); - for (OreLayerWrapper worldGen: GTOreLayerHelper.mapOreLayerWrapper.values()) { - if (worldGen.primaryMeta == baseMeta || worldGen.secondaryMeta == baseMeta || worldGen.betweenMeta == baseMeta || worldGen.sporadicMeta == baseMeta) { - List stackListPrimary = new ArrayList(); - List stackListSecondary = new ArrayList(); - List stackListBetween = new ArrayList(); - List stackListSporadic = new ArrayList(); - for (int i=0;i getIngredients() { + List ingredientsList = new ArrayList(); + ingredientsList.add(positionedStackPrimary); + ingredientsList.add(positionedStackSecondary); + ingredientsList.add(positionedStackBetween); + ingredientsList.add(positionedStackSporadic); + return ingredientsList; + } + + @Override + public PositionedStack getResult() { + return null; + } + + } + + @Override + public void drawExtras(int recipe) { + CachedAsteroidStatRecipe crecipe = (CachedAsteroidStatRecipe) this.arecipes.get(recipe); + OreLayerWrapper oreLayer = GT5OreLayerHelper.mapOreLayerWrapper.get(crecipe.veinName); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getLocalizedAsteroidName(oreLayer.veinName), 2, 18, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.asteroidPrimary") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.primaryMeta)), 2, 31, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.asteroidSecondary") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.secondaryMeta)), 2, 44, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.asteroidBetween") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.betweenMeta)), 2, 57, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.asteroidSporadic") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.sporadicMeta)), 2, 70, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": " + getWorldNameTranslated(oreLayer.genEndAsteroid, oreLayer.genGCAsteroid), 2, 83, 0x404040, false); + GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gtnop.gui.nei.seeAll"), getGuiWidth()-3, 5, 0x404040, false); + } + + public String getWorldNameTranslated(boolean genEndAsteroid, boolean genGCAsteroid) { + String worldNameTranslatedAsteroid = ""; + if (genEndAsteroid) { + if (!worldNameTranslatedAsteroid.isEmpty()) + worldNameTranslatedAsteroid += ", "; + worldNameTranslatedAsteroid += I18n.format("gtnop.world.end.name"); + } + if (genGCAsteroid) { + if (!worldNameTranslatedAsteroid.isEmpty()) + worldNameTranslatedAsteroid += ", "; + worldNameTranslatedAsteroid += I18n.format("gtnop.world.asteroid.name"); + } + return worldNameTranslatedAsteroid; + } + + public String getLocalizedAsteroidName(String unlocalizedName) { + if (unlocalizedName.startsWith("ore.mix.custom.")) + return I18n.format("gtnop.ore.custom.name") + I18n.format("gtnop.ore.asteroid.name") + unlocalizedName.substring(15); + else + return I18n.format("gtnop." + unlocalizedName) + I18n.format("gtnop.ore.asteroid.name"); + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getOutputId())) { + OreLayerWrapper oreLayerWrapper; + for (String veinName: GT5OreLayerHelper.mapOreLayerWrapper.keySet()) { + oreLayerWrapper = GT5OreLayerHelper.mapOreLayerWrapper.get(veinName); + if (oreLayerWrapper.genEndAsteroid || oreLayerWrapper.genGCAsteroid) { + ItemStack stackPrimary = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.primaryMeta+2000); + ItemStack stackSecondary = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.secondaryMeta+2000); + ItemStack stackBetween = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.betweenMeta+2000); + ItemStack stackSporadic = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.sporadicMeta+2000); + this.arecipes.add(new CachedAsteroidStatRecipe(veinName, stackPrimary, stackSecondary, stackBetween, stackSporadic)); + } + } + } + else + super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack stack) { + if (stack.getUnlocalizedName().startsWith("gt.blockores")) { + if (stack.getItemDamage()>16000) { + super.loadCraftingRecipes(stack); + return; + } + short baseMeta = (short)(stack.getItemDamage() % 1000); + for (OreLayerWrapper worldGen: GT5OreLayerHelper.mapOreLayerWrapper.values()) { + if (worldGen.primaryMeta == baseMeta || worldGen.secondaryMeta == baseMeta || worldGen.betweenMeta == baseMeta || worldGen.sporadicMeta == baseMeta) { + if (worldGen.genEndAsteroid || worldGen.genGCAsteroid) { + ItemStack stackPrimary = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.primaryMeta+2000); + ItemStack stackSecondary = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.secondaryMeta+2000); + ItemStack stackBetween = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.betweenMeta+2000); + ItemStack stackSporadic = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.sporadicMeta+2000); + this.arecipes.add(new CachedAsteroidStatRecipe(worldGen.veinName, stackPrimary, stackSecondary, stackBetween, stackSporadic)); + } + } + } + } + else + super.loadCraftingRecipes(stack); + } + + @Override + public String getOutputId() { + return "GTOrePluginAsteroid"; + } + + @Override + public String getRecipeName() { + return I18n.format("gtnop.gui.asteroidStat.name"); + } +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java new file mode 100644 index 0000000000..a61a8bb977 --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java @@ -0,0 +1,33 @@ +package pers.gwyog.gtneioreplugin.plugin.gregtech5; + +import java.awt.Rectangle; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.recipe.TemplateRecipeHandler; +import codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRect; +import gregtech.api.util.GT_LanguageManager; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.EnumChatFormatting; +import pers.gwyog.gtneioreplugin.plugin.PluginBase; + +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; + } + + public String getGTOreLocalizedName(short index) { + return GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(index)); + } + + public String getGTOreUnlocalizedName(short index) { + return "gt.blockores." + index + ".name"; + } + +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5IEVeinStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5IEVeinStat.java new file mode 100644 index 0000000000..547c966081 --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5IEVeinStat.java @@ -0,0 +1,133 @@ +package pers.gwyog.gtneioreplugin.plugin.gregtech5; + +import java.util.ArrayList; +import java.util.List; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler.CachedRecipe; +import gregtech.api.GregTech_API; +import gregtech.api.util.GT_LanguageManager; +import net.minecraft.client.resources.I18n; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper; +import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper.OreLayerWrapper; + +public class PluginGT5IEVeinStat extends PluginGT5Base { + + public class CachedIEVeinStatRecipe extends CachedRecipe { + public String veinName; + public PositionedStack positionedStackPrimary; + public PositionedStack positionedStackSecondary; + public PositionedStack positionedStackBetween; + public PositionedStack positionedStackSporadic; + + public CachedIEVeinStatRecipe(String veinName, ItemStack stackListPrimary, ItemStack stackListSecondary, + ItemStack stackListBetween, 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 getIngredients() { + List ingredientsList = new ArrayList(); + ingredientsList.add(positionedStackPrimary); + ingredientsList.add(positionedStackSecondary); + ingredientsList.add(positionedStackBetween); + ingredientsList.add(positionedStackSporadic); + return ingredientsList; + } + + @Override + public PositionedStack getResult() { + return null; + } + + } + + @Override + public void drawExtras(int recipe) { + CachedIEVeinStatRecipe crecipe = (CachedIEVeinStatRecipe) this.arecipes.get(recipe); + OreLayerWrapper oreLayer = GT5OreLayerHelper.mapOreLayerWrapper.get(crecipe.veinName); + int stringLength1 = GuiDraw.getStringWidth(I18n.format("gtnop.gui.nei.weightedChance") + ": "); + int stringLength2 = GuiDraw.getStringWidth("40%"); + int beginXCoord = (stringLength1-stringLength2)/2; + GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getLocalizedVeinName(oreLayer.veinName), 2, 18, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.ieVeinComponent") + ": ", 2, 31, 0x404040, false); + GuiDraw.drawString("40%", beginXCoord, 44, 0x404040, false); + GuiDraw.drawString(GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.primaryMeta)), 2+stringLength1, 44, 0x404040, false); + GuiDraw.drawString("40%", beginXCoord, 57, 0x404040, false); + GuiDraw.drawString(GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.secondaryMeta)), 2+stringLength1, 57, 0x404040, false); + GuiDraw.drawString("15%", beginXCoord, 70, 0x404040, false); + GuiDraw.drawString(GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.betweenMeta)), 2+stringLength1, 70, 0x404040, false); + GuiDraw.drawString("5% ", beginXCoord, 83, 0x404040, false); + GuiDraw.drawString(GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.sporadicMeta)), 2+stringLength1, 83, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.weightedChance") + ": " + oreLayer.weightedIEChance, 2, 96, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.fromMod") + ": " + "Immersive Engineering", 2, 109, 0x404040, false); + GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gtnop.gui.nei.seeAll"), getGuiWidth()-3, 5, 0x404040, false); + } + + public String getLocalizedVeinName(String unlocalizedName) { + if (unlocalizedName.startsWith("ore.mix.custom.")) + return I18n.format("gtnop.ore.custom.name") + I18n.format("gtnop.ore.vein.name") + unlocalizedName.substring(15); + else + return I18n.format("gtnop." + unlocalizedName) + I18n.format("gtnop.ore.vein.name"); + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getOutputId())) { + OreLayerWrapper oreLayerWrapper; + for (String veinName: GT5OreLayerHelper.mapOreLayerWrapper.keySet()) { + oreLayerWrapper = GT5OreLayerHelper.mapOreLayerWrapper.get(veinName); + if (oreLayerWrapper.genIEVein) { + ItemStack stackPrimary = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.primaryMeta); + ItemStack stackSecondary = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.secondaryMeta); + ItemStack stackBetween = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.betweenMeta); + ItemStack stackSporadic = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.sporadicMeta); + this.arecipes.add(new CachedIEVeinStatRecipe(veinName, stackPrimary, stackSecondary, stackBetween, stackSporadic)); + } + } + } + else + super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack stack) { + if (stack.getUnlocalizedName().startsWith("gt.blockores")) { + if (stack.getItemDamage()>16000) { + super.loadCraftingRecipes(stack); + return; + } + short baseMeta = (short)(stack.getItemDamage() % 1000); + for (OreLayerWrapper worldGen: GT5OreLayerHelper.mapOreLayerWrapper.values()) { + if (worldGen.primaryMeta == baseMeta || worldGen.secondaryMeta == baseMeta || worldGen.betweenMeta == baseMeta || worldGen.sporadicMeta == baseMeta) { + if (worldGen.genIEVein) { + ItemStack stackPrimary = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.primaryMeta); + ItemStack stackSecondary = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.secondaryMeta); + ItemStack stackBetween = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.betweenMeta); + ItemStack stackSporadic = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.sporadicMeta); + this.arecipes.add(new CachedIEVeinStatRecipe(worldGen.veinName, stackPrimary, stackSecondary, stackBetween, stackSporadic)); + } + } + } + } + else + super.loadCraftingRecipes(stack); + } + + @Override + public String getOutputId() { + return "GTOrePluginIEVeinCompat"; + } + + @Override + public String getRecipeName() { + return I18n.format("gtnop.gui.ieVeinStat.name"); + } +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java new file mode 100644 index 0000000000..f1ddce6629 --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java @@ -0,0 +1,135 @@ +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; + + 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; + } + + } + + @Override + public void drawExtras(int recipe) { + CachedOreSmallRecipe crecipe = (CachedOreSmallRecipe) this.arecipes.get(recipe); + OreSmallWrapper oreSmall = GT5OreSmallHelper.mapOr