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/gwyog') 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.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); + } + + public int getRestrictBiomeOffset() { + return GT5OreSmallHelper.restrictBiomeSupport? 0: -13; + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getOutputId())) + 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) { + super.loadCraftingRecipes(stack); + return; + } + 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)); + List materialDustStackList = new ArrayList(); + 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 + super.loadCraftingRecipes(stack); + } + + @Override + public String getOutputId() { + return "GTOrePluginOreSmall"; + } + + @Override + public String getRecipeName() { + return I18n.format("gtnop.gui.smallOreStat.name"); + } +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java new file mode 100644 index 0000000000..d9085ab82a --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java @@ -0,0 +1,147 @@ +package pers.gwyog.gtneioreplugin.plugin.gregtech5; + +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.GT5OreLayerHelper; +import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper.OreLayerWrapper; + +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); + } + + @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: 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.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: GT5OreLayerHelper.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 stackListOre, List stackListOreSmall) { + this.oreName = oreName; + positionedStackOreBedrock = new PositionedStack(stackOreBedrock, 2, 0); + positionedStackOreSmallBedrock = new PositionedStack(stackOreSmallBedrock, 22, 0); + positionedStackOre = new PositionedStack(stackListOre, 42, 0); + positionedStackOreSmall = new PositionedStack(stackListOreSmall, 62, 0); + } + + @Override + public List getIngredients() { + List ingredientsList = new ArrayList(); + positionedStackOre.setPermutationToRender((cycleticks / 20) % positionedStackOre.items.length);; + positionedStackOreSmall.setPermutationToRender((cycleticks / 20) % positionedStackOreSmall.items.length);; + ingredientsList.add(positionedStackOreBedrock); + ingredientsList.add(positionedStackOreSmallBedrock); + ingredientsList.add(positionedStackOre); + ingredientsList.add(positionedStackOreSmall); + return ingredientsList; + } + + @Override + public PositionedStack getResult() { + return null; + } + + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getOutputId())) + for (OreBedrockWrapper worldGen: GT6OreBedrockHelper.mapOreBedrockWrapper.values()) + loadCraftingRecipes(new ItemStack(CS.BlocksGT.oreBedrock, 1, worldGen.meta)); + else + super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack stack) { + String unlocalizedName = stack.getUnlocalizedName(); + if (unlocalizedName.startsWith("oredict.oreBedrock") || unlocalizedName.startsWith("oredict.ore") || unlocalizedName.startsWith("oredict.oreSmall")) { + short meta = (short)stack.getItemDamage(); + for (OreBedrockWrapper worldGen: GT6OreBedrockHelper.mapOreBedrockWrapper.values()) { + if (meta==worldGen.meta) { + ItemStack stackOreBedrock = new ItemStack(CS.BlocksGT.oreBedrock, 1, meta); + ItemStack stackOreSmallBedrock = new ItemStack(CS.BlocksGT.oreSmallBedrock, 1, meta); + List stackListOre = new ArrayList(); + List stackListOreSmall = new ArrayList(); + for (PrefixBlock prefixBlock: GT6OreLayerHelper.setOreNormalBasicTypes) + stackListOre.add(new ItemStack(prefixBlock, 1, meta)); + for (PrefixBlock prefixBlock: GT6OreSmallHelper.setOreSmallBasicTypes) + stackListOreSmall.add(new ItemStack(prefixBlock, 1, meta)); + this.arecipes.add(new CachedBedrockOreStatRecipe(worldGen.veinName, stackOreBedrock, stackOreSmallBedrock, stackListOre, stackListOreSmall)); + } + } + } + else + super.loadCraftingRecipes(stack); + } + + @Override + public void drawExtras(int recipe) { + CachedBedrockOreStatRecipe crecipe = (CachedBedrockOreStatRecipe) this.arecipes.get(recipe); + OreBedrockWrapper oreLayer = GT6OreBedrockHelper.mapOreBedrockWrapper.get(crecipe.oreName); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.oreName") + ": " + GT6OreBedrockHelper.mapMetaToLocalizedName.get(oreLayer.meta), 2, 18, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.oreOthers") + ": " + GT6OreSmallHelper.mapMetaToLocalizedName.get(oreLayer.meta), 2, 31, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.oreOthers") + ": " + GT6OreLayerHelper.mapMetaToLocalizedName.get(oreLayer.meta), 2, 44, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.oreOthers") + ": " + GT6OreSmallHelper.mapMetaToLocalizedName.get(oreLayer.meta), 2, 57, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.genHeight") + ": " + "0-6", 2, 70, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.nei.genPosition") + ": " + I18n.format("gtnop.nei.genPositionInfo"), 2,83, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.weightedChance") + ": " + "1/" + oreLayer.probability, 2, 96, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": " + getWorldNameTranslated(oreLayer.genOverworld, oreLayer.genNether, oreLayer.genEnd, false, false), 2, 109, 0x404040, false); + GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gtnop.gui.nei.seeAll"), getGuiWidth()-3, 5, 0x404040, false); + } + + @Override + public String getOutputId() { + return "GTOrePluginOreBedrock"; + } + + @Override + public String getRecipeName() { + return I18n.format("gtnop.gui.bedrockOreStat.name"); + } + +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech6/PluginGT6SmallOreStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech6/PluginGT6SmallOreStat.java new file mode 100644 index 0000000000..02f43a02f9 --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech6/PluginGT6SmallOreStat.java @@ -0,0 +1,139 @@ +package pers.gwyog.gtneioreplugin.plugin.gregtech6; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler.CachedRecipe; +import gregapi.block.IBlockPlacable; +import gregapi.block.behaviors.Drops_SmallOre; +import gregapi.block.prefixblock.PrefixBlock; +import gregapi.data.CS; +import gregapi.data.OP; +import gregapi.oredict.OreDictMaterial; +import net.minecraft.client.resources.I18n; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import pers.gwyog.gtneioreplugin.plugin.PluginBase; +import pers.gwyog.gtneioreplugin.util.GT6OreSmallHelper; +import pers.gwyog.gtneioreplugin.util.GT6OreSmallHelper.OreSmallWrapper; + +public class PluginGT6SmallOreStat extends PluginBase { + + 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, 67); + List positionedDropStackList = new ArrayList(); + int i = 1; + for (ItemStack stackDrop: dropStackList) + positionedDropStackList.add(new PositionedStack(stackDrop, 43+20*(i%5), 67+17*((i++)/5))); + 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 = GT6OreSmallHelper.mapOreSmallWrapper.get(crecipe.oreGenName); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.oreName") + ": " + GT6OreSmallHelper.mapMetaToLocalizedName.get(oreSmall.oreMeta), 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, false, false), 2, 57, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.chanceDrops") + ": ", 2, 70, 0x404040, false); + GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gtnop.gui.nei.seeAll"), getGuiWidth()-3, 5, 0x404040, false); + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getOutputId())) + for (ItemStack stack: GT6OreSmallHelper.oreSmallList) + loadCraftingRecipes(stack); + else + super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack stack) { + if (stack.getUnlocalizedName().startsWith("oredict.oreSmall") && !stack.isItemEqual(new ItemStack(CS.BlocksGT.oreSmallBedrock, 1, stack.getItemDamage()))) { + short meta = (short)stack.getItemDamage(); + for (OreSmallWrapper oreSmallWorldGen: GT6OreSmallHelper.mapOreSmallWrapper.values()) { + if (oreSmallWorldGen.oreMeta == meta) { + List stackList = new ArrayList(); + List materialDustStackList = new ArrayList(); + for (PrefixBlock prefixBlock: GT6OreSmallHelper.setOreSmallBasicTypes) { + stackList.add(new ItemStack(prefixBlock, 1, meta)); + Drops_SmallOre drops_SmallOre = ((Drops_SmallOre)prefixBlock.mDrops); + Class clazzDropsOreSmall = drops_SmallOre.getClass(); + try { + Field fieldSecondaryDrop = clazzDropsOreSmall.getDeclaredField("mSecondaryDrop"); + fieldSecondaryDrop.setAccessible(true); + OreDictMaterial oreDictMaterial = (OreDictMaterial)fieldSecondaryDrop.get(drops_SmallOre); + materialDustStackList.add(OP.dust.mat(oreDictMaterial.mTargetCrushing.mMaterial, 1L)); + } catch (Exception e) {} + } + this.arecipes.add(new CachedOreSmallRecipe(oreSmallWorldGen.oreGenName, stackList, materialDustStackList, GT6OreSmallHelper.mapOreMetaToOreDrops.get(meta))); + } + } + } + else if (GT6OreSmallHelper.mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) { + short meta = GT6OreSmallHelper.mapOreDropUnlocalizedNameToOreMeta.get(stack.getUnlocalizedName()); + for (String oreGenName: GT6OreSmallHelper.mapOreSmallWrapper.keySet()) { + OreSmallWrapper oreSmallWrapper = GT6OreSmallHelper.mapOreSmallWrapper.get(oreGenName); + if (oreSmallWrapper.oreMeta == meta) { + List stackList = new ArrayList(); + List materialDustStackList = new ArrayList(); + for (PrefixBlock prefixBlock: GT6OreSmallHelper.setOreSmallBasicTypes) { + stackList.add(new ItemStack(prefixBlock, 1, meta)); + Drops_SmallOre drops_OreSmall = ((Drops_SmallOre)prefixBlock.mDrops); + Class clazzDropsOreSmall = drops_OreSmall.getClass(); + try { + Field fieldSecondaryDrop = clazzDropsOreSmall.getDeclaredField("mSecondaryDrop"); + fieldSecondaryDrop.setAccessible(true); + OreDictMaterial oreDictMaterial = (OreDictMaterial)fieldSecondaryDrop.get(drops_OreSmall); + materialDustStackList.add(OP.dust.mat(oreDictMaterial.mTargetCrushing.mMaterial, 1L)); + } catch (Exception e) {} + } + this.arecipes.add(new CachedOreSmallRecipe(GT6OreSmallHelper.mapOreSmallWrapper.get(oreGenName).oreGenName, stackList, materialDustStackList, GT6OreSmallHelper.mapOreMetaToOreDrops.get(meta))); + } + } + } + else + super.loadCraftingRecipes(stack); + } + + @Override + public String getOutputId() { + return "GTOrePluginOreSmall"; + } + + @Override + public String getRecipeName() { + return I18n.format("gtnop.gui.smallOreStat.name"); + } + +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech6/PluginGT6VeinStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech6/PluginGT6VeinStat.java new file mode 100644 index 0000000000..83ebb1211e --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech6/PluginGT6VeinStat.java @@ -0,0 +1,138 @@ +package pers.gwyog.gtneioreplugin.plugin.gregtech6; + +import java.util.ArrayList; +import java.util.List; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler.CachedRecipe; +import gregapi.block.IBlockPlacable; +import gregapi.block.prefixblock.PrefixBlock; +import gregapi.data.CS; +import net.minecraft.client.resources.I18n; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import pers.gwyog.gtneioreplugin.plugin.PluginBase; +import pers.gwyog.gtneioreplugin.util.GT6OreLayerHelper; +import pers.gwyog.gtneioreplugin.util.GT6OreLayerHelper.OreLayerWrapper; + +public class PluginGT6VeinStat 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((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; + } + + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getOutputId())) { + OreLayerWrapper oreLayerWrapper; + for (String veinName: GT6OreLayerHelper.mapOreLayerWrapper.keySet()) { + oreLayerWrapper = GT6OreLayerHelper.mapOreLayerWrapper.get(veinName); + List stackListPrimary = new ArrayList(); + List stackListSecondary = new ArrayList(); + List stackListBetween = new ArrayList(); + List stackListSporadic = new ArrayList(); + for (PrefixBlock prefixBlock: GT6OreLayerHelper.setOreNormalBasicTypes) { + stackListPrimary.add(new ItemStack(prefixBlock, 1, oreLayerWrapper.primaryMeta)); + stackListSecondary.add(new ItemStack(prefixBlock, 1, oreLayerWrapper.secondaryMeta)); + stackListBetween.add(new ItemStack(prefixBlock, 1, oreLayerWrapper.betweenMeta)); + stackListSporadic.add(new ItemStack(prefixBlock, 1, oreLayerWrapper.sporadicMeta)); + } + this.arecipes.add(new CachedVeinStatRecipe(veinName, stackListPrimary, stackListSecondary, stackListBetween, stackListSporadic)); + } + } + else + super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack stack) { + String unlocalizedName = stack.getUnlocalizedName(); + if (unlocalizedName.startsWith("oredict.ore") && !unlocalizedName.startsWith("oredict.oreSmall") && !unlocalizedName.startsWith("oredict.oreBedrock")) { + short meta = (short)stack.getItemDamage(); + for (OreLayerWrapper worldGen: GT6OreLayerHelper.mapOreLayerWrapper.values()) { + if (meta==worldGen.primaryMeta || meta==worldGen.secondaryMeta || meta==worldGen.betweenMeta || meta==worldGen.sporadicMeta) { + List stackListPrimary = new ArrayList(); + List stackListSecondary = new ArrayList(); + List stackListBetween = new ArrayList(); + List stackListSporadic = new ArrayList(); + for (PrefixBlock prefixBlock: GT6OreLayerHelper.setOreNormalBasicTypes) { + stackListPrimary.add(new ItemStack(prefixBlock, 1, worldGen.primaryMeta)); + stackListSecondary.add(new ItemStack(prefixBlock, 1, worldGen.secondaryMeta)); + stackListBetween.add(new ItemStack(prefixBlock, 1, worldGen.betweenMeta)); + stackListSporadic.add(new ItemStack(prefixBlock, 1, worldGen.sporadicMeta)); + } + this.arecipes.add(new CachedVeinStatRecipe(worldGen.veinName, stackListPrimary, stackListSecondary, stackListBetween, stackListSporadic)); + } + } + } + else + super.loadCraftingRecipes(stack); + } + + @Override + public void drawExtras(int recipe) { + CachedVeinStatRecipe crecipe = (CachedVeinStatRecipe) this.arecipes.get(recipe); + OreLayerWrapper oreLayer = GT6OreLayerHelper.mapOreLayerWrapper.get(crecipe.veinName); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getLocalizedVeinName(oreLayer.veinName), 2, 18, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.primaryOre") + ": " + GT6OreLayerHelper.mapMetaToLocalizedName.get(oreLayer.primaryMeta), 2, 31, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.secondaryOre") + ": " + GT6OreLayerHelper.mapMetaToLocalizedName.get(oreLayer.secondaryMeta), 2, 44, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.betweenOre") + ": " + GT6OreLayerHelper.mapMetaToLocalizedName.get(oreLayer.betweenMeta), 2, 57, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.sporadicOre") + ": " + GT6OreLayerHelper.mapMetaToLocalizedName.get(oreLayer.sporadicMeta), 2, 70, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.genHeight") + ": " + oreLayer.worldGenHeightRange, 2, 83, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.weightedChance") + ": " + oreLayer.weightedChance, 2, 96, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": " + getWorldNameTranslated(oreLayer.genOverworld, oreLayer.genNether, oreLayer.genEnd, false, false), 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 String getOutputId() { + return "GTOrePluginVein"; + } + + @Override + public String getRecipeName() { + return I18n.format("gtnop.gui.veinStat.name"); + } + +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java new file mode 100644 index 0000000000..9026aec71d --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java @@ -0,0 +1,128 @@ +package pers.gwyog.gtneioreplugin.util; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import cpw.mods.fml.common.Loader; +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.common.GT_Worldgen_GT_Ore_Layer; +import net.minecraft.client.resources.I18n; +import net.minecraft.item.ItemStack; +import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; +import sun.awt.windows.WWindowPeer; + +public class GT5OreLayerHelper { + public static boolean restrictBiomeSupport = false; + public static boolean endAsteroidSupport = false; + public static boolean gcBasicSupport = false; + public static boolean gcAsteroidSupport = false; + public static boolean immersiveEngineeringSupport = false; + public static HashMap mapOreLayerWrapper = new HashMap(); + + public GT5OreLayerHelper() { + checkExtraSupport(); + for (GT_Worldgen_GT_Ore_Layer tWorldGen: GT_Worldgen_GT_Ore_Layer.sList) + mapOreLayerWrapper.put(tWorldGen.mWorldGenName, new OreLayerWrapper(tWorldGen)); + } + + private static void checkExtraSupport() { + Class clazzGTOreLayer = null; + try { + clazzGTOreLayer = Class.forName("gregtech.common.GT_Worldgen_GT_Ore_Layer"); + } catch (ClassNotFoundException e) {} + if (clazzGTOreLayer != null) { + try { + Field fieldRestrictBiome = clazzGTOreLayer.getField("mRestrictBiome"); + restrictBiomeSupport = true; + } catch (Exception e) {} + try { + Field fieldEndAsteroid = clazzGTOreLayer.getField("mEndAsteroid"); + endAsteroidSupport = true; + } catch (Exception e) {} + try { + Field fieldGCMoon = clazzGTOreLayer.getField("mMoon"); + Field fieldGCMars = clazzGTOreLayer.getField("mMars"); + gcBasicSupport = true; + } catch (Exception e) {} + try { + Field fieldGCAsteroid = clazzGTOreLayer.getField("mAsteroid"); + gcAsteroidSupport = true; + } catch (Exception e) {} + } + + // immersive engineering support for GT5.09.25+ + if (Loader.instance().isModLoaded("ImmersiveEngineering")) { + Class clazzGTMod = null; + Class clazzGTProxy = null; + Class clazzGTAPI = null; + try { + clazzGTMod = Class.forName("gregtech.GT_Mod"); + clazzGTProxy = Class.forName("gregtech.common.GT_Proxy"); + clazzGTAPI = Class.forName("gregtech.api.GregTech_API"); + } catch (ClassNotFoundException e) {} + if (clazzGTMod!=null && clazzGTProxy!=null && clazzGTAPI!=null) { + try { + Field fieldImmersiveEngineeringRecipes = clazzGTAPI.getField("mImmersiveEngineering"); + Field fieldGTProxy = clazzGTMod.getField("gregtechproxy"); + Field fieldImmersiveEngineering = clazzGTProxy.getField("mImmersiveEngineeringRecipes"); + immersiveEngineeringSupport = GregTech_API.mImmersiveEngineering && GT_Mod.gregtechproxy.mImmersiveEngineeringRecipes; + } catch (Exception e) {} + } + } + } + + public class OreLayerWrapper { + public String veinName; + public short primaryMeta; + public short secondaryMeta; + public short betweenMeta; + public short sporadicMeta; + public String worldGenHeightRange; + public String weightedChance; + public String weightedIEChance; + public String restrictBiome; + public boolean genOverworld = false; + public boolean genNether = false; + public boolean genEnd = false; + public boolean genMoon = false; + public boolean genMars = false; + public boolean genEndAsteroid = false; + public boolean genGCAsteroid = false; + public boolean genIEVein = false; + + public OreLayerWrapper(GT_Worldgen_GT_Ore_Layer worldGen) { + this.veinName = worldGen.mWorldGenName; + this.primaryMeta = worldGen.mPrimaryMeta; + this.secondaryMeta = worldGen.mSecondaryMeta; + this.betweenMeta = worldGen.mBetweenMeta; + this.sporadicMeta = worldGen.mSporadicMeta; + this.worldGenHeightRange = worldGen.mMinY + "-" + worldGen.mMaxY; + this.weightedChance = String.format("%.2f%%", (100.0f*worldGen.mWeight)/GT_Worldgen_GT_Ore_Layer.sWeight); + this.genOverworld = worldGen.mOverworld; + this.genNether = worldGen.mNether; + this.genEnd = worldGen.mEnd; + if (restrictBiomeSupport) + this.restrictBiome = worldGen.mRestrictBiome; + if (GT5OreLayerHelper.gcBasicSupport) { + this.genMoon = worldGen.mMoon; + this.genMars = worldGen.mMars; + } + if (GT5OreLayerHelper.endAsteroidSupport) + this.genEndAsteroid = worldGen.mEndAsteroid; + if (GT5OreLayerHelper.gcAsteroidSupport) + this.genGCAsteroid = worldGen.mAsteroid; + + // immersive engineering support for GT5.09.25+ + if (immersiveEngineeringSupport) { + this.genIEVein = true; + this.weightedIEChance = String.format("%.3f%%", (100.0f*worldGen.mWeight)/GT_Worldgen_GT_Ore_Layer.sWeight/8); + } + } + + } + +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java new file mode 100644 index 0000000000..69311a83ee --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java @@ -0,0 +1,111 @@ +package pers.gwyog.gtneioreplugin.util; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.world.GT_Worldgen; +import gregtech.common.GT_Worldgen_GT_Ore_SmallPieces; +import net.minecraft.client.resources.I18n; +import net.minecraft.item.ItemStack; +import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; + +public class GT5OreSmallHelper { + public static boolean restrictBiomeSupport = false; + public static boolean gcBasicSupport = false; + public static List oreSmallList = new ArrayList(); + public static HashMap mapOreSmallWrapper = new HashMap(); + public static HashMap mapOreDropUnlocalizedNameToOreMeta = new HashMap(); + public static HashMap> mapOreMetaToOreDrops = new HashMap>(); + + public GT5OreSmallHelper() { + checkExtraSupport(); + ItemStack stack; + Materials material; + short meta; + for (GT_Worldgen worldGen : GregTech_API.sWorldgenList) + if (worldGen.mWorldGenName.startsWith("ore.small.") && worldGen instanceof GT_Worldgen_GT_Ore_SmallPieces) { + GT_Worldgen_GT_Ore_SmallPieces worldGenSmallPieces = (GT_Worldgen_GT_Ore_SmallPieces)worldGen; + meta = worldGenSmallPieces.mMeta; + material = GregTech_API.sGeneratedMaterials[meta]; + mapOreSmallWrapper.put(worldGen.mWorldGenName, new OreSmallWrapper(worldGenSmallPieces)); + if (!mapOreMetaToOreDrops.keySet().contains(meta)) { + List stackList = new ArrayList(); + stack = GT_OreDictUnificator.get(OrePrefixes.gemExquisite, material, GT_OreDictUnificator.get(OrePrefixes.gem, material, 1L), 1L); + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + stack = GT_OreDictUnificator.get(OrePrefixes.gemFlawless, material, GT_OreDictUnificator.get(OrePrefixes.gem, material, 1L), 1L); + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + stack = GT_OreDictUnificator.get(OrePrefixes.gem, material, 1L); + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + stack = GT_OreDictUnificator.get(OrePrefixes.gemFlawed, material, GT_OreDictUnificator.get(OrePrefixes.crushed, material, 1L), 1L); + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + stack = GT_OreDictUnificator.get(OrePrefixes.crushed, material, 1L); + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + stack = GT_OreDictUnificator.get(OrePrefixes.gemChipped, material, GT_OreDictUnificator.get(OrePrefixes.dustImpure, material, 1L), 1L); + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + stack = GT_OreDictUnificator.get(OrePrefixes.dustImpure, material, 1L); + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + oreSmallList.add(new ItemStack(GregTech_API.sBlockOres1, 1, meta+16000)); + mapOreMetaToOreDrops.put(meta, stackList); + } + } + } + + private static void checkExtraSupport() { + if (GTNEIOrePlugin.GTVersion.equals("GT5")) { + Class clazzGTOreSmall = null; + try { + clazzGTOreSmall = Class.forName("gregtech.common.GT_Worldgen_GT_Ore_SmallPieces"); + } catch (ClassNotFoundException e) {} + if (clazzGTOreSmall != null) { + try { + Field fieldRestrictBiome = clazzGTOreSmall.getField("mRestrictBiome");; + restrictBiomeSupport = true; + } catch (Exception e) {} + try { + Field fieldGCMoon = clazzGTOreSmall.getField("mMoon"); + Field fieldGCMars = clazzGTOreSmall.getField("mMars"); + gcBasicSupport = true; + } catch (Exception e) {} + } + } + } + + public static Materials[] getDroppedDusts() { + return new Materials[]{Materials.Stone, Materials.Netherrack, Materials.Endstone, Materials.GraniteBlack, Materials.GraniteRed, Materials.Marble, Materials.Basalt, Materials.Stone}; + } + + public class OreSmallWrapper { + public String oreGenName; + public short oreMeta; + public String worldGenHeightRange; + public short amountPerChunk; + public String restrictBiome; + public boolean genOverworld = false; + public boolean genNether = false; + public boolean genEnd = false; + public boolean genMoon = false; + public boolean genMars = false; + + public OreSmallWrapper(GT_Worldgen_GT_Ore_SmallPieces worldGen) { + this.oreGenName = worldGen.mWorldGenName; + this.oreMeta = worldGen.mMeta; + this.worldGenHeightRange = worldGen.mMinY + "-" + worldGen.mMaxY; + this.amountPerChunk = worldGen.mAmount; + this.genOverworld = worldGen.mOverworld; + this.genNether = worldGen.mNether; + this.genEnd = worldGen.mEnd; + if (GT5OreSmallHelper.restrictBiomeSupport) + this.restrictBiome = worldGen.mRestrictBiome; + if (GT5OreSmallHelper.gcBasicSupport) { + this.genMoon = worldGen.mMoon; + this.genMars = worldGen.mMars; + } + } + } +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT6OreBedrockHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT6OreBedrockHelper.java new file mode 100644 index 0000000000..be95bcc7b3 --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT6OreBedrockHelper.java @@ -0,0 +1,56 @@ +package pers.gwyog.gtneioreplugin.util; + +import java.util.HashMap; + +import gregapi.data.CS; +import gregapi.data.OP; +import gregapi.lang.LanguageHandler; +import gregapi.oredict.OreDictMaterial; +import gregapi.worldgen.WorldgenObject; +import gregapi.worldgen.Worldgen_GT_Ore_Bedrock; +import gregapi.worldgen.Worldgenerator; +import net.minecraft.client.resources.I18n; + +public class GT6OreBedrockHelper { + public static HashMap mapOreBedrockWrapper = new HashMap(); + public static HashMap mapMetaToLocalizedName = new HashMap(); + + public GT6OreBedrockHelper() { + for (WorldgenObject worldGenOreBedrock : Worldgenerator.sWorldgenList) + if (worldGenOreBedrock.mWorldGenName.startsWith("ore.bedrock.") && worldGenOreBedrock instanceof Worldgen_GT_Ore_Bedrock) + mapOreBedrockWrapper.put(worldGenOreBedrock.mWorldGenName, new OreBedrockWrapper((Worldgen_GT_Ore_Bedrock)worldGenOreBedrock)); + } + + public static String getLocalizedOreBedrockName(short meta) { + // meta==-1 means OreDictMaterial is MT.NULL + if (meta==-1) + return I18n.format("gtnop.ore.null.name"); + else + return LanguageHandler.getLocalName(OP.oreBedrock, CS.BlocksGT.oreBedrock.getMetaMaterial(meta)); + } + + public class OreBedrockWrapper { + public String veinName; + public short meta; + public int probability; + public boolean genOverworld = false; + public boolean genNether = false; + public boolean genEnd = false; + + public OreBedrockWrapper(Worldgen_GT_Ore_Bedrock worldGen) { + this.veinName = worldGen.mWorldGenName; + this.meta = worldGen.mMaterial.mID; + this.probability = worldGen.mProbability; + this.genOverworld = worldGen.mOverworld; + this.genNether = worldGen.mNether; + this.genEnd = worldGen.mEnd; + if (!GT6OreLayerHelper.mapMetaToLocalizedName.keySet().contains(meta)) + GT6OreLayerHelper.mapMetaToLocalizedName.put(meta, GT6OreLayerHelper.getLocalizedOreName(meta)); + if (!GT6OreSmallHelper.mapMetaToLocalizedName.keySet().contains(meta)) + GT6OreSmallHelper.mapMetaToLocalizedName.put(meta, GT6OreSmallHelper.getLocalizedSmallOreName(meta)); + if (!mapMetaToLocalizedName.keySet().contains(meta)) + mapMetaToLocalizedName.put(meta, getLocalizedOreBedrockName(meta)); + } + } + +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT6OreLayerHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT6OreLayerHelper.java new file mode 100644 index 0000000000..ce5da9feb8 --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT6OreLayerHelper.java @@ -0,0 +1,76 @@ +package pers.gwyog.gtneioreplugin.util; + +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; + +import cpw.mods.fml.common.Loader; +import gregapi.block.IBlockPlacable; +import gregapi.block.prefixblock.PrefixBlock; +import gregapi.data.CS; +import gregapi.data.OP; +import gregapi.lang.LanguageHandler; +import gregapi.worldgen.Worldgen_GT_Ore_Layer; +import gregtech.GT_Mod; +import net.minecraft.client.resources.I18n; +import net.minecraft.item.ItemStack; +import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; + +public class GT6OreLayerHelper { + public static HashMap mapOreLayerWrapper = new HashMap(); + public static HashMap mapMetaToLocalizedName = new HashMap(); + public static Set setOreNormalBasicTypes = new HashSet(); + + public GT6OreLayerHelper() { + for (Worldgen_GT_Ore_Layer tWorldGen: Worldgen_GT_Ore_Layer.sList) + mapOreLayerWrapper.put(tWorldGen.mWorldGenName, new OreLayerWrapper(tWorldGen)); + Set setNormalOreBasicTypesTemp = new HashSet(CS.BlocksGT.stoneToNormalOres.values()); + for (IBlockPlacable block: setNormalOreBasicTypesTemp) + if (block instanceof PrefixBlock) + setOreNormalBasicTypes.add((PrefixBlock)block); + } + + public static String getLocalizedOreName(short meta) { + // meta==-1 means OreDictMaterial is MT.NULL + if (meta==-1) + return I18n.format("gtnop.ore.null.name"); + else + return LanguageHandler.getLocalName(OP.ore, CS.BlocksGT.ore.getMetaMaterial(meta)); + } + + public class OreLayerWrapper { + public String veinName; + public short primaryMeta; + public short secondaryMeta; + public short betweenMeta; + public short sporadicMeta; + public String worldGenHeightRange; + public String weightedChance; + public boolean genOverworld = false; + public boolean genNether = false; + public boolean genEnd = false; + + public OreLayerWrapper(Worldgen_GT_Ore_Layer worldGen) { + this.veinName = worldGen.mWorldGenName; + this.primaryMeta = worldGen.mPrimaryMeta; + this.secondaryMeta = worldGen.mSecondaryMeta; + this.betweenMeta = worldGen.mBetweenMeta; + this.sporadicMeta = worldGen.mSporadicMeta; + this.worldGenHeightRange = worldGen.mMinY + "-" + worldGen.mMaxY; + this.weightedChance = String.format("%.2f%%", (100.0f*worldGen.mWeight)/Worldgen_GT_Ore_Layer.sWeight); + this.genOverworld = worldGen.mOverworld; + this.genNether = worldGen.mNether; + this.genEnd = worldGen.mEnd; + if (!mapMetaToLocalizedName.keySet().contains(primaryMeta)) + mapMetaToLocalizedName.put(primaryMeta, getLocalizedOreName(primaryMeta)); + if (!mapMetaToLocalizedName.keySet().contains(secondaryMeta)) + mapMetaToLocalizedName.put(secondaryMeta, getLocalizedOreName(secondaryMeta)); + if (!mapMetaToLocalizedName.keySet().contains(betweenMeta)) + mapMetaToLocalizedName.put(betweenMeta, getLocalizedOreName(betweenMeta)); + if (!mapMetaToLocalizedName.keySet().contains(sporadicMeta)) + mapMetaToLocalizedName.put(sporadicMeta, getLocalizedOreName(sporadicMeta)); + } + } + +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT6OreSmallHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT6OreSmallHelper.java new file mode 100644 index 0000000000..33598b0d98 --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT6OreSmallHelper.java @@ -0,0 +1,100 @@ +package pers.gwyog.gtneioreplugin.util; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import gregapi.block.IBlockPlacable; +import gregapi.block.prefixblock.PrefixBlock; +import gregapi.data.CS; +import gregapi.data.MT; +import gregapi.data.OP; +import gregapi.lang.LanguageHandler; +import gregapi.oredict.OreDictMaterial; +import gregapi.worldgen.WorldgenObject; +import gregapi.worldgen.Worldgen_GT_Ore_SmallPieces; +import gregapi.worldgen.Worldgenerator; +import net.minecraft.client.resources.I18n; +import net.minecraft.item.ItemStack; +import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; + +public class GT6OreSmallHelper { + public static List oreSmallList = new ArrayList(); + public static HashMap mapOreSmallWrapper = new HashMap(); + public static HashMap mapOreDropUnlocalizedNameToOreMeta = new HashMap(); + public static HashMap> mapOreMetaToOreDrops = new HashMap>(); + public static HashMap mapMetaToLocalizedName = new HashMap(); + public static Set setOreSmallBasicTypes = new HashSet(); + + public GT6OreSmallHelper() { + ItemStack stack; + OreDictMaterial material; + PrefixBlock oreSmall = CS.BlocksGT.oreSmall; + short meta; + for (WorldgenObject worldGen : Worldgenerator.sWorldgenList) + if (worldGen.mWorldGenName.startsWith("ore.small.") && worldGen instanceof Worldgen_GT_Ore_SmallPieces) { + Worldgen_GT_Ore_SmallPieces worldGenSmallPieces = (Worldgen_GT_Ore_SmallPieces)worldGen; + meta = worldGenSmallPieces.mMeta; + material = oreSmall.getMetaMaterial(meta); + mapOreSmallWrapper.put(worldGen.mWorldGenName, new OreSmallWrapper(worldGenSmallPieces)); + if (!mapOreMetaToOreDrops.keySet().contains(meta)) { + List stackList = new ArrayList(); + stack = OP.gemExquisite.mat(material, OP.gem.mat(material, 1L), 1L); + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + stack = OP.gemFlawless.mat(material, OP.gem.mat(material, 1L), 1L); + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + stack = OP.gem.mat(material, 1L); + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + stack = OP.gemFlawed.mat(material, OP.crushed.mat(material, 1L), 1L); + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + stack = OP.crushed.mat(material, 1L); + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + stack = OP.gemChipped.mat(material, OP.dustImpure.mat(material, 1L), 1L); + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + stack = OP.dustImpure.mat(material, OP.dust.mat(material, 1L), 1L); + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + stack = OP.gemLegendary.mat(material, 1L); + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + oreSmallList.add(new ItemStack(oreSmall, 1, meta)); + mapOreMetaToOreDrops.put(meta, stackList); + } + mapMetaToLocalizedName.put(meta, getLocalizedSmallOreName(meta)); + Set setSmallOreBasicTypesTemp = new HashSet(CS.BlocksGT.stoneToSmallOres.values()); + for (IBlockPlacable block: setSmallOreBasicTypesTemp) + if (block instanceof PrefixBlock) + setOreSmallBasicTypes.add((PrefixBlock)block); + } + } + + public static String getLocalizedSmallOreName(short meta) { + // meta==-1 means OreDictMaterial is MT.NULL + if (meta==-1) + return I18n.format("gtnop.ore.null.name"); + else + return LanguageHandler.getLocalName(OP.oreSmall, CS.BlocksGT.oreSmall.getMetaMaterial(meta)); + } + + public class OreSmallWrapper { + public String oreGenName; + public short oreMeta; + public String worldGenHeightRange; + public String amountPerChunk; + public boolean genOverworld = false; + public boolean genNether = false; + public boolean genEnd = false; + + public OreSmallWrapper(Worldgen_GT_Ore_SmallPieces worldGen) { + this.oreGenName = worldGen.mWorldGenName; + this.oreMeta = worldGen.mMeta; + this.worldGenHeightRange = worldGen.mMinY + "-" + worldGen.mMaxY; + this.amountPerChunk = worldGen.mAmount/2 + "-" + (worldGen.mAmount/2 + (worldGen.mAmount+1)/2); + this.genOverworld = worldGen.mOverworld; + this.genNether = worldGen.mNether; + this.genEnd = worldGen.mEnd; + } + } + +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GTOreLayerHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GTOreLayerHelper.java deleted file mode 100644 index fd674464cb..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GTOreLayerHelper.java +++ /dev/null @@ -1,126 +0,0 @@ -package pers.gwyog.gtneioreplugin.util; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import cpw.mods.fml.common.Loader; -import gregtech.GT_Mod; -import gregtech.api.GregTech_API; -import gregtech.common.GT_Worldgen_GT_Ore_Layer; -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; -import sun.awt.windows.WWindowPeer; - -public class GTOreLayerHelper { - public static boolean restrictBiomeSupport = false; - public static boolean endAsteroidSupport = false; - public static boolean gcBasicSupport = false; - public static boolean gcAsteroidSupport = false; - public static boolean immersiveEngineeringSupport = false; - public static HashMap mapOreLayerWrapper = new HashMap(); - - public GTOreLayerHelper() { - checkExtraSupport(); - for (GT_Worldgen_GT_Ore_Layer tWorldGen: GT_Worldgen_GT_Ore_Layer.sList) - mapOreLayerWrapper.put(tWorldGen.mWorldGenName, new OreLayerWrapper(tWorldGen)); - } - - private static void checkExtraSupport() { - Class clazzGTOreLayer = null; - try { - clazzGTOreLayer = Class.forName("gregtech.common.GT_Worldgen_GT_Ore_Layer"); - } catch (ClassNotFoundException e) {} - if (clazzGTOreLayer != null) { - try { - Field fieldRestrictBiome = clazzGTOreLayer.getField("mRestrictBiome"); - restrictBiomeSupport = true; - } catch (Exception e) {} - try { - Field fieldEndAsteroid = clazzGTOreLayer.getField("mEndAsteroid"); - endAsteroidSupport = true; - } catch (Exception e) {} - try { - Field fieldGCMoon = clazzGTOreLayer.getField("mMoon"); - Field fieldGCMars = clazzGTOreLayer.getField("mMars"); - gcBasicSupport = true; - } catch (Exception e) {} - try { - Field fieldGCAsteroid = clazzGTOreLayer.getField("mAsteroid"); - gcAsteroidSupport = true; - } catch (Exception e) {} - } - - // immersive engineering support for GT5.09.25+ - if (Loader.isModLoaded("ImmersiveEngineering")) { - Class clazzGTMod = null; - Class clazzGTProxy = null; - Class clazzGTAPI = null; - try { - clazzGTMod = Class.forName("gregtech.GT_Mod"); - clazzGTProxy = Class.forName("gregtech.common.GT_Proxy"); - clazzGTAPI = Class.forName("gregtech.api.GregTech_API"); - } catch (ClassNotFoundException e) {} - if (clazzGTMod!=null && clazzGTProxy!=null && clazzGTAPI!=null) { - try { - Field fieldImmersiveEngineeringRecipes = clazzGTAPI.getField("mImmersiveEngineering"); - Field fieldGTProxy = clazzGTMod.getField("gregtechproxy"); - Field fieldImmersiveEngineering = clazzGTProxy.getField("mImmersiveEngineeringRecipes"); - immersiveEngineeringSupport = GregTech_API.mImmersiveEngineering && GT_Mod.gregtechproxy.mImmersiveEngineeringRecipes; - } catch (Exception e) {} - } - } - } - - public class OreLayerWrapper { - public String veinName; - public short primaryMeta; - public short secondaryMeta; - public short betweenMeta; - public short sporadicMeta; - public String worldGenHeightRange; - public String weightedChance; - public String weightedIEChance; - public String restrictBiome; - public boolean genOverworld = false; - public boolean genNether = false; - public boolean genEnd = false; - public boolean genMoon = false; - public boolean genMars = false; - public boolean genEndAsteroid = false; - public boolean genGCAsteroid = false; - public boolean genIEVein = false; - - public OreLayerWrapper(GT_Worldgen_GT_Ore_Layer worldGen) { - this.veinName = worldGen.mWorldGenName; - this.primaryMeta = worldGen.mPrimaryMeta; - this.secondaryMeta = worldGen.mSecondaryMeta; - this.betweenMeta = worldGen.mBetweenMeta; - this.sporadicMeta = worldGen.mSporadicMeta; - this.worldGenHeightRange = worldGen.mMinY + "-" + worldGen.mMaxY; - this.weightedChance = String.format("%.2f%%", (100.0f*worldGen.mWeight)/GT_Worldgen_GT_Ore_Layer.sWeight); - this.genOverworld = worldGen.mOverworld; - this.genNether = worldGen.mNether; - this.genEnd = worldGen.mEnd; - if (restrictBiomeSupport) - this.restrictBiome = worldGen.mRestrictBiome; - if (GTOreLayerHelper.gcBasicSupport) { - this.genMoon = worldGen.mMoon; - this.genMars = worldGen.mMars; - } - if (GTOreLayerHelper.endAsteroidSupport) - this.genEndAsteroid = worldGen.mEndAsteroid; - if (GTOreLayerHelper.gcAsteroidSupport) - this.genGCAsteroid = worldGen.mAsteroid; - - // immersive engineering support for GT5.09.25+ - if (immersiveEngineeringSupport) { - this.genIEVein = true; - this.weightedIEChance = String.format("%.3f%%", (100.0f*worldGen.mWeight)/GT_Worldgen_GT_Ore_Layer.sWeight/8); - } - } - } - -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GTSmallOreHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GTSmallOreHelper.java deleted file mode 100644 index 5c8168e503..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GTSmallOreHelper.java +++ /dev/null @@ -1,108 +0,0 @@ -package pers.gwyog.gtneioreplugin.util; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.world.GT_Worldgen; -import gregtech.common.GT_Worldgen_GT_Ore_SmallPieces; -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; - -public class GTSmallOreHelper { - public static boolean restrictBiomeSupport = false; - public static boolean gcBasicSupport = false; - public static List smallOreList = new ArrayList(); - public static HashMap mapSmallOreWrapper = new HashMap(); - public static HashMap mapOreDropUnlocalizedNameToOreMeta = new HashMap(); - public static HashMap> mapOreMetaToOreDrops = new HashMap>(); - - public GTSmallOreHelper() { - checkExtraSupport(); - ItemStack stack; - Materials material; - short meta; - for (GT_Worldgen worldGen : GregTech_API.sWorldgenList) - if (worldGen.mWorldGenName.startsWith("ore.small.") && worldGen instanceof GT_Worldgen_GT_Ore_SmallPieces) { - GT_Worldgen_GT_Ore_SmallPieces worldGenSmallPieces = (GT_Worldgen_GT_Ore_SmallPieces)worldGen; - meta = worldGenSmallPieces.mMeta; - material = GregTech_API.sGeneratedMaterials[meta]; - mapSmallOreWrapper.put(worldGen.mWorldGenName, new SmallOreWrapper(worldGenSmallPieces)); - if (!mapOreMetaToOreDrops.keySet().contains(meta)) { - List stackList = new ArrayList(); - stack = GT_OreDictUnificator.get(OrePrefixes.gemExquisite, material, GT_OreDictUnificator.get(OrePrefixes.gem, material, 1L), 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} - stack = GT_OreDictUnificator.get(OrePrefixes.gemFlawless, material, GT_OreDictUnificator.get(OrePrefixes.gem, material, 1L), 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} - stack = GT_OreDictUnificator.get(OrePrefixes.gem, material, 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} - stack = GT_OreDictUnificator.get(OrePrefixes.gemFlawed, material, GT_OreDictUnificator.get(OrePrefixes.crushed, material, 1L), 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} - stack = GT_OreDictUnificator.get(OrePrefixes.crushed, material, 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} - stack = GT_OreDictUnificator.get(OrePrefixes.gemChipped, material, GT_OreDictUnificator.get(OrePrefixes.dustImpure, material, 1L), 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} - stack = GT_OreDictUnificator.get(OrePrefixes.dustImpure, material, 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} - smallOreList.add(new ItemStack(GregTech_API.sBlockOres1, 1, meta+16000)); - mapOreMetaToOreDrops.put(meta, stackList); - } - } - } - - private static void checkExtraSupport() { - Class clazzGTSmallOre = null; - try { - clazzGTSmallOre = Class.forName("gregtech.common.GT_Worldgen_GT_Ore_SmallPieces"); - } catch (ClassNotFoundException e) {} - if (clazzGTSmallOre != null) { - try { - Field fieldRestrictBiome = clazzGTSmallOre.getField("mRestrictBiome");; - restrictBiomeSupport = true; - } catch (Exception e) {} - try { - Field fieldGCMoon = clazzGTSmallOre.getField("mMoon"); - Field fieldGCMars = clazzGTSmallOre.getField("mMars"); - gcBasicSupport = true; - } catch (Exception e) {} - } - } - - public static Materials[] getDroppedDusts() { - return new Materials[]{Materials.Stone, Materials.Netherrack, Materials.Endstone, Materials.GraniteBlack, Materials.GraniteRed, Materials.Marble, Materials.Basalt, Materials.Stone}; - } - - public class SmallOreWrapper { - public String oreGenName; - public short oreMeta; - public String worldGenHeightRange; - public short amountPerChunk; - public String restrictBiome; - public boolean genOverworld = false; - public boolean genNether = false; - public boolean genEnd = false; - public boolean genMoon = false; - public boolean genMars = false; - - public SmallOreWrapper(GT_Worldgen_GT_Ore_SmallPieces worldGen) { - this.oreGenName = worldGen.mWorldGenName; - this.oreMeta = worldGen.mMeta; - this.worldGenHeightRange = worldGen.mMinY + "-" + worldGen.mMaxY; - this.amountPerChunk = worldGen.mAmount; - this.genOverworld = worldGen.mOverworld; - this.genNether = worldGen.mNether; - this.genEnd = worldGen.mEnd; - if (GTSmallOreHelper.restrictBiomeSupport) - this.restrictBiome = worldGen.mRestrictBiome; - if (GTSmallOreHelper.gcBasicSupport) { - this.genMoon = worldGen.mMoon; - this.genMars = worldGen.mMars; - } - } - } -} -- cgit