diff options
| author | YannickMG <yannickmg@gmail.com> | 2022-07-06 15:35:36 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-06 20:35:36 +0100 |
| commit | 7836eea57a199661e1ac4b41d9ae678e62588ee2 (patch) | |
| tree | ed9c71b33553fcdc58b52664b1efb3dbe4e3cb45 /src/main | |
| parent | 1cb11f470f296eb4db63174f7e58b17c7af7000d (diff) | |
| download | GT5-Unofficial-7836eea57a199661e1ac4b41d9ae678e62588ee2.tar.gz GT5-Unofficial-7836eea57a199661e1ac4b41d9ae678e62588ee2.tar.bz2 GT5-Unofficial-7836eea57a199661e1ac4b41d9ae678e62588ee2.zip | |
Enhanced NEI discoverability (#17)
* Removed unused code
* Addressed IDE warnings
* Refactored PluginGT5VeinStat::loadCraftingRecipes for readability
* Refactored PluginGT5VeinStat::drawExtras for readability
* Added OreVeinLayer class for the concept of ore layer
* Updated buildscript
* Ran spotlessApply
* Addressed some trivial IDE warnings
* Load both Small Ores and regular Ores when either is queried.
* Refactored PluginGT5SmallOreStat::loadCraftingRecipes for readability
* Refactored PluginGT5SmallOreStat::drawExtras for readability
Diffstat (limited to 'src/main')
17 files changed, 612 insertions, 550 deletions
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/Config.java b/src/main/java/pers/gwyog/gtneioreplugin/Config.java index c31ebc63a6..eedd953316 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/Config.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/Config.java @@ -1,9 +1,8 @@ package pers.gwyog.gtneioreplugin; import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.common.config.Configuration; - import java.io.File; +import net.minecraftforge.common.config.Configuration; public class Config { public Configuration tConfig; @@ -15,8 +14,6 @@ public class Config { } public void save() { - if (tConfig.hasChanged()) - tConfig.save(); + if (tConfig.hasChanged()) tConfig.save(); } - } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java b/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java index a324621a3b..3c0eb00eb4 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java @@ -11,7 +11,11 @@ import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper; import pers.gwyog.gtneioreplugin.util.GT5OreSmallHelper; import pers.gwyog.gtneioreplugin.util.GuiRecipeHelper; -@Mod(modid = GTNEIOrePlugin.MODID, name = GTNEIOrePlugin.NAME, version = GTNEIOrePlugin.VERSION, dependencies = "required-after:gregtech;required-after:NotEnoughItems") +@Mod( + modid = GTNEIOrePlugin.MODID, + name = GTNEIOrePlugin.NAME, + version = GTNEIOrePlugin.VERSION, + dependencies = "required-after:gregtech;required-after:NotEnoughItems") public class GTNEIOrePlugin { public static final String MODID = "GRADLETOKEN_MODID"; public static final String NAME = "GRADLETOKEN_MODNAME"; @@ -22,17 +26,36 @@ public class GTNEIOrePlugin { public static String CSVnameSmall; public static boolean toolTips = true; public static int maxTooltipLines = 11; + @Mod.Instance(MODID) public static GTNEIOrePlugin instance; @EventHandler public void preinit(FMLPreInitializationEvent event) { Config c = new Config(event, MODID + ".cfg"); - csv = c.tConfig.getBoolean("print csv", "ALL", false, "print csv, you need apache commons collections to be injected in the minecraft jar."); - CSVname = c.tConfig.getString("CSV_name", "ALL", event.getModConfigurationDirectory() + "/GTNH-Oresheet.csv", "rename the oresheet here, it will appear in /config"); - CSVnameSmall= c.tConfig.getString("CSV_name_for_Small_Ore_Sheet", "ALL", event.getModConfigurationDirectory() + "/GTNH-Small-Ores-Sheet.csv", "rename the oresheet here, it will appear in /config"); + csv = c.tConfig.getBoolean( + "print csv", + "ALL", + false, + "print csv, you need apache commons collections to be injected in the minecraft jar."); + CSVname = c.tConfig.getString( + "CSV_name", + "ALL", + event.getModConfigurationDirectory() + "/GTNH-Oresheet.csv", + "rename the oresheet here, it will appear in /config"); + CSVnameSmall = c.tConfig.getString( + "CSV_name_for_Small_Ore_Sheet", + "ALL", + event.getModConfigurationDirectory() + "/GTNH-Small-Ores-Sheet.csv", + "rename the oresheet here, it will appear in /config"); toolTips = c.tConfig.getBoolean("DimTooltip", "ALL", true, "Activates Dimension Tooltips"); - maxTooltipLines = c.tConfig.getInt("MaxToolTipLines", "ALL", 11, 1, Integer.MAX_VALUE, "Maximum number of lines the dimension names tooltip can have before it wraps around."); + maxTooltipLines = c.tConfig.getInt( + "MaxToolTipLines", + "ALL", + 11, + 1, + Integer.MAX_VALUE, + "Maximum number of lines the dimension names tooltip can have before it wraps around."); c.save(); } @@ -48,5 +71,4 @@ public class GTNEIOrePlugin { } } } - } 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) { - |
