diff options
Diffstat (limited to 'src/main/java/gregtech/api/util')
-rw-r--r-- | src/main/java/gregtech/api/util/GT_Recipe.java | 420 |
1 files changed, 361 insertions, 59 deletions
diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 81937c42f8..9af6e45885 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -1,13 +1,16 @@ package gregtech.api.util; import static gregtech.api.enums.GT_Values.*; +import static net.minecraft.util.EnumChatFormatting.GRAY; import codechicken.nei.PositionedStack; +import com.gtnewhorizons.modularui.api.GlStateManager; import com.gtnewhorizons.modularui.api.ModularUITextures; import com.gtnewhorizons.modularui.api.drawable.FallbackableUITexture; import com.gtnewhorizons.modularui.api.drawable.IDrawable; import com.gtnewhorizons.modularui.api.drawable.UITexture; import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable; +import com.gtnewhorizons.modularui.api.math.Alignment; import com.gtnewhorizons.modularui.api.math.Pos2d; import com.gtnewhorizons.modularui.api.math.Size; import com.gtnewhorizons.modularui.api.screen.ModularWindow; @@ -22,6 +25,7 @@ import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.*; import gregtech.api.enums.SteamVariant; +import gregtech.api.gui.GT_GUIColorOverride; import gregtech.api.gui.modularui.FallbackableSteamTexture; import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.gui.modularui.SteamTexture; @@ -33,7 +37,15 @@ import gregtech.api.objects.ItemData; import gregtech.api.objects.MaterialStack; import gregtech.api.util.extensions.ArrayExt; import gregtech.common.gui.modularui.UIHelper; +import gregtech.common.power.EUPower; +import gregtech.common.power.Power; +import gregtech.common.power.UnspecifiedEUPower; import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_Replicator; +import gregtech.nei.FusionSpecialValueFormatter; +import gregtech.nei.GT_NEI_DefaultHandler; +import gregtech.nei.HeatingCoilSpecialValueFormatter; +import gregtech.nei.INEISpecialInfoFormatter; +import gregtech.nei.NEIRecipeInfo; import ic2.core.Ic2Items; import java.awt.*; import java.util.*; @@ -41,12 +53,15 @@ import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Supplier; import javax.annotation.Nullable; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; @@ -739,6 +754,11 @@ public class GT_Recipe implements Comparable<GT_Recipe> { return neiDesc; } + /** + * Sets description shown on NEI. + * <br>If you have a large number of recipes for the recipemap, + * this is not efficient memory wise, so use {@link GT_Recipe_Map#setNEISpecialInfoFormatter} instead. + */ protected void setNeiDesc(String... neiDesc) { this.neiDesc = neiDesc; } @@ -1664,33 +1684,25 @@ public class GT_Recipe implements Comparable<GT_Recipe> { true) .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_BOXED) .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); - public static final GT_Recipe_Map sFusionRecipes = new GT_Recipe_Map( - new HashSet<>(50), - "gt.recipe.fusionreactor", - "Fusion Reactor", - null, - RES_PATH_GUI + "basicmachines/FusionReactor", - 0, - 0, - 0, - 2, - 1, - "Start: ", - 1, - " EU", - true, - true) { - @Override - public List<Pos2d> getFluidInputPositions(int fluidInputCount) { - return UIHelper.getItemInputPositions(fluidInputCount); - } - - @Override - public List<Pos2d> getFluidOutputPositions(int fluidOutputCount) { - return UIHelper.getItemOutputPositions(fluidOutputCount); - } - }.setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT) - .setUsualFluidInputCount(2); + public static final GT_Recipe_Map sFusionRecipes = new GT_Recipe_Map_FluidOnly( + new HashSet<>(50), + "gt.recipe.fusionreactor", + "Fusion Reactor", + null, + RES_PATH_GUI + "basicmachines/FusionReactor", + 0, + 0, + 0, + 2, + 1, + "Start: ", + 1, + " EU", + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT) + .setUsualFluidInputCount(2) + .setNEISpecialInfoFormatter(FusionSpecialValueFormatter.INSTANCE); public static final GT_Recipe_Map sComplexFusionRecipes = new GT_Recipe_Map_ComplexFusion( new HashSet<>(50), "gt.recipe.complexfusionreactor", @@ -1711,7 +1723,8 @@ public class GT_Recipe implements Comparable<GT_Recipe> { .setUsualFluidInputCount(16) .setUsualFluidOutputCount(16) .setNEITransferRect(new Rectangle(79, 34, 18, 18)) - .setLogoPos(80, 61); + .setLogoPos(80, 61) + .setNEISpecialInfoFormatter(FusionSpecialValueFormatter.INSTANCE); public static final GT_Recipe_Map sCentrifugeRecipes = new GT_Recipe_Map( new HashSet<>(1200), "gt.recipe.centrifuge", @@ -1768,7 +1781,8 @@ public class GT_Recipe implements Comparable<GT_Recipe> { " K", false, true) - .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT) + .setNEISpecialInfoFormatter(HeatingCoilSpecialValueFormatter.INSTANCE); public static final GT_Recipe_Map sPlasmaForgeRecipes = new GT_Recipe_Map_LargeNEI( new HashSet<>(20), "gt.recipe.plasmaforge", @@ -1787,7 +1801,8 @@ public class GT_Recipe implements Comparable<GT_Recipe> { true) .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT) .setUsualFluidInputCount(9) - .setUsualFluidOutputCount(9); + .setUsualFluidOutputCount(9) + .setNEISpecialInfoFormatter(HeatingCoilSpecialValueFormatter.INSTANCE); public static final GT_Recipe_Map sPrimitiveBlastRecipes = new GT_Recipe_Map( new HashSet<>(200), "gt.recipe.primitiveblastfurnace", @@ -1840,7 +1855,8 @@ public class GT_Recipe implements Comparable<GT_Recipe> { E, false, true) - .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT) + .setUsualFluidInputCount(2); public static final GT_Recipe_Map sChemicalRecipes = new GT_Recipe_Map( new HashSet<>(1170), "gt.recipe.chemicalreactor", @@ -2479,7 +2495,22 @@ public class GT_Recipe implements Comparable<GT_Recipe> { .useModularUI(true) .setUsualFluidInputCount(3) .setUsualFluidOutputCount(0) - .setProgressBar(GT_UITextures.PROGRESSBAR_ASSEMBLE, ProgressBar.Direction.RIGHT); + .setProgressBar(GT_UITextures.PROGRESSBAR_ASSEMBLE, ProgressBar.Direction.RIGHT) + .setNEISpecialInfoFormatter((recipeInfo, applyPrefixAndSuffix) -> { + List<String> result = new ArrayList<>(); + int bitmap = recipeInfo.recipe.mSpecialValue; + if ((bitmap & 0b1) > 0) { + result.add(GT_Utility.trans("336", "PCB Factory Tier: ") + 1); + } else if ((bitmap & 0b10) > 0) { + result.add(GT_Utility.trans("336", "PCB Factory Tier: ") + 2); + } else if ((bitmap & 0b100) > 0) { + result.add(GT_Utility.trans("336", "PCB Factory Tier: ") + 3); + } + if ((bitmap & 0b1000) > 0) { + result.add(GT_Utility.trans("337", "Upgrade Required: ") + GT_Utility.trans("338", "Bio")); + } + return result; + }); public static final GT_Recipe_Map_IC2NuclearFake sIC2NuclearFakeRecipe = new GT_Recipe_Map_IC2NuclearFake(); @@ -2625,6 +2656,11 @@ public class GT_Recipe implements Comparable<GT_Recipe> { public Size neiBackgroundSize = new Size(172, 82); + protected final GT_GUIColorOverride colorOverride; + private int neiTextColorOverride = -1; + + private INEISpecialInfoFormatter neiSpecialInfoFormatter; + /** * Initialises a new type of Recipe Handler. * @@ -2683,6 +2719,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { progressBarTexture = new FallbackableUITexture( UITexture.fullImage("gregtech", "gui/progressbar/" + mUnlocalizedName), GT_UITextures.PROGRESSBAR_ARROW); + colorOverride = GT_GUIColorOverride.get(ModularUITextures.VANILLA_BACKGROUND.location); if (sIndexedMappings.put(mUniqueIdentifier, this) != null) throw new IllegalArgumentException("Duplicate recipe map registered: " + mUniqueIdentifier); } @@ -2885,6 +2922,11 @@ public class GT_Recipe implements Comparable<GT_Recipe> { return this; } + public GT_Recipe_Map setNEISpecialInfoFormatter(INEISpecialInfoFormatter neiSpecialInfoFormatter) { + this.neiSpecialInfoFormatter = neiSpecialInfoFormatter; + return this; + } + public GT_Recipe addRecipe( boolean aOptimize, ItemStack[] aInputs, @@ -3491,6 +3533,284 @@ public class GT_Recipe implements Comparable<GT_Recipe> { return UIHelper.getFluidOutputPositions(fluidOutputCount); } + public void drawNEIDescription(NEIRecipeInfo recipeInfo) { + drawNEIEnergyInfo(recipeInfo); + drawNEIDurationInfo(recipeInfo); + drawNEISpecialInfo(recipeInfo); + drawNEIRecipeOwnerInfo(recipeInfo); + } + + protected void drawNEIEnergyInfo(NEIRecipeInfo recipeInfo) { + GT_Recipe recipe = recipeInfo.recipe; + Power power = recipeInfo.power; + if (power.getEuPerTick() > 0) { + drawNEIText(recipeInfo, GT_Utility.trans("152", "Total: ") + power.getTotalPowerString()); + + String amperage = power.getAmperageString(); + String powerUsage = power.getPowerUsageString(); + if (amperage == null || amperage.equals("unspecified") || powerUsage.contains("(OC)")) { + drawNEIText(recipeInfo, GT_Utility.trans("153", "Usage: ") + powerUsage); + if (GT_Mod.gregtechproxy.mNEIOriginalVoltage) { + Power originalPower = getPowerFromRecipeMap(); + if (!(originalPower instanceof UnspecifiedEUPower)) { + originalPower.computePowerUsageAndDuration(recipe.mEUt, recipe.mDuration); + drawNEIText( + recipeInfo, + GT_Utility.trans("275", "Original voltage: ") + originalPower.getVoltageString()); + } + } + if (amperage != null && !amperage.equals("unspecified") && !amperage.equals("1")) { + drawNEIText(recipeInfo, GT_Utility.trans("155", "Amperage: ") + amperage); + } + } else if (amperage.equals("1")) { + drawNEIText(recipeInfo, GT_Utility.trans("154", "Voltage: ") + power.getVoltageString()); + } else { + drawNEIText(recipeInfo, GT_Utility.trans("153", "Usage: ") + powerUsage); + drawNEIText(recipeInfo, GT_Utility.trans("154", "Voltage: ") + power.getVoltageString()); + drawNEIText(recipeInfo, GT_Utility.trans("155", "Amperage: ") + amperage); + } + } + } + + protected void drawNEIDurationInfo(NEIRecipeInfo recipeInfo) { + Power power = recipeInfo.power; + if (power.getDurationTicks() > 0) { + String textToDraw = GT_Utility.trans("158", "Time: "); + if (GT_Mod.gregtechproxy.mNEIRecipeSecondMode) { + textToDraw += power.getDurationStringSeconds(); + if (power.getDurationSeconds() <= 1.0d) { + textToDraw += String.format(" (%s)", power.getDurationStringTicks()); + } + } else { + textToDraw += power.getDurationStringTicks(); + } + drawNEIText(recipeInfo, textToDraw); + } + } + + protected void drawNEISpecialInfo(NEIRecipeInfo recipeInfo) { + String[] recipeDesc = recipeInfo.recipe.getNeiDesc(); + if (recipeDesc != null) { + for (String s : recipeDesc) { + drawOptionalNEIText(recipeInfo, s); + } + } else if (neiSpecialInfoFormatter != null) { + drawNEITextMultipleLines( + recipeInfo, neiSpecialInfoFormatter.format(recipeInfo, this::formatSpecialValue)); + } else { + drawOptionalNEIText(recipeInfo, getNEISpecialInfo(recipeInfo.recipe.mSpecialValue)); + } + } + + protected String getNEISpecialInfo(int specialValue) { + if (specialValue == -100 && GT_Mod.gregtechproxy.mLowGravProcessing) { + return GT_Utility.trans("159", "Needs Low Gravity"); + } else if (specialValue == -200 && GT_Mod.gregtechproxy.mEnableCleanroom) { + return GT_Utility.trans("160", "Needs Cleanroom"); + } else if (specialValue == -201) { + return GT_Utility.trans("206", "Scan for Assembly Line"); + } else if (specialValue == -300 && GT_Mod.gregtechproxy.mEnableCleanroom) { + return GT_Utility.trans("160.1", "Needs Cleanroom & LowGrav"); + } else if (specialValue == -400) { + return GT_Utility.trans("216", "Deprecated Recipe"); + } else if (hasSpecialValueFormat()) { + return formatSpecialValue(specialValue); + } + return null; + } + + private boolean hasSpecialValueFormat() { + return (GT_Utility.isStringValid(mNEISpecialValuePre)) || (GT_Utility.isStringValid(mNEISpecialValuePost)); + } + + protected String formatSpecialValue(int specialValue) { + return mNEISpecialValuePre + + GT_Utility.formatNumbers((long) specialValue * mNEISpecialValueMultiplier) + + mNEISpecialValuePost; + } + + protected void drawNEIRecipeOwnerInfo(NEIRecipeInfo recipeInfo) { + GT_Recipe recipe = recipeInfo.recipe; + if (GT_Mod.gregtechproxy.mNEIRecipeOwner) { + if (recipe.owners.size() > 1) { + drawNEIText( + recipeInfo, + EnumChatFormatting.ITALIC + + GT_Utility.trans("273", "Original Recipe by: ") + + recipe.owners.get(0).getName()); + for (int i = 1; i < recipe.owners.size(); i++) { + drawNEIText( + recipeInfo, + EnumChatFormatting.ITALIC + + GT_Utility.trans("274", "Modified by: ") + + recipe.owners.get(i).getName()); + } + } else if (recipe.owners.size() > 0) { + drawNEIText( + recipeInfo, + EnumChatFormatting.ITALIC + + GT_Utility.trans("272", "Recipe by: ") + + recipe.owners.get(0).getName()); + } + } + if (GT_Mod.gregtechproxy.mNEIRecipeOwnerStackTrace + && recipe.stackTraces != null + && !recipe.stackTraces.isEmpty()) { + drawNEIText(recipeInfo, "stackTrace:"); + // todo: good way to show all stacktraces + for (StackTraceElement stackTrace : recipe.stackTraces.get(0)) { + drawNEIText(recipeInfo, stackTrace.toString()); + } + } + } + + protected void drawNEIText(NEIRecipeInfo recipeInfo, String text) { + drawNEIText(recipeInfo, text, 10); + } + + /** + * Draws text on NEI recipe. + * @param yShift y position to shift after this text + */ + @SuppressWarnings("SameParameterValue") + protected void drawNEIText(NEIRecipeInfo recipeInfo, String text, int yShift) { + drawNEIText(recipeInfo, text, 10, yShift); + } + + /** + * Draws text on NEI recipe. + * @param xStart x position to start drawing + * @param yShift y position to shift after this text + */ + @SuppressWarnings("SameParameterValue") + protected void drawNEIText(NEIRecipeInfo recipeInfo, String text, int xStart, int yShift) { + Minecraft.getMinecraft() + .fontRenderer + .drawString( + text, + xStart, + recipeInfo.yPos, + neiTextColorOverride != -1 ? neiTextColorOverride : 0x000000); + recipeInfo.yPos += yShift; + } + + protected void drawOptionalNEIText(NEIRecipeInfo recipeInfo, String text) { + if (GT_Utility.isStringValid(text) && !text.equals("unspecified")) { + drawNEIText(recipeInfo, text, 10); + } + } + + protected void drawNEITextMultipleLines(NEIRecipeInfo recipeInfo, List<String> texts) { + for (String text : texts) { + drawNEIText(recipeInfo, text, 10); + } + } + + public List<String> handleNEIItemTooltip( + ItemStack stack, List<String> currentTip, GT_NEI_DefaultHandler.CachedDefaultRecipe neiCachedRecipe) { + for (PositionedStack pStack : neiCachedRecipe.mInputs) { + if (stack == pStack.item) { + if (pStack instanceof GT_NEI_DefaultHandler.FixedPositionedStack) { + currentTip = handleNEIItemInputTooltip( + currentTip, (GT_NEI_DefaultHandler.FixedPositionedStack) pStack); + } + break; + } + } + for (PositionedStack pStack : neiCachedRecipe.mOutputs) { + if (stack == pStack.item) { + if (pStack instanceof GT_NEI_DefaultHandler.FixedPositionedStack) { + currentTip = handleNEIItemOutputTooltip( + currentTip, (GT_NEI_DefaultHandler.FixedPositionedStack) pStack); + } + break; + } + } + return currentTip; + } + + protected List<String> handleNEIItemInputTooltip( + List<String> currentTip, GT_NEI_DefaultHandler.FixedPositionedStack pStack) { + if (pStack.isNotConsumed()) { + currentTip.add(GRAY + GT_Utility.trans("151", "Does not get consumed in the process")); + } + return currentTip; + } + + protected List<String> handleNEIItemOutputTooltip( + List<String> currentTip, GT_NEI_DefaultHandler.FixedPositionedStack pStack) { + if (pStack.isChanceBased()) { + currentTip.add(GRAY + GT_Utility.trans("150", "Chance: ") + pStack.getChanceText()); + } + return currentTip; + } + + public void drawNEIOverlays(GT_NEI_DefaultHandler.CachedDefaultRecipe neiCachedRecipe) { + for (PositionedStack stack : neiCachedRecipe.mInputs) { + if (stack instanceof GT_NEI_DefaultHandler.FixedPositionedStack) { + drawNEIOverlayForInput((GT_NEI_DefaultHandler.FixedPositionedStack) stack); + } + } + for (PositionedStack stack : neiCachedRecipe.mOutputs) { + if (stack instanceof GT_NEI_DefaultHandler.FixedPositionedStack) { + drawNEIOverlayForOutput((GT_NEI_DefaultHandler.FixedPositionedStack) stack); + } + } + } + + protected void drawNEIOverlayForInput(GT_NEI_DefaultHandler.FixedPositionedStack stack) { + if (stack.isNotConsumed()) { + drawNEIOverlayText("NC", stack); + } + } + + protected void drawNEIOverlayForOutput(GT_NEI_DefaultHandler.FixedPositionedStack stack) { + if (stack.isChanceBased()) { + drawNEIOverlayText(stack.getChanceText(), stack); + } + } + + @SuppressWarnings("SameParameterValue") + protected void drawNEIOverlayText( + String text, PositionedStack stack, int color, float scale, boolean shadow, Alignment alignment) { + FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; + int width = fontRenderer.getStringWidth(text); + int x = (int) ((stack.relx + 8 + 8 * alignment.x) / scale) - (width / 2 * (alignment.x + 1)); + int y = (int) ((stack.rely + 8 + 8 * alignment.y) / scale) + - (fontRenderer.FONT_HEIGHT / 2 * (alignment.y + 1)) + - (alignment.y - 1) / 2; + + GlStateManager.pushMatrix(); + GlStateManager.scale(scale, scale, 1); + fontRenderer.drawString(text, x, y, color, shadow); + GlStateManager.popMatrix(); + } + + protected void drawNEIOverlayText(String text, PositionedStack stack) { + drawNEIOverlayText( + text, + stack, + colorOverride.getTextColorOrDefault("nei_overlay_yellow", 0xFDD835), + 0.5f, + false, + Alignment.TopLeft); + } + + public void updateNEITextColorOverride() { + neiTextColorOverride = colorOverride.getTextColorOrDefault("nei", -1); + } + + public Power getPowerFromRecipeMap() { + // By default, assume generic EU LV power with no overclocks + Power power; + if (mShowVoltageAmperageInNEI) { + power = new EUPower((byte) 1, mAmperage); + } else { + power = new UnspecifiedEUPower((byte) 1, mAmperage); + } + return power; + } + /** * Use {@link #getItemInputPositions} or {@link #getSpecialItemPosition} or {@link #getFluidInputPositions} instead */ @@ -3562,24 +3882,22 @@ public class GT_Recipe implements Comparable<GT_Recipe> { @Override public List<Pos2d> getItemInputPositions(int itemInputCount) { - return UIHelper.getItemGridPositions(itemInputCount, 16, yOrigin, xDirMaxCount, 3); + return UIHelper.getGridPositions(itemInputCount, 16, yOrigin, xDirMaxCount); } @Override public List<Pos2d> getItemOutputPositions(int itemOutputCount) { - return UIHelper.getItemGridPositions(itemOutputCount, 106, yOrigin, xDirMaxCount, 3); + return UIHelper.getGridPositions(itemOutputCount, 106, yOrigin, xDirMaxCount); } @Override public List<Pos2d> getFluidInputPositions(int fluidInputCount) { - return UIHelper.getItemGridPositions( - fluidInputCount, 16, yOrigin + getItemRowCount() * 18, xDirMaxCount, 3); + return UIHelper.getGridPositions(fluidInputCount, 16, yOrigin + getItemRowCount() * 18, xDirMaxCount); } @Override public List<Pos2d> getFluidOutputPositions(int fluidOutputCount) { - return UIHelper.getItemGridPositions( - fluidOutputCount, 106, yOrigin + getItemRowCount() * 18, xDirMaxCount, 3); + return UIHelper.getGridPositions(fluidOutputCount, 106, yOrigin + getItemRowCount() * 18, xDirMaxCount); } @Override @@ -5306,7 +5624,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { null, RES_PATH_GUI + "basicmachines/Default", 1, - 0, + 1, 1, 0, 1, @@ -5885,20 +6203,12 @@ public class GT_Recipe implements Comparable<GT_Recipe> { @Override public List<Pos2d> getFluidInputPositions(int fluidInputCount) { - List<Pos2d> results = new ArrayList<>(); - for (int i = 0; i < fluidInputCount; i++) { - results.add(new Pos2d(7 + (i % 4) * 18, 9 + (i / 4) * 18)); - } - return results; + return UIHelper.getGridPositions(fluidInputCount, 7, 9, 4); } @Override public List<Pos2d> getFluidOutputPositions(int fluidOutputCount) { - List<Pos2d> results = new ArrayList<>(); - for (int i = 0; i < fluidOutputCount; i++) { - results.add(new Pos2d(97 + (i % 4) * 18, 9 + (i / 4) * 18)); - } - return results; + return UIHelper.getGridPositions(fluidOutputCount, 97, 9, 4); } } @@ -5941,11 +6251,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { @Override public List<Pos2d> getItemInputPositions(int itemInputCount) { - List<Pos2d> results = new ArrayList<>(); - for (int i = 0; i < itemInputCount; i++) { - results.add(new Pos2d(16 + (i % 4) * 18, 8 + (i / 4) * 18)); - } - return results; + return UIHelper.getGridPositions(itemInputCount, 16, 8, 4); } @Override @@ -5960,11 +6266,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { @Override public List<Pos2d> getFluidInputPositions(int fluidInputCount) { - List<Pos2d> results = new ArrayList<>(); - for (int i = 0; i < fluidInputCount; i++) { - results.add(new Pos2d(106, 8 + i * 18)); - } - return results; + return UIHelper.getGridPositions(fluidInputCount, 106, 8, 1); } @Override |