diff options
Diffstat (limited to 'src/main/java/pers/gwyog/gtneioreplugin')
9 files changed, 800 insertions, 0 deletions
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java b/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java new file mode 100644 index 0000000000..fdf92404f8 --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java @@ -0,0 +1,29 @@ +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.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.event.ClientTickHandler; + +@Mod(modid = GTNEIOrePlugin.MODID, name = GTNEIOrePlugin.NAME, version = GTNEIOrePlugin.VERSION, dependencies = "required-after:gregtech") +public class GTNEIOrePlugin { + public static final String MODID = "gtneioreplugin"; + public static final String NAME = "GT NEI Ore Plugin"; + public static final String VERSION = "1.0.0"; + + @Mod.Instance(MODID) + public static GTNEIOrePlugin instance; + + @EventHandler + public void init(FMLInitializationEvent event) { + if (event.getSide() == Side.CLIENT) + FMLCommonHandler.instance().bus().register(new ClientTickHandler()); + } + +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/event/ClientTickHandler.java b/src/main/java/pers/gwyog/gtneioreplugin/event/ClientTickHandler.java new file mode 100644 index 0000000000..cb83a4974d --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/event/ClientTickHandler.java @@ -0,0 +1,19 @@ +package pers.gwyog.gtneioreplugin.event; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; +import pers.gwyog.gtneioreplugin.util.GTOreLayerHelper; +import pers.gwyog.gtneioreplugin.util.GTSmallOreHelper; + +public class ClientTickHandler { + public boolean hasInitialized = false; + + @SubscribeEvent + public void onTick(ClientTickEvent event) { + if (!hasInitialized) { + new GTOreLayerHelper(); + new GTSmallOreHelper(); + hasInitialized = true; + } + } +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java new file mode 100644 index 0000000000..a4813c746b --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java @@ -0,0 +1,32 @@ +package pers.gwyog.gtneioreplugin.plugin; + +import codechicken.nei.api.API; +import codechicken.nei.api.IConfigureNEI; +import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; + +public class NEIPluginConfig implements IConfigureNEI { + + @Override + public String getName() { + return "GregTech Ore Plugin"; + } + + @Override + public String getVersion() { + return GTNEIOrePlugin.VERSION; + } + + @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); + } + +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginAsteroidStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginAsteroidStat.java new file mode 100644 index 0000000000..1dc55c441f --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginAsteroidStat.java @@ -0,0 +1,134 @@ +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.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<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) { + CachedAsteroidStatRecipe crecipe = (CachedAsteroidStatRecipe) this.arecipes.get(recipe); + OreLayerWrapper oreLayer = GTOreLayerHelper.mapOreLayerWrapper.get(crecipe.veinName); + GuiDraw.drawString(I18n.format("gui.nei.veinName") + ": " + I18n.format(oreLayer.veinName), 2, 18, 0x404040, false); + GuiDraw.drawString(I18n.format("gui.nei.asteroidPrimary") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.primaryMeta)), 2, 31, 0x404040, false); + GuiDraw.drawString(I18n.format("gui.nei.asteroidSecondary") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.secondaryMeta)), 2, 44, 0x404040, false); + GuiDraw.drawString(I18n.format("gui.nei.asteroidBetween") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.betweenMeta)), 2, 57, 0x404040, false); + GuiDraw.drawString(I18n.format("gui.nei.asteroidSporadic") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.sporadicMeta)), 2, 70, 0x404040, false); + GuiDraw.drawString(I18n.format("gui.nei.worldNames") + ": " + getWorldNameTranslated(oreLayer.genEndAsteroid, oreLayer.genGCAsteroid), 2, 83, 0x404040, false); + GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("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("world.end.name"); + } + if (genGCAsteroid) { + if (!worldNameTranslatedAsteroid.isEmpty()) + worldNameTranslatedAsteroid += ", "; + worldNameTranslatedAsteroid += I18n.format("world.asteroid.name"); + } + return worldNameTranslatedAsteroid; + } + + @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("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 new file mode 100644 index 0000000000..e225ea0944 --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java @@ -0,0 +1,46 @@ +package pers.gwyog.gtneioreplugin.plugin; + +import java.awt.Rectangle; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.recipe.TemplateRecipeHandler; +import codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRect; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.EnumChatFormatting; + +public class PluginBase extends TemplateRecipeHandler { + + @Override + public int recipiesPerPage() { + return 1; + } + + @Override + public String getRecipeName() { + return null; + } + + @Override + public String getGuiTexture() { + return "gtneioreplugin:textures/gui/nei/guiBase.png"; + } + + @Override + public void loadTransferRects() { + int stringLength = GuiDraw.getStringWidth(EnumChatFormatting.BOLD + I18n.format("gui.nei.seeAll")); + transferRects.add(new RecipeTransferRect(new Rectangle(getGuiWidth()-stringLength-3, 5, stringLength, 9), getOutputId())); + } + + public String getOutputId() { + return null; + } + + public String getGTOreUnlocalizedName(short index) { + return "gt.blockores." + index + ".name"; + } + + public int getGuiWidth() { + return 166; + } + +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginSmallOreStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginSmallOreStat.java new file mode 100644 index 0000000000..ba8c39babb --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginSmallOreStat.java @@ -0,0 +1,165 @@ +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<PositionedStack> positionedDropStackList; + + public CachedSmallOreRecipe(String oreGenName, List<ItemStack> stackList, List<ItemStack> materialDustStackList, List<ItemStack> dropStackList) { + this.oreGenName = oreGenName; + this.positionedStackSmallOre = new PositionedStack(stackList, 2, 0); + this.positionedStackMaterialDust = new PositionedStack(materialDustStackList, 43, 79); + List<PositionedStack> positionedDropStackList = new ArrayList<PositionedStack>(); + int i = 1; + for (ItemStack stackDrop: dropStackList) + positionedDropStackList.add(new PositionedStack(stackDrop, 43+20*(i%4), 79+16*((i++)/4))); + this.positionedDropStackList = positionedDropStackList; + } + + @Override + public List<PositionedStack> 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("gui.nei.oreName") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName((short)(smallOre.oreMeta+16000))), 2, 18, 0x404040, false); + GuiDraw.drawString(I18n.format("gui.nei.genHeight") + ": " + smallOre.worldGenHeightRange, 2, 31, 0x404040, false); + GuiDraw.drawString(I18n.format("gui.nei.amount") + ": " + smallOre.amountPerChunk, 2, 44, 0x404040, false); + GuiDraw.drawString(I18n.format("gui.nei.worldNames") + ": " + getWorldNameTranslated(smallOre.genOverworld, smallOre.genNether, smallOre.genEnd, smallOre.genMoon, smallOre.genMars), 2, 57, 0x404040, false); + GuiDraw.drawString(I18n.format("gui.nei.restrictBiome") + ": " + getBiomeTranslated(smallOre.restrictBiome), 2, 70, 0x404040, false); + GuiDraw.drawString(I18n.format("gui.nei.chanceDrops") + ": ", 2, 83, 0x404040, false); + GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gui.nei.seeAll"), getGuiWidth()-3, 5, 0x404040, false); + } + + public String getBiomeTranslated(String unlocalizedBiome) { + return unlocalizedBiome.equals("None")? I18n.format("biome.none.name"): unlocalizedBiome; + } + + public String getWorldNameTranslated(boolean genOverworld, boolean genNether, boolean genEnd, boolean genMoon, boolean genMars) { + String worldNameTranslated = ""; + if (genOverworld) { + if (!worldNameTranslated.isEmpty()) + worldNameTranslated += ", "; + worldNameTranslated += I18n.format("world.overworld.name"); + } + if (genNether) { + if (!worldNameTranslated.isEmpty()) + worldNameTranslated += ", "; + worldNameTranslated += I18n.format("world.nether.name"); + } + if (genEnd) { + if (!worldNameTranslated.isEmpty()) + worldNameTranslated += ", "; + worldNameTranslated += I18n.format("world.end.name"); + } + if (genMoon) { + if (!worldNameTranslated.isEmpty()) + worldNameTranslated += ", "; + worldNameTranslated += I18n.format("world.moon.name"); + } + if (genMars) { + if (!worldNameTranslated.isEmpty()) + worldNameTranslated += ", "; + worldNameTranslated += I18n.format("world.mars.name"); + } + return worldNameTranslated; + } + + @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<ItemStack> stackList = new ArrayList<ItemStack>(); + for (int i=0;i<7;i++) + stackList.add(new ItemStack(GregTech_API.sBlockOres1, 1, smallOreWorldGen.oreMeta+16000+i*1000)); + List<ItemStack> materialDustStackList = new ArrayList<ItemStack>(); + for (int i=0;i<7;i++) + materialDustStackList.add(GT_OreDictUnificator.get(OrePrefixes.dust, GTSmallOreHelper.getDroppedDusts()[i], 1L)); + this.arecipes.add(new CachedSmallOreRecipe(smallOreWorldGen.oreGenName, stackList, materialDustStackList, GTSmallOreHelper.mapOreMetaToOreDrops.get(baseMeta))); + } + } + } + else if (GTSmallOreHelper.mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) { + short baseMeta = GTSmallOreHelper.mapOreDropUnlocalizedNameToOreMeta.get(stack.getUnlocalizedName()); + for (String oreGenName: GTSmallOreHelper.mapSmallOreWrapper.keySet()) { + SmallOreWrapper smallOreWrapper = GTSmallOreHelper.mapSmallOreWrapper.get(oreGenName); + if (smallOreWrapper.oreMeta == baseMeta) { + List<ItemStack> stackList = new ArrayList<ItemStack>(); + for (int i=0;i<7;i++) + stackList.add(new ItemStack(GregTech_API.sBlockOres1, 1, baseMeta+16000+i*1000)); + List<ItemStack> materialDustStackList = new ArrayList<ItemStack>(); + 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("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 new file mode 100644 index 0000000000..f281b3b29e --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginVeinStat.java @@ -0,0 +1,175 @@ +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<ItemStack> stackListPrimary, List<ItemStack> stackListSecondary, + List<ItemStack> stackListBetween, List<ItemStack> stackListSporadic) { + this.veinName = veinName; + positionedStackPrimary = new PositionedStack(stackListPrimary, 2, 0); + positionedStackSecondary = new PositionedStack(stackListSecondary, 22, 0); + positionedStackBetween = new PositionedStack(stackListBetween, 42, 0); + positionedStackSporadic = new PositionedStack(stackListSporadic, 62, 0); + } + + @Override + public List<PositionedStack> getIngredients() { + List<PositionedStack> ingredientsList = new ArrayList<PositionedStack>(); + positionedStackPrimary.setPermutationToRender((cycleticks / 20) % positionedStackPrimary.items.length);; + positionedStackSecondary.setPermutationToRender((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<ItemStack> stackListPrimary = new ArrayList<ItemStack>(); + List<ItemStack> stackListSecondary = new ArrayList<ItemStack>(); + List<ItemStack> stackListBetween = new ArrayList<ItemStack>(); + List<ItemStack> stackListSporadic = new ArrayList<ItemStack>(); + for (int i=0;i<7;i++) { + stackListPrimary.add(new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.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()) { + System.out.println(worldGen.primaryMeta + "," + worldGen.secondaryMeta + "," + worldGen.betweenMeta + "," + worldGen.sporadicMeta); + if (worldGen.primaryMeta == baseMeta || worldGen.secondaryMeta == baseMeta || worldGen.betweenMeta == baseMeta || worldGen.sporadicMeta == baseMeta) { + List<ItemStack> stackListPrimary = new ArrayList<ItemStack>(); + List<ItemStack> stackListSecondary = new ArrayList<ItemStack>(); + List<ItemStack> stackListBetween = new ArrayList<ItemStack>(); + List<ItemStack> stackListSporadic = new ArrayList<ItemStack>(); + for (int i=0;i<7;i++) { + stackListPrimary.add(new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.primaryMeta+i*1000)); + stackListSecondary.add(new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.secondaryMeta+i*1000)); + stackListBetween.add(new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.betweenMeta+i*1000)); + stackListSporadic.add(new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.sporadicMeta+i*1000)); + } + 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 = GTOreLayerHelper.mapOreLayerWrapper.get(crecipe.veinName); + GuiDraw.drawString(I18n.format("gui.nei.veinName") + ": " + I18n.format(oreLayer.veinName), 2, 18, 0x404040, false); + GuiDraw.drawString(I18n.format("gui.nei.primaryOre") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.primaryMeta)), 2, 31, 0x404040, false); + GuiDraw.drawString(I18n.format("gui.nei.secondaryOre") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.secondaryMeta)), 2, 44, 0x404040, false); + GuiDraw.drawString(I18n.format("gui.nei.betweenOre") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.betweenMeta)), 2, 57, 0x404040, false); + GuiDraw.drawString(I18n.format("gui.nei.sporadicOre") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.sporadicMeta)), 2, 70, 0x404040, false); + GuiDraw.drawString(I18n.format("gui.nei.genHeight") + ": " + oreLayer.worldGenHeightRange, 2, 83, 0x404040, false); + GuiDraw.drawString(I18n.format("gui.nei.weightedChance") + ": " + oreLayer.weightedChance, 2, 96, 0x404040, false); + GuiDraw.drawString(I18n.format("gui.nei.worldNames") + ": " + getWorldNameTranslated(oreLayer.genOverworld, oreLayer.genNether, oreLayer.genEnd, oreLayer.genMoon, oreLayer.genMars), 2, 109, 0x404040, false); + GuiDraw.drawString(I18n.format("gui.nei.restrictBiome") + ": " + getBiomeTranslated(oreLayer.restrictBiome), 2, 122, 0x404040, false); + GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gui.nei.seeAll"), getGuiWidth()-3, 5, 0x404040, false); + } + + public String getBiomeTranslated(String unlocalizedBiome) { + return unlocalizedBiome.equals("None")? I18n.format("biome.none.name"): unlocalizedBiome; + } + + public String getWorldNameTranslated(boolean genOverworld, boolean genNether, boolean genEnd, boolean genMoon, boolean genMars) { + String worldNameTranslated = ""; + if (genOverworld) { + if (!worldNameTranslated.isEmpty()) + worldNameTranslated += ", "; + worldNameTranslated += I18n.format("world.overworld.name"); + } + if (genNether) { + if (!worldNameTranslated.isEmpty()) + worldNameTranslated += ", "; + worldNameTranslated += I18n.format("world.nether.name"); + } + if (genEnd) { + if (!worldNameTranslated.isEmpty()) + worldNameTranslated += ", "; + worldNameTranslated += I18n.format("world.end.name"); + } + if (genMoon) { + if (!worldNameTranslated.isEmpty()) + worldNameTranslated += ", "; + worldNameTranslated += I18n.format("world.moon.name"); + } + if (genMars) { + if (!worldNameTranslated.isEmpty()) + worldNameTranslated += ", "; + worldNameTranslated += I18n.format("world.mars.name"); + } + return worldNameTranslated; + } + + @Override + public String getOutputId() { + return "GTOrePluginVein"; + } + + @Override + public String getRecipeName() { + return I18n.format("gui.veinStat.name"); + } + +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GTOreLayerHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GTOreLayerHelper.java new file mode 100644 index 0000000000..e6f9541e9f --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GTOreLayerHelper.java @@ -0,0 +1,98 @@ +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 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 endAsteroidSupport = false; + public static boolean gcBasicSupport = false; + public static boolean gcAsteroidSupport = 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(); + 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 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) {} + } + } + + 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 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 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.restrictBiome = worldGen.mRestrictBiome; + this.genOverworld = worldGen.mOverworld; + this.genNether = worldGen.mNether; + this.genEnd = worldGen.mEnd; + 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; + 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); + } + } + +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GTSmallOreHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GTSmallOreHelper.java new file mode 100644 index 0000000000..40889e8c11 --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GTSmallOreHelper.java @@ -0,0 +1,102 @@ +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 gcBasicSupport = false; + public static List<ItemStack> smallOreList = new ArrayList<ItemStack>(); + public static HashMap<String, SmallOreWrapper> mapSmallOreWrapper = new HashMap<String, SmallOreWrapper>(); + public static HashMap<String, Short> mapOreDropUnlocalizedNameToOreMeta = new HashMap<String, Short>(); + public static HashMap<Short, List<ItemStack>> mapOreMetaToOreDrops = new HashMap<Short, List<ItemStack>>(); + + 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<ItemStack> stackList = new ArrayList<ItemStack>(); + stack = GT_OreDictUnificator.get(OrePrefixes.gemExquisite, material, GT_OreDictUnificator.get(OrePrefixes.gem, material, 1L), 1L); + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + 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 clazzGTOreLayer = null; + try { + clazzGTOreLayer = Class.forName("gregtech.common.GT_Worldgen_GT_Ore_SmallPieces"); + } catch (ClassNotFoundException e) {} + if (clazzGTOreLayer != null) { + try { + Field fieldGCMoon = clazzGTOreLayer.getField("mMoon"); + Field fieldGCMars = clazzGTOreLayer.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.restrictBiome = worldGen.mRestrictBiome; + this.genOverworld = worldGen.mOverworld; + this.genNether = worldGen.mNether; + this.genEnd = worldGen.mEnd; + if (GTOreLayerHelper.gcBasicSupport) { + this.genMoon = worldGen.mMoon; + this.genMars = worldGen.mMars; + } + } + } +} |