diff options
Diffstat (limited to 'src/main/java/pers/gwyog/gtneioreplugin/plugin')
4 files changed, 203 insertions, 280 deletions
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java index da3947fee8..de36d22bc9 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java @@ -2,11 +2,10 @@ package pers.gwyog.gtneioreplugin.plugin; import codechicken.lib.gui.GuiDraw; import codechicken.nei.recipe.TemplateRecipeHandler; +import java.awt.*; import net.minecraft.client.resources.I18n; import net.minecraft.util.EnumChatFormatting; -import java.awt.*; - public abstract class PluginBase extends TemplateRecipeHandler { @Override @@ -27,7 +26,8 @@ public abstract class PluginBase extends TemplateRecipeHandler { @Override public void loadTransferRects() { int stringLength = GuiDraw.getStringWidth(EnumChatFormatting.BOLD + I18n.format("gui.nei.seeAll")); - transferRects.add(new RecipeTransferRect(new Rectangle(getGuiWidth() - stringLength - 3, 5, stringLength, 9), getOutputId())); + transferRects.add(new RecipeTransferRect( + new Rectangle(getGuiWidth() - stringLength - 3, 5, stringLength, 9), getOutputId())); } public abstract String getOutputId(); @@ -35,5 +35,4 @@ public abstract class PluginBase extends TemplateRecipeHandler { public int getGuiWidth() { return 166; } - } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java index f5bb8a618b..bdcccebe7a 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java @@ -1,27 +1,27 @@ package pers.gwyog.gtneioreplugin.plugin.gregtech5; +import static pers.gwyog.gtneioreplugin.GTNEIOrePlugin.toolTips; + import codechicken.lib.gui.GuiDraw; import codechicken.nei.guihook.GuiContainerManager; import codechicken.nei.recipe.GuiRecipe; import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.util.GT_LanguageManager; +import java.awt.Point; +import java.awt.Rectangle; +import java.util.List; import net.minecraft.client.resources.I18n; import net.minecraft.util.EnumChatFormatting; import pers.gwyog.gtneioreplugin.plugin.PluginBase; import pers.gwyog.gtneioreplugin.util.DimensionHelper; import pers.gwyog.gtneioreplugin.util.GuiRecipeHelper; -import java.awt.Point; -import java.awt.Rectangle; -import java.util.List; - -import static pers.gwyog.gtneioreplugin.GTNEIOrePlugin.toolTips; - public abstract class PluginGT5Base extends PluginBase { protected static String getLocalizedNameForItem(Materials aMaterial, String aFormat) { - return String.format(aFormat.replace("%s", "%temp").replace("%material", "%s"), aMaterial.mLocalizedName).replace("%temp", "%s"); + return String.format(aFormat.replace("%s", "%temp").replace("%material", "%s"), aMaterial.mLocalizedName) + .replace("%temp", "%s"); } protected static String getLocalizedNameForItem(String aFormat, int aMaterialID) { @@ -36,19 +36,24 @@ public abstract class PluginGT5Base extends PluginBase { public static String getGTOreLocalizedName(short index) { - if (!getLocalizedNameForItem(GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(index)), index % 1000).contains("Awakened")) - return getLocalizedNameForItem(GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(index)), index % 1000); - else - return "Aw. Draconium Ore"; + if (!getLocalizedNameForItem(GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(index)), index % 1000) + .contains("Awakened")) + return getLocalizedNameForItem( + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(index)), index % 1000); + else return "Aw. Draconium Ore"; } protected static String getGTOreUnlocalizedName(short index) { return "gt.blockores." + index + ".name"; } + static void drawLine(String lineKey, String value, int x, int y) { + GuiDraw.drawString(I18n.format(lineKey) + ": " + value, x, y, 0x404040, false); + } + /** * Add lines to the current tooltip if appropriate - * + * * @param gui An instance of the currentscreen * @param currenttip The current tooltip, will contain item name and info * @param recipe The recipe index being handled @@ -58,9 +63,8 @@ public abstract class PluginGT5Base extends PluginBase { public List<String> handleTooltip(GuiRecipe gui, List<String> currenttip, int recipe) { if (toolTips && GuiContainerManager.shouldShowTooltip(gui) && currenttip.size() == 0) { String dimNames = getDimensionNames(recipe); - Rectangle dimRect = getDimensionNamesRect(gui, recipe , dimNames); + Rectangle dimRect = getDimensionNamesRect(gui, recipe, dimNames); Point mousePos = GuiDraw.getMousePosition(); - if (dimRect.contains(mousePos.x, mousePos.y)) { List<String> dims = DimensionHelper.convertCondensedStringToToolTip(dimNames); @@ -73,42 +77,42 @@ public abstract class PluginGT5Base extends PluginBase { /** * The dimension names for a given recipe index - * - * @param The recipe index being handled + * + * @param recipe The recipe index being handled * @return A CSV string of dimension name abbreviations */ protected abstract String getDimensionNames(int recipe); /** * Produce a rectangle covering the area of displayed dimension names - * + * * @param gui An instance of the currentscreen * @param recipe The recipe index being handled * @param dimNames Dimension names to produce a rectangle for * @return Rectangle area of dimension names */ protected Rectangle getDimensionNamesRect(GuiRecipe gui, int recipe, String dimNames) { - int dimNamesHeight = dimNames.length() > 70 ? 30 : (dimNames.length() > 36 ? 20 : 10); + int dimNamesHeight = dimNames.length() > 70 ? 30 : (dimNames.length() > 36 ? 20 : 10); Point offset = gui.getRecipePosition(recipe); - return new Rectangle(GuiRecipeHelper.getGuiLeft(gui) + offset.x + 2, - GuiRecipeHelper.getGuiTop(gui) + offset.y + 110, - GuiRecipeHelper.getXSize(gui) - 9, - dimNamesHeight ); + return new Rectangle( + GuiRecipeHelper.getGuiLeft(gui) + offset.x + 2, + GuiRecipeHelper.getGuiTop(gui) + offset.y + 110, + GuiRecipeHelper.getXSize(gui) - 9, + dimNamesHeight); } protected int getMaximumMaterialIndex(short meta, boolean smallOre) { int offset = smallOre ? 16000 : 0; - if (!getGTOreLocalizedName((short) (meta + offset + 5000)).equals(getGTOreUnlocalizedName((short) (meta + offset + 5000)))) - return 7; - else if (!getGTOreLocalizedName((short) (meta + offset + 5000)).equals(getGTOreUnlocalizedName((short) (meta + offset + 5000)))) - return 6; - else - return 5; + 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; } /** * Draw the dimension header and the dimension names over up to 3 lines - * + * * @param dimNames A CSV string of dimension name abbreviations */ protected void drawDimNames(String dimNames) { @@ -118,12 +122,13 @@ public abstract class PluginGT5Base extends PluginBase { GuiDraw.drawString(I18n.format("") + dimNames.substring(0, 36), 2, 110, 0x404040, false); if (dimNames.length() > 70) { GuiDraw.drawString(I18n.format("") + dimNames.substring(36, 70), 2, 120, 0x404040, false); - GuiDraw.drawString(I18n.format("") + dimNames.substring(70, dimNames.length() - 1), 2, 130, 0x404040, false); - } else - { - GuiDraw.drawString(I18n.format("") + dimNames.substring(36, dimNames.length() - 1), 2, 120, 0x404040, false); + GuiDraw.drawString( + I18n.format("") + dimNames.substring(70, dimNames.length() - 1), 2, 130, 0x404040, false); + } else { + GuiDraw.drawString( + I18n.format("") + dimNames.substring(36, dimNames.length() - 1), 2, 120, 0x404040, false); } - } else{ + } else { GuiDraw.drawString(I18n.format("") + dimNames.substring(0, dimNames.length() - 1), 2, 110, 0x404040, false); } } @@ -132,6 +137,7 @@ public abstract class PluginGT5Base extends PluginBase { * Draw the "see all recipes" transfer label */ protected void drawSeeAllRecipesLabel() { - GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gtnop.gui.nei.seeAll"), getGuiWidth() - 3, 5, 0x404040, false); + GuiDraw.drawStringR( + EnumChatFormatting.BOLD + I18n.format("gtnop.gui.nei.seeAll"), getGuiWidth() - 3, 5, 0x404040, false); } } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java index 70346889e9..38f668f05e 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java @@ -1,37 +1,49 @@ package pers.gwyog.gtneioreplugin.plugin.gregtech5; -import codechicken.lib.gui.GuiDraw; import codechicken.nei.PositionedStack; -import gregtech.api.GregTech_API; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_OreDictUnificator; +import java.util.ArrayList; +import java.util.List; import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; import pers.gwyog.gtneioreplugin.util.GT5OreSmallHelper; import pers.gwyog.gtneioreplugin.util.GT5OreSmallHelper.OreSmallWrapper; -import java.util.ArrayList; -import java.util.List; - public class PluginGT5SmallOreStat extends PluginGT5Base { + private static final int SMALL_ORE_BASE_META = 16000; + @Override public void drawExtras(int recipe) { - CachedOreSmallRecipe crecipe = (CachedOreSmallRecipe) this.arecipes.get(recipe); - OreSmallWrapper oreSmall = GT5OreSmallHelper.mapOreSmallWrapper.get(crecipe.oreGenName); - String sDimNames = GT5OreSmallHelper.bufferedDims.get(oreSmall); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.oreName") + ": " + getGTOreLocalizedName((short) (oreSmall.oreMeta + 16000)), 2, 18, 0x404040, false); + OreSmallWrapper oreSmall = getSmallOre(recipe); - 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); - // if (GT5OreSmallHelper.restrictBiomeSupport) GuiDraw.drawString(I18n.format("gtnop.gui.nei.restrictBiome") + ": " + getBiomeTranslated(oreSmall.restrictBiome), 2, 70, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.chanceDrops") + ": ", 2, 83 + getRestrictBiomeOffset(), 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": ", 2, 100, 0x404040, false); + drawSmallOreName(oreSmall); + drawSmallOreInfo(oreSmall); + String sDimNames = GT5OreSmallHelper.bufferedDims.get(oreSmall); drawDimNames(sDimNames); + drawSeeAllRecipesLabel(); } + private void drawSmallOreName(OreSmallWrapper oreSmall) { + String oreName = getGTOreLocalizedName((short) (oreSmall.oreMeta + SMALL_ORE_BASE_META)); + drawLine("gtnop.gui.nei.oreName", oreName, 2, 18); + } + + private void drawSmallOreInfo(OreSmallWrapper oreSmall) { + drawLine("gtnop.gui.nei.genHeight", oreSmall.worldGenHeightRange, 2, 31); + drawLine("gtnop.gui.nei.amount", String.valueOf(oreSmall.amountPerChunk), 2, 44); + drawLine("gtnop.gui.nei.chanceDrops", "", 2, 83 + getRestrictBiomeOffset()); + drawLine("gtnop.gui.nei.worldNames", "", 2, 100); + } + + private OreSmallWrapper getSmallOre(int recipe) { + CachedOreSmallRecipe crecipe = (CachedOreSmallRecipe) this.arecipes.get(recipe); + return GT5OreSmallHelper.mapOreSmallWrapper.get(crecipe.oreGenName); + } + public int getRestrictBiomeOffset() { return GT5OreSmallHelper.restrictBiomeSupport ? 0 : -13; } @@ -39,48 +51,51 @@ public class PluginGT5SmallOreStat extends PluginGT5Base { @Override public void loadCraftingRecipes(String outputId, Object... results) { if (outputId.equals(getOutputId())) - for (ItemStack stack : GT5OreSmallHelper.oreSmallList) - loadCraftingRecipes(stack); - else - super.loadCraftingRecipes(outputId, results); + 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<ItemStack> stackList = new ArrayList<ItemStack>(); - int maximumIndex = getMaximumMaterialIndex(baseMeta, true); - for (int i = 0; i < maximumIndex; i++) - stackList.add(new ItemStack(GregTech_API.sBlockOres1, 1, oreSmallWorldGen.oreMeta + 16000 + i * 1000)); - List<ItemStack> materialDustStackList = new ArrayList<ItemStack>(); - for (int i = 0; i < maximumIndex; i++) - materialDustStackList.add(GT_OreDictUnificator.get(OrePrefixes.dust, GT5OreSmallHelper.getDroppedDusts()[i], 1L)); - this.arecipes.add(new CachedOreSmallRecipe(oreSmallWorldGen.oreGenName, stackList, materialDustStackList, GT5OreSmallHelper.mapOreMetaToOreDrops.get(baseMeta))); - } - } - } else if (GT5OreSmallHelper.mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) { - short baseMeta = GT5OreSmallHelper.mapOreDropUnlocalizedNameToOreMeta.get(stack.getUnlocalizedName()); - for (String oreGenName : GT5OreSmallHelper.mapOreSmallWrapper.keySet()) { - OreSmallWrapper oreSmallWrapper = GT5OreSmallHelper.mapOreSmallWrapper.get(oreGenName); - if (oreSmallWrapper.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, GT5OreSmallHelper.getDroppedDusts()[i], 1L)); - this.arecipes.add(new CachedOreSmallRecipe(GT5OreSmallHelper.mapOreSmallWrapper.get(oreGenName).oreGenName, stackList, materialDustStackList, GT5OreSmallHelper.mapOreMetaToOreDrops.get(baseMeta))); - } + short oreMeta = (short) (stack.getItemDamage() % 1000); + loadSmallOre(oreMeta, getMaximumMaterialIndex(oreMeta, true)); + } else if (GT5OreSmallHelper.mapOreDropUnlocalizedNameToOreMeta.containsKey(stack.getUnlocalizedName())) { + short oreMeta = GT5OreSmallHelper.mapOreDropUnlocalizedNameToOreMeta.get(stack.getUnlocalizedName()); + loadSmallOre(oreMeta, 7); + } else super.loadCraftingRecipes(stack); + } + + private void loadSmallOre(short oreMeta, int maximumIndex) { + OreSmallWrapper smallOre = getSmallOre(oreMeta); + if (smallOre != null) { + addSmallOre(smallOre, maximumIndex); + } + } + + private OreSmallWrapper getSmallOre(short oreMeta) { + for (OreSmallWrapper oreSmallWorldGen : GT5OreSmallHelper.mapOreSmallWrapper.values()) { + if (oreSmallWorldGen.oreMeta == oreMeta) { + return oreSmallWorldGen; } - } else - super.loadCraftingRecipes(stack); + } + return null; + } + + private void addSmallOre(OreSmallWrapper smallOre, int maximumIndex) { + this.arecipes.add(new CachedOreSmallRecipe( + smallOre.oreGenName, + smallOre.getMaterialDrops(maximumIndex), + getStoneDusts(maximumIndex), + GT5OreSmallHelper.mapOreMetaToOreDrops.get(smallOre.oreMeta))); + } + + private List<ItemStack> getStoneDusts(int maximumIndex) { + List<ItemStack> materialDustStackList = new ArrayList<>(); + for (int i = 0; i < maximumIndex; i++) + materialDustStackList.add( + GT_OreDictUnificator.get(OrePrefixes.dust, GT5OreSmallHelper.getDroppedDusts()[i], 1L)); + return materialDustStackList; } @Override @@ -95,48 +110,52 @@ public class PluginGT5SmallOreStat extends PluginGT5Base { /** * The dimension names for a given recipe identifier - * + * * @param recipe identifier * @return A CSV string of dimension name abbreviations */ @Override - protected String getDimensionNames(int recipe) { - CachedOreSmallRecipe crecipe = (CachedOreSmallRecipe) this.arecipes.get(recipe); - OreSmallWrapper oreSmall = GT5OreSmallHelper.mapOreSmallWrapper.get(crecipe.oreGenName); + protected String getDimensionNames(int recipe) { + OreSmallWrapper oreSmall = getSmallOre(recipe); return GT5OreSmallHelper.bufferedDims.get(oreSmall); } - + public class CachedOreSmallRecipe extends CachedRecipe { public String oreGenName; public PositionedStack positionedStackOreSmall; public PositionedStack positionedStackMaterialDust; public List<PositionedStack> positionedDropStackList; - public CachedOreSmallRecipe(String oreGenName, List<ItemStack> stackList, List<ItemStack> materialDustStackList, List<ItemStack> dropStackList) { + public CachedOreSmallRecipe( + String oreGenName, + List<ItemStack> stackList, + List<ItemStack> materialDustStackList, + List<ItemStack> dropStackList) { this.oreGenName = oreGenName; this.positionedStackOreSmall = new PositionedStack(stackList, 2, 0); - this.positionedStackMaterialDust = new PositionedStack(materialDustStackList, 43, 79 + getRestrictBiomeOffset()); - List<PositionedStack> positionedDropStackList = new ArrayList<PositionedStack>(); + this.positionedStackMaterialDust = + new PositionedStack(materialDustStackList, 43, 79 + getRestrictBiomeOffset()); + List<PositionedStack> positionedDropStackList = new ArrayList<>(); int i = 1; for (ItemStack stackDrop : dropStackList) - positionedDropStackList.add(new PositionedStack(stackDrop, 43 + 20 * (i % 4), 79 + 16 * ((i++) / 4) + getRestrictBiomeOffset())); + positionedDropStackList.add(new PositionedStack( + stackDrop, 43 + 20 * (i % 4), 79 + 16 * ((i++) / 4) + getRestrictBiomeOffset())); this.positionedDropStackList = positionedDropStackList; } @Override public List<PositionedStack> getIngredients() { positionedStackOreSmall.setPermutationToRender((cycleticks / 20) % positionedStackOreSmall.items.length); - positionedStackMaterialDust.setPermutationToRender((cycleticks / 20) % positionedStackMaterialDust.items.length); + positionedStackMaterialDust.setPermutationToRender( + (cycleticks / 20) % positionedStackMaterialDust.items.length); positionedDropStackList.add(positionedStackOreSmall); positionedDropStackList.add(positionedStackMaterialDust); return positionedDropStackList; - } @Override public PositionedStack getResult() { return null; } - } } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java index 8f8a01ef0a..dc559db34a 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java @@ -1,202 +1,104 @@ package pers.gwyog.gtneioreplugin.plugin.gregtech5; -import codechicken.lib.gui.GuiDraw; +import static pers.gwyog.gtneioreplugin.util.OreVeinLayer.*; + import codechicken.nei.PositionedStack; import cpw.mods.fml.common.Loader; -import gregtech.api.GregTech_API; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper; import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper.OreLayerWrapper; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - public class PluginGT5VeinStat extends PluginGT5Base { - // Unused - public static String[] getLocalizedVeinName(OreLayerWrapper oreLayer) { - String unlocalizedName = oreLayer.veinName; - if (unlocalizedName.startsWith("ore.mix.custom.")) - return get_Cnames(oreLayer);//I18n.format("gtnop.ore.custom.name") + I18n.format("gtnop.ore.vein.name") + unlocalizedName.substring(15); - else - return new String[]{I18n.format("gtnop." + unlocalizedName) + I18n.format("gtnop.ore.vein.name")}; - } - - // Unused - public static String coustomVeinRenamer(OreLayerWrapper oreLayer) { - Set<String> s = new HashSet<String>(); - for (int i = 0; i < 4; i++) - s.add(getGTOreLocalizedName(oreLayer.Meta[i]).replaceAll(" ", "")); - return s.toString() - .replace("[".charAt(0), ",".charAt(0)) - .replace("]".charAt(0), ",".charAt(0)) - .replaceAll(" Ore", ",") - .replaceAll("Ore", ",") - .replaceAll(" Sand", ",") - .replaceAll("Sand", ",") - .replaceAll("Stone", ",") - .replaceAll(" Stone", ",") - .replaceAll("Earth", ",") - .replaceAll(" Earth", ",") - .replaceAll("Infused", ",") - .replaceAll(" Infused", ",") - .replaceAll(",", "") - .trim(); - } - - /*public String getWeightedChance(OreLayerWrapper oreLayer) { - String weightedChance = ""; - for (int i=0; i < oreLayer.alloweddims.size(); i++) { - if (oreLayer.alloweddims.get(i) && (oreLayer.Weight.get(i) != 0)) { - if (!weightedChance.isEmpty()) - weightedChance += ", "; - weightedChance += String.format("%.2f%%", (100.0f*oreLayer.Weight.get(i))/GT5OreLayerHelper.weightPerWorld[i]); - } - } - return weightedChance; - }*/ - - // Unused - public static String[] get_Cnames(OreLayerWrapper oreLayer) { - - String[] splt = coustomVeinRenamer(oreLayer).split("\\s"); - /*HashSet<String> h = new HashSet<String>(); - for (int i=0; i < splt.length;i++) { - h.add(splt[i]); - } - h.toArray(splt);*/ - - String[] ret = {oreLayer.veinName.replace("ore.mix.custom.", "") + " ", " ", " "}; - for (int i = 0; i < ret.length; i++) { - ret[i] = ret[i].trim(); - } - for (int i = 0; i < splt.length; i++) { - //FMLLog.info("Split:"+splt[i]); - //FMLLog.info("I:"+Integer.toString(i)); - if (ret[0].length() + splt[i].length() <= 20) - ret[0] = ret[0] + splt[i] + " "; - if ((ret[0].length() + splt[i].length() > 20) && ret[1].length() + splt[i].length() <= 70 && !ret[0].contains(splt[i])) - ret[1] = ret[1] + splt[i] + " "; - if ((ret[0].length() + splt[i].length() > 20) && (ret[1].length() + splt[i].length() > 70) && ret[2].length() + splt[i].length() <= 70 && !ret[1].contains(splt[i])) - ret[2] = ret[2] + splt[i] + " "; - } - for (int i = 0; i < ret.length; i++) { - ret[i] = ret[i].trim(); - } - - if (ret[2].isEmpty() && !ret[1].isEmpty()) - if (ret[1].length() <= 65) - ret[1] = ret[1] + " Vein"; - else - ret[2] = ret[2] + "Vein"; - else if (ret[1].isEmpty() && ret[2].isEmpty() && !ret[0].isEmpty()) - if (ret[0].length() <= 15) - ret[0] = ret[0] + " Vein"; - else - ret[1] = ret[1] + "Vein"; - else if (!(ret[1].isEmpty() && ret[2].isEmpty())) - ret[2] = ret[2] + "Vein"; - String[] ret2 = new String[2]; - if (ret[2].isEmpty() && !ret[1].isEmpty()) { - ret2[0] = ret[0]; - ret2[1] = ret[1]; - return ret2; - } - String[] ret1 = new String[1]; - if (ret[1].isEmpty() && ret[2].isEmpty() && !ret[0].isEmpty()) { - ret1[0] = ret[0]; - return ret1; - } else - return ret; - } - @Override public void loadCraftingRecipes(String outputId, Object... results) { if (outputId.equals(getOutputId())) { - OreLayerWrapper oreLayerWrapper; - for (String veinName : GT5OreLayerHelper.mapOreLayerWrapper.keySet()) { - oreLayerWrapper = GT5OreLayerHelper.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.Meta[0] + i * 1000)); - stackListSecondary.add(new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.Meta[1] + i * 1000)); - stackListBetween.add(new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.Meta[2] + i * 1000)); - stackListSporadic.add(new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.Meta[3] + i * 1000)); - } - this.arecipes.add(new CachedVeinStatRecipe(veinName, stackListPrimary, stackListSecondary, stackListBetween, stackListSporadic)); + for (OreLayerWrapper oreVein : getAllVeins()) { + addVeinWithLayers(oreVein, 7); } - } else - super.loadCraftingRecipes(outputId, results); + } 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.Meta[0] == baseMeta || worldGen.Meta[1] == baseMeta || worldGen.Meta[2] == baseMeta || worldGen.Meta[3] == 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 < getMaximumMaterialIndex(baseMeta, false); i++) { - stackListPrimary.add(new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.Meta[0] + i * 1000)); - stackListSecondary.add(new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.Meta[1] + i * 1000)); - stackListBetween.add(new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.Meta[2] + i * 1000)); - stackListSporadic.add(new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.Meta[3] + i * 1000)); - } - this.arecipes.add(new CachedVeinStatRecipe(worldGen.veinName, stackListPrimary, stackListSecondary, stackListBetween, stackListSporadic)); - } + loadMatchingVeins((short) (stack.getItemDamage() % 1000)); + } else super.loadCraftingRecipes(stack); + } + + private void loadMatchingVeins(short oreId) { + for (OreLayerWrapper oreVein : getAllVeins()) { + if (oreVein.containsOre(oreId)) { + addVeinWithLayers(oreVein, getMaximumMaterialIndex(oreId, false)); } - } else - super.loadCraftingRecipes(stack); + } + } + + private void addVeinWithLayers(OreLayerWrapper oreVein, int maximumMaterialIndex) { + this.arecipes.add(new CachedVeinStatRecipe( + oreVein.veinName, + oreVein.getVeinLayerOre(maximumMaterialIndex, VEIN_PRIMARY), + oreVein.getVeinLayerOre(maximumMaterialIndex, VEIN_SECONDARY), + oreVein.getVeinLayerOre(maximumMaterialIndex, VEIN_BETWEEN), + oreVein.getVeinLayerOre(maximumMaterialIndex, VEIN_SPORADIC))); + } + + private Collection<OreLayerWrapper> getAllVeins() { + return GT5OreLayerHelper.mapOreLayerWrapper.values(); } @Override public void drawExtras(int recipe) { - CachedVeinStatRecipe crecipe = (CachedVeinStatRecipe) this.arecipes.get(recipe); - OreLayerWrapper oreLayer = GT5OreLayerHelper.mapOreLayerWrapper.get(crecipe.veinName); + OreLayerWrapper oreLayer = getOreLayer(recipe); - String sDimNames = GT5OreLayerHelper.bufferedDims.get(oreLayer); + drawVeinName(oreLayer); + drawVeinLayerNames(oreLayer); + drawVeinInfo(oreLayer); - if(Loader.isModLoaded("visualprospecting")) { - GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + I18n.format(oreLayer.veinName) + " " + I18n.format("gtnop.gui.nei.vein"), 2, 20, 0x404040, false); - } - else { - if (getGTOreLocalizedName(oreLayer.Meta[0]).contains("Ore")) - GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getGTOreLocalizedName(oreLayer.Meta[0]).split("Ore")[0] + "" + I18n.format("gtnop.gui.nei.vein"), 2, 20, 0x404040, false); - else if (getGTOreLocalizedName(oreLayer.Meta[0]).contains("Sand")) - GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getGTOreLocalizedName(oreLayer.Meta[0]).split("Sand")[0] + "" + I18n.format("gtnop.gui.nei.vein"), 2, 20, 0x404040, false); - else - GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getGTOreLocalizedName(oreLayer.Meta[0]) + " " + I18n.format("gtnop.gui.nei.vein"), 2, 20, 0x404040, false); - } - - GuiDraw.drawString(I18n.format("gtnop.gui.nei.primaryOre") + ": " + getGTOreLocalizedName(oreLayer.Meta[0]), 2, 50, 0x404040, false); + String sDimNames = GT5OreLayerHelper.bufferedDims.get(oreLayer); + drawDimNames(sDimNames); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.secondaryOre") + ": " + getGTOreLocalizedName(oreLayer.Meta[1]), 2, 60, 0x404040, false); + drawSeeAllRecipesLabel(); + } - GuiDraw.drawString(I18n.format("gtnop.gui.nei.betweenOre") + ": " + getGTOreLocalizedName(oreLayer.Meta[2]), 2, 70, 0x404040, false); + private OreLayerWrapper getOreLayer(int recipe) { + CachedVeinStatRecipe crecipe = (CachedVeinStatRecipe) this.arecipes.get(recipe); + return GT5OreLayerHelper.mapOreLayerWrapper.get(crecipe.veinName); + } - GuiDraw.drawString(I18n.format("gtnop.gui.nei.sporadicOre") + ": " + getGTOreLocalizedName(oreLayer.Meta[3]), 2, 80, 0x404040, false); + private static void drawVeinName(OreLayerWrapper oreLayer) { + if (Loader.isModLoaded("visualprospecting")) { + drawVeinNameLine(I18n.format(oreLayer.veinName) + " "); + } else { + String veinName = getGTOreLocalizedName(oreLayer.Meta[VEIN_PRIMARY]); + if (veinName.contains("Ore")) drawVeinNameLine(veinName.split("Ore")[0]); + else if (veinName.contains("Sand")) drawVeinNameLine(veinName.split("Sand")[0]); + else drawVeinNameLine(veinName + " "); + } + } - GuiDraw.drawString(I18n.format("gtnop.gui.nei.genHeight") + ": " + oreLayer.worldGenHeightRange, 2, 90, 0x404040, false); + private static void drawVeinNameLine(String veinName) { + drawLine("gtnop.gui.nei.veinName", veinName + I18n.format("gtnop.gui" + ".nei.vein"), 2, 20); + } - GuiDraw.drawString(I18n.format("gtnop.gui.nei.weightedChance") + ": " + Integer.toString(oreLayer.randomWeight), 100, 90, 0x404040, false); + private static void drawVeinLayerNames(OreLayerWrapper oreLayer) { + drawVeinLayerNameLine(oreLayer, VEIN_PRIMARY, 50); + drawVeinLayerNameLine(oreLayer, VEIN_SECONDARY, 60); + drawVeinLayerNameLine(oreLayer, VEIN_BETWEEN, 70); + drawVeinLayerNameLine(oreLayer, VEIN_SPORADIC, 80); + } - drawDimNames(sDimNames); + private static void drawVeinLayerNameLine(OreLayerWrapper oreLayer, int veinLayer, int height) { + drawLine(getOreVeinLayerName(veinLayer), getGTOreLocalizedName(oreLayer.Meta[veinLayer]), 2, height); + } - //if (GT5OreLayerHelper.restrictBiomeSupport) GuiDraw.drawString(I18n.format("gtnop.gui.nei.restrictBiome") + ": " + getBiomeTranslated(oreLayer.restrictBiome), 2, 122, 0x404040, false); - drawSeeAllRecipesLabel(); + private static void drawVeinInfo(OreLayerWrapper oreLayer) { + drawLine("gtnop.gui.nei.genHeight", oreLayer.worldGenHeightRange, 2, 90); + drawLine("gtnop.gui.nei.weightedChance", Integer.toString(oreLayer.randomWeight), 100, 90); } @Override @@ -208,17 +110,16 @@ public class PluginGT5VeinStat extends PluginGT5Base { public String getRecipeName() { return I18n.format("gtnop.gui.veinStat.name"); } - + /** * The dimension names for a given recipe identifier - * + * * @param recipe identifier * @return A CSV string of dimension name abbreviations */ @Override - protected String getDimensionNames(int recipe) { - CachedVeinStatRecipe crecipe = (CachedVeinStatRecipe) this.arecipes.get(recipe); - OreLayerWrapper oreLayer = GT5OreLayerHelper.mapOreLayerWrapper.get(crecipe.veinName); + protected String getDimensionNames(int recipe) { + OreLayerWrapper oreLayer = getOreLayer(recipe); return GT5OreLayerHelper.bufferedDims.get(oreLayer); } @@ -229,8 +130,12 @@ public class PluginGT5VeinStat extends PluginGT5Base { public PositionedStack positionedStackBetween; public PositionedStack positionedStackSporadic; - public CachedVeinStatRecipe(String veinName, List<ItemStack> stackListPrimary, List<ItemStack> stackListSecondary, - List<ItemStack> stackListBetween, List<ItemStack> stackListSporadic) { + 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); @@ -240,15 +145,11 @@ public class PluginGT5VeinStat extends PluginGT5Base { @Override public List<PositionedStack> getIngredients() { - List<PositionedStack> ingredientsList = new ArrayList<PositionedStack>(); + List<PositionedStack> 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); @@ -260,7 +161,5 @@ public class PluginGT5VeinStat extends PluginGT5Base { public PositionedStack getResult() { return null; } - } - } |