diff options
Diffstat (limited to 'src/main')
5 files changed, 181 insertions, 10 deletions
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java index 0f1b0210b5..738834c8f0 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java @@ -2,7 +2,9 @@ package pers.gwyog.gtneioreplugin.plugin; import codechicken.nei.api.API; import codechicken.nei.api.IConfigureNEI; +import cpw.mods.fml.common.Loader; import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; +import pers.gwyog.gtneioreplugin.util.GTOreLayerHelper; public class NEIPluginConfig implements IConfigureNEI { @@ -27,6 +29,11 @@ public class NEIPluginConfig implements IConfigureNEI { API.registerUsageHandler(pluginAsteriodStat); API.registerRecipeHandler(pluginSmallOreStat); API.registerUsageHandler(pluginSmallOreStat); + if (GTOreLayerHelper.immersiveEngineeringSupport) { + PluginIEVeinStat pluginIEVeinStat = new PluginIEVeinStat(); + API.registerRecipeHandler(pluginIEVeinStat); + API.registerUsageHandler(pluginIEVeinStat); + } } } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginIEVeinStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginIEVeinStat.java new file mode 100644 index 0000000000..430490d18a --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginIEVeinStat.java @@ -0,0 +1,134 @@ +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<PositionedStack> getIngredients() { + List<PositionedStack> ingredientsList = new ArrayList<PositionedStack>(); + 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/util/GTOreLayerHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GTOreLayerHelper.java index 8bc84157e1..fd674464cb 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GTOreLayerHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GTOreLayerHelper.java @@ -6,6 +6,9 @@ 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; @@ -16,9 +19,8 @@ public class GTOreLayerHelper { public static boolean endAsteroidSupport = false; public static boolean gcBasicSupport = false; public static boolean gcAsteroidSupport = false; + public static boolean immersiveEngineeringSupport = false; public static HashMap<String, OreLayerWrapper> mapOreLayerWrapper = new HashMap<String, OreLayerWrapper>(); - public static List<List<Short>> listVein = new ArrayList<List<Short>>(); - public static List<List<Short>> listAsteroid = new ArrayList<List<Short>>(); public GTOreLayerHelper() { checkExtraSupport(); @@ -50,6 +52,26 @@ public class GTOreLayerHelper { 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 { @@ -60,6 +82,7 @@ public class GTOreLayerHelper { public short sporadicMeta; public String worldGenHeightRange; public String weightedChance; + public String weightedIEChance; public String restrictBiome; public boolean genOverworld = false; public boolean genNether = false; @@ -68,6 +91,7 @@ public class GTOreLayerHelper { 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; @@ -90,14 +114,12 @@ public class GTOreLayerHelper { this.genEndAsteroid = worldGen.mEndAsteroid; if (GTOreLayerHelper.gcAsteroidSupport) this.genGCAsteroid = worldGen.mAsteroid; - List<Short> list = new ArrayList<Short>(); - list.add(primaryMeta); - list.add(secondaryMeta); - list.add(betweenMeta); - list.add(sporadicMeta); - listVein.add(list); - if (genEndAsteroid || genGCAsteroid) - listAsteroid.add(list); + + // 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/resources/assets/gtneioreplugin/lang/en_US.lang b/src/main/resources/assets/gtneioreplugin/lang/en_US.lang index cbeb074fbd..2b347b0398 100644 --- a/src/main/resources/assets/gtneioreplugin/lang/en_US.lang +++ b/src/main/resources/assets/gtneioreplugin/lang/en_US.lang @@ -2,6 +2,7 @@ gtnop.gui.veinStat.name=Vein Stats gtnop.gui.asteroidStat.name=Asteroid Stats gtnop.gui.smallOreStat.name=Small Ore Stats +gtnop.gui.ieVeinStat.name=IE Vein Stats gtnop.gui.nei.veinName=Vein name gtnop.gui.nei.primaryOre=Primary-Gen @@ -22,6 +23,9 @@ gtnop.gui.nei.oreName=Ore name gtnop.gui.nei.amount=Amount per chunk gtnop.gui.nei.chanceDrops=Drops +gtnop.gui.nei.ieVeinComponent=Vein components +gtnop.gui.nei.fromMod=From mod + gtnop.gui.nei.seeAll=See All diff --git a/src/main/resources/assets/gtneioreplugin/lang/zh_CN.lang b/src/main/resources/assets/gtneioreplugin/lang/zh_CN.lang index d02326efa8..042f6065d9 100644 --- a/src/main/resources/assets/gtneioreplugin/lang/zh_CN.lang +++ b/src/main/resources/assets/gtneioreplugin/lang/zh_CN.lang @@ -2,6 +2,7 @@ gtnop.gui.veinStat.name=矿脉信息 gtnop.gui.asteroidStat.name=小行星信息 gtnop.gui.smallOreStat.name=贫瘠矿石信息 +gtnop.gui.ieVeinStat.name=IE虚拟矿脉信息 gtnop.gui.nei.veinName=矿脉名称 gtnop.gui.nei.primaryOre=上层矿石 @@ -22,6 +23,9 @@ gtnop.gui.nei.oreName=矿石名称 gtnop.gui.nei.amount=每区块生成个数 gtnop.gui.nei.chanceDrops=几率掉落 +gtnop.gui.nei.ieVeinComponent=矿脉构成 +gtnop.gui.nei.fromMod=来自模组 + gtnop.gui.nei.seeAll=查看全部 # world names |