diff options
author | Johann Bernhardt <johann.bernhardt@tum.de> | 2021-12-12 19:38:06 +0100 |
---|---|---|
committer | Johann Bernhardt <johann.bernhardt@tum.de> | 2021-12-12 19:38:06 +0100 |
commit | 311ab89f93558233a40079f7cb16605b141b5346 (patch) | |
tree | c5f44ef47f441a57c5f57aa801f639c7879ed760 /src/main/java/gtPlusPlus/nei | |
parent | 896143b96132f5ac54aa8d8f7386f27487e5e530 (diff) | |
download | GT5-Unofficial-311ab89f93558233a40079f7cb16605b141b5346.tar.gz GT5-Unofficial-311ab89f93558233a40079f7cb16605b141b5346.tar.bz2 GT5-Unofficial-311ab89f93558233a40079f7cb16605b141b5346.zip |
Move sources and resources
Diffstat (limited to 'src/main/java/gtPlusPlus/nei')
-rw-r--r-- | src/main/java/gtPlusPlus/nei/DecayableRecipeHandler.java | 264 | ||||
-rw-r--r-- | src/main/java/gtPlusPlus/nei/GTPP_NEI_DefaultHandler.java | 942 | ||||
-rw-r--r-- | src/main/java/gtPlusPlus/nei/GT_NEI_FlotationCell.java | 100 | ||||
-rw-r--r-- | src/main/java/gtPlusPlus/nei/GT_NEI_FluidReactor.java | 195 | ||||
-rw-r--r-- | src/main/java/gtPlusPlus/nei/GT_NEI_LFTR.java | 118 | ||||
-rw-r--r-- | src/main/java/gtPlusPlus/nei/GT_NEI_LFTR_Sparging.java | 372 | ||||
-rw-r--r-- | src/main/java/gtPlusPlus/nei/GT_NEI_MillingMachine.java | 136 | ||||
-rw-r--r-- | src/main/java/gtPlusPlus/nei/GT_NEI_MultiNoCell.java | 58 | ||||
-rw-r--r-- | src/main/java/gtPlusPlus/nei/NEI_GT_Config.java | 100 | ||||
-rw-r--r-- | src/main/java/gtPlusPlus/nei/NEI_IMC_Sender.java | 51 | ||||
-rw-r--r-- | src/main/java/gtPlusPlus/nei/handlers/NeiTextureHandler.java | 164 |
11 files changed, 2500 insertions, 0 deletions
diff --git a/src/main/java/gtPlusPlus/nei/DecayableRecipeHandler.java b/src/main/java/gtPlusPlus/nei/DecayableRecipeHandler.java new file mode 100644 index 0000000000..ce2062d12c --- /dev/null +++ b/src/main/java/gtPlusPlus/nei/DecayableRecipeHandler.java @@ -0,0 +1,264 @@ +package gtPlusPlus.nei; + +import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.gui.machine.GUI_DecayablesChest; +import gtPlusPlus.core.handler.Recipes.DecayableRecipe; +import gtPlusPlus.core.item.base.dusts.BaseItemDustUnique; +import gtPlusPlus.core.item.materials.DustDecayable; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.VanillaColours; +import gtPlusPlus.nei.handlers.NeiTextureHandler; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.resources.I18n; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; + +public class DecayableRecipeHandler extends TemplateRecipeHandler { + + public static final String mNEIName = "Decayables"; + + public String getRecipeName() { + return StatCollector.translateToLocal("GTPP.container.decaychest.name"); + } + + public String getGuiTexture() { + return CORE.MODID + ":textures/gui/nei/decayables.png"; + } + + public Class<? extends GuiContainer> getGuiClass() { + return GUI_DecayablesChest.class; + } + + public String getOverlayIdentifier() { + return "GTPP_Decayables"; + } + + public int recipiesPerPage() { + return 1; + } + + public void loadTransferRects() { + this.transferRects.add(new RecipeTransferRect(new Rectangle(6, 3, 16, 16), "GTPP_Decayables", new Object[0])); + } + + public void loadCraftingRecipes(ItemStack result) { + if (result == null || (!DustDecayable.class.isInstance(result.getItem()) + && !BaseItemDustUnique.class.isInstance(result.getItem()))) { + return; + } + if (result != null) { + //Logger.INFO("Looking up crafting recipes for "+ItemUtils.getItemName(result)); + } + final List<DecayableRecipe> recipes = DecayableRecipe.mRecipes; + for (final DecayableRecipe recipe : recipes) { + if (recipe.isValid()) { + final ItemStack input = recipe.mInput.copy(); + final ItemStack output = recipe.mOutput.copy(); + if (!GT_Utility.areStacksEqual(result, output, true)) { + continue; + } + //Logger.INFO("Showing Usage result for "+ItemUtils.getItemName(result)); + final DecayableRecipeNEI rec = new DecayableRecipeNEI(input, output, recipe.mTime); + this.arecipes.add(rec); + sort(); + } + } + } + + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getOverlayIdentifier()) && this.getClass() == DecayableRecipeHandler.class) { + final List<DecayableRecipe> recipes = DecayableRecipe.mRecipes; + for (final DecayableRecipe recipe : recipes) { + if (recipe.isValid()) { + final ItemStack input = recipe.mInput.copy(); + final ItemStack output = recipe.mOutput.copy(); + final DecayableRecipeNEI rec = new DecayableRecipeNEI(input, output, recipe.mTime); + this.arecipes.add(rec); + sort(); + } + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } + + public void loadUsageRecipes(ItemStack ingredient) { + final List<DecayableRecipe> recipes = DecayableRecipe.mRecipes; + if (ingredient != null) { + //Logger.INFO("Looking up Usage results for "+ItemUtils.getItemName(ingredient)); + } + for (final DecayableRecipe recipe : recipes) { + if (recipe.isValid()) { + final ItemStack input = recipe.mInput.copy(); + final ItemStack output = recipe.mOutput.copy(); + if (!GT_Utility.areStacksEqual(ingredient, input, true)) { + continue; + } + //Logger.INFO("Showing up Usage results for "+ItemUtils.getItemName(ingredient)); + final DecayableRecipeNEI rec = new DecayableRecipeNEI(input, output, recipe.mTime); + //rec.setIngredientPermutation((Collection) rec.input, ingredient); + this.arecipes.add(rec); + sort(); + } + } + } + + private final void sort() { + List<DecayableRecipeNEI> g = new ArrayList<DecayableRecipeNEI>(); + for (CachedRecipe u : arecipes) { + g.add((DecayableRecipeNEI) u); + } + if (g != null && !g.isEmpty()) { + Collections.sort(g); + } + } + + public void drawExtras(int recipeIndex) { + DecayableRecipeNEI recipe = (DecayableRecipeNEI) this.arecipes.get(recipeIndex); + + //GuiDraw.drawStringC(I18n.format("GTPP.container.decaychest.result", new Object[]{}), 43, 10, 8421504, false); + + int cost = recipe.time; + if (cost > 0) { + + // NEI Strings + String s = I18n.format("GTPP.nei.info", new Object[] { cost }); + String s0 = I18n.format("GTPP.nei.timetaken", new Object[] { cost }); + + // Time Strings + String s1 = I18n.format("GTPP.time.ticks", new Object[] { cost }); + String s2 = I18n.format("GTPP.time.seconds", new Object[] { cost }); + String s3 = I18n.format("GTPP.time.minutes", new Object[] { cost }); + String s4 = I18n.format("GTPP.time.hours", new Object[] { cost }); + String s5 = I18n.format("GTPP.time.days", new Object[] { cost }); + String s6 = I18n.format("GTPP.time.months", new Object[] { cost }); + int y = 20; + + int secs = cost / 20; + int mins = secs / 60; + int hours = mins / 60; + int days = hours / 24; + int months = days / 30; + + String suffix; + int formattedTime; + if (cost <= 20) { + suffix = s1; + formattedTime = cost; + } else if (cost <= (20 * 60)) { + suffix = s2; + formattedTime = secs; + } else if (cost <= (20 * 60 * 60)) { + suffix = s3; + formattedTime = mins; + } else if (cost <= (20 * 60 * 60 * 24)) { + suffix = s4; + formattedTime = hours; + } else if (cost < (20 * 60 * 60 * 24 * 30)) { + suffix = s5; + formattedTime = days; + } else if (cost <= (20 * 60 * 60 * 24 * 30)) { + suffix = s6; + formattedTime = months; + } else { + suffix = s1; + formattedTime = cost; + } + + int x = 5; + GuiDraw.drawString(s, x, 25, VanillaColours.DYE_BLACK.getAsInt(), false); + GuiDraw.drawString(s0, x, 40, VanillaColours.DYE_BLACK.getAsInt(), false); + + GuiDraw.drawString(suffix, x + 16, y + 30, VanillaColours.DYE_BLACK.getAsInt(), false); + + //Values + GuiDraw.drawString(("" + formattedTime), x, y + 30, VanillaColours.DYE_GREEN.getAsInt(), false); + + if (hours > 1) { + int aLeftoverMinutes = (cost - (hours * (20 * 60 * 60))); + if (aLeftoverMinutes > 0) { + int secs2 = aLeftoverMinutes / 20; + int mins2 = secs2 / 60; + GuiDraw.drawString(s3, x + 16, y + 42, VanillaColours.DYE_BLACK.getAsInt(), false); + GuiDraw.drawString(("" + mins2), x, y + 42, VanillaColours.DYE_GREEN.getAsInt(), false); + + } + + } + + } + + NeiTextureHandler.RECIPE_BUTTON.renderIcon(6.0D, 3.0D, 16.0D, 16.0D, 0.0D, true); + } + + public class DecayableRecipeNEI extends TemplateRecipeHandler.CachedRecipe implements Comparable<CachedRecipe> { + private PositionedStack input; + private PositionedStack output; + public int time; + + @Override + public PositionedStack getIngredient() { + return this.input; + } + + public PositionedStack getResult() { + return this.output; + } + + public DecayableRecipeNEI(final ItemStack input, final ItemStack result, final int time) { + super(); + this.input = new PositionedStack(input, 93, 24); + this.output = new PositionedStack(result, 142, 42); + this.time = time; + } + + @Override + public int compareTo(CachedRecipe o) { + boolean b = DecayableRecipeNEI.class.isInstance(o); + if (b) { + DecayableRecipeNEI p = (DecayableRecipeNEI) o; + if (p.time > this.time) { + return 1; + } else if (p.time == this.time) { + return 0; + } else { + return -1; + } + } + return 0; + } + + @Override + public boolean equals(Object obj) { + if (obj != null) { + if (DecayableRecipeNEI.class.isInstance(obj)) { + DecayableRecipeNEI p = (DecayableRecipeNEI) obj; + if (p != null) { + // Time check first to keep it simple and not unbox the Recipes. + if (p.time == this.time) { + ItemStack aInput = p.input.item; + ItemStack aOutput = p.output.item; + if (GT_Utility.areStacksEqual(aInput, this.input.item, true)) { + if (GT_Utility.areStacksEqual(aOutput, this.output.item, true)) { + return true; + } + } + } + } + + } + } + return false; + } + + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/nei/GTPP_NEI_DefaultHandler.java b/src/main/java/gtPlusPlus/nei/GTPP_NEI_DefaultHandler.java new file mode 100644 index 0000000000..de2c29db9f --- /dev/null +++ b/src/main/java/gtPlusPlus/nei/GTPP_NEI_DefaultHandler.java @@ -0,0 +1,942 @@ +package gtPlusPlus.nei; + +import java.awt.Point; +import java.awt.Rectangle; +import java.lang.ref.SoftReference; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; + +import org.lwjgl.opengl.GL11; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.PositionedStack; +import codechicken.nei.guihook.GuiContainerManager; +import codechicken.nei.guihook.IContainerInputHandler; +import codechicken.nei.guihook.IContainerTooltipHandler; +import codechicken.nei.recipe.GuiCraftingRecipe; +import codechicken.nei.recipe.GuiRecipe; +import codechicken.nei.recipe.GuiUsageRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; +import cpw.mods.fml.common.event.FMLInterModComms; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.gui.GT_GUIContainer_BasicMachine; +import gregtech.api.objects.ItemData; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.core.util.math.MathUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class GTPP_NEI_DefaultHandler extends TemplateRecipeHandler { + + public static final int sOffsetX = 5; + public static final int sOffsetY = 11; + private SoftReference<List<CachedDefaultRecipe>> mCachedRecipes = null; + + private static final HashMap<Integer, Pair<Integer, Integer>> mInputSlotMap = new HashMap<Integer, Pair<Integer, Integer>>(); + private static final HashMap<Integer, Pair<Integer, Integer>> mOutputSlotMap = new HashMap<Integer, Pair<Integer, Integer>>(); + + static { + GuiContainerManager.addInputHandler(new GT_RectHandler()); + GuiContainerManager.addTooltipHandler(new GT_RectHandler()); + int[] aSlotX = new int[] {12, 30, 48}; + int[] aSlotY = new int[] {5, 23, 41, 64}; + // Input slots + int aIndex = 0; + for (int y=0; y<aSlotY.length;y++) { + for (int x=0; x<aSlotX.length;x++) { + mInputSlotMap.put(aIndex++, new Pair<Integer, Integer>(aSlotX[x], aSlotY[y])); + } + } + // Output slots + aSlotX = new int[] {102, 120, 138}; + aIndex = 0; + for (int y=0; y<aSlotY.length;y++) { + for (int x=0; x<aSlotX.length;x++) { + mOutputSlotMap.put(aIndex++, new Pair<Integer, Integer>(aSlotX[x], aSlotY[y])); + } + } + } + + protected final GT_Recipe_Map mRecipeMap; + + public GTPP_NEI_DefaultHandler(final GT_Recipe_Map tMap) { + this.mRecipeMap = tMap; + this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(65, 13, 36, 18), this.getOverlayIdentifier(), new Object[0])); + if (!NEI_GT_Config.sIsAdded) { + FMLInterModComms.sendRuntimeMessage(GT_Values.GT, "NEIPlugins", "register-crafting-handler", "gregtechplusplus@" + this.getRecipeName() + "@" + this.getOverlayIdentifier()); + GuiCraftingRecipe.craftinghandlers.add(this); + GuiUsageRecipe.usagehandlers.add(this); + } + } + + public static void drawText(final int aX, final int aY, final String aString, final int aColor) { + Minecraft.getMinecraft().fontRenderer.drawString(aString, aX, aY, aColor); + } + + @Override + public TemplateRecipeHandler newInstance() { + return new GTPP_NEI_DefaultHandler(this.mRecipeMap); + } + + + public List<GT_Recipe> getSortedRecipes() { + List<GT_Recipe> result = new ArrayList<>(this.mRecipeMap.mRecipeList); + Collections.sort(result); + return result; + } + + public List<CachedDefaultRecipe> getCache() { + List<CachedDefaultRecipe> cache; + if (mCachedRecipes == null || (cache = mCachedRecipes.get()) == null) { + cache = mRecipeMap.mRecipeList.stream() // do not use parallel stream. This is already parallelized by NEI + .filter(r -> !r.mHidden) + .sorted() + .map(temp -> {return createCachedRecipe(temp);}) + .collect(Collectors.toList()); + // while the NEI parallelize handlers, for each individual handler it still uses sequential execution model + // so we do not need any synchronization here + mCachedRecipes = new SoftReference<>(cache); + } + return cache; + } + + public CachedDefaultRecipe createCachedRecipe(GT_Recipe aRecipe) { + return new CachedDefaultRecipe(aRecipe); + } + + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getOverlayIdentifier())) { + arecipes.addAll(getCache()); + } else { + super.loadCraftingRecipes(outputId, results); + } + } + + public void loadCraftingRecipes(ItemStack aResult) { + ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aResult); + + ArrayList<ItemStack> tResults = new ArrayList<>(); + tResults.add(aResult); + tResults.add(GT_OreDictUnificator.get(true, aResult)); + if ((tPrefixMaterial != null) && (!tPrefixMaterial.mBlackListed) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) { + for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { + tResults.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); + } + } + FluidStack tFluid = GT_Utility.getFluidForFilledItem(aResult, true); + FluidStack tFluidStack; + if (tFluid != null) { + tFluidStack = tFluid; + tResults.add(GT_Utility.getFluidDisplayStack(tFluid, false)); + } + else tFluidStack = GT_Utility.getFluidFromDisplayStack(aResult); + if (tFluidStack != null) { + tResults.addAll(GT_Utility.getContainersFromFluid(tFluidStack)); + } + for (CachedDefaultRecipe recipe : getCache()) { + if (tResults.stream().anyMatch(stack -> recipe.contains(recipe.mOutputs, stack))) + arecipes.add(recipe); + } + } + + public void loadUsageRecipes(ItemStack aInput) { + ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aInput); + + ArrayList<ItemStack> tInputs = new ArrayList<>(); + tInputs.add(aInput); + tInputs.add(GT_OreDictUnificator.get(false, aInput)); + if ((tPrefixMaterial != null) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) { + for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { + tInputs.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); + } + } + FluidStack tFluid = GT_Utility.getFluidForFilledItem(aInput, true); + FluidStack tFluidStack; + if (tFluid != null) { + tFluidStack = tFluid; + tInputs.add(GT_Utility.getFluidDisplayStack(tFluid, false)); + } + else tFluidStack = GT_Utility.getFluidFromDisplayStack(aInput); + if (tFluidStack != null) { + tInputs.addAll(GT_Utility.getContainersFromFluid(tFluidStack)); + } + for (CachedDefaultRecipe recipe : getCache()) { + if (tInputs.stream().anyMatch(stack -> recipe.contains(recipe.mInputs, stack))) + arecipes.add(recipe); + } + } + + @Override + public String getOverlayIdentifier() { + return this.mRecipeMap.mNEIName; + } + + @Override + public void drawBackground(final int recipe) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(this.getGuiTexture()); + GuiDraw.drawTexturedModalRect(-4, -8, 1, 3, 174, 78); + } + + @Override + public int recipiesPerPage() { + return 1; + } + + @Override + public String getRecipeName() { + return GT_LanguageManager.getTranslation(this.mRecipeMap.mUnlocalizedName); + } + + @Override + public String getGuiTexture() { + return this.mRecipeMap.mNEIGUIPath; + } + + @Override + public List<String> handleItemTooltip(final GuiRecipe gui, final ItemStack aStack, final List<String> currenttip, final int aRecipeIndex) { + final TemplateRecipeHandler.CachedRecipe tObject = this.arecipes.get(aRecipeIndex); + if ((tObject instanceof CachedDefaultRecipe)) { + final CachedDefaultRecipe tRecipe = (CachedDefaultRecipe) tObject; + for (final PositionedStack tStack : tRecipe.mOutputs) { + if (aStack == tStack.item) { + if ((!(tStack instanceof FixedPositionedStack)) || (((FixedPositionedStack) tStack).mChance <= 0) || (((FixedPositionedStack) tStack).mChance == 10000)) { + break; + } + currenttip.add("Chance: " + (((FixedPositionedStack) tStack).mChance / 100) + "." + ((((FixedPositionedStack) tStack).mChance % 100) < 10 ? "0" + (((FixedPositionedStack) tStack).mChance % 100) : Integer.valueOf(((FixedPositionedStack) tStack).mChance % 100)) + "%"); + break; + } + } + for (final PositionedStack tStack : tRecipe.mInputs) { + if (aStack == tStack.item) { + if ((gregtech.api.enums.ItemList.Display_Fluid.isStackEqual(tStack.item, true, true)) || + (tStack.item.stackSize != 0)) { + break; + } + currenttip.add("Does not get consumed in the process"); + break; + } + } + } + return currenttip; + } + + @Override + public void drawExtras(final int aRecipeIndex) { + final long tEUt = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mEUt; + final long tDuration = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mDuration; + if (tEUt != 0) { + drawText(10, 73, "Total: " + MathUtils.formatNumbers((long) (tDuration * tEUt)) + " EU", -16777216); + drawText(10, 83, "Usage: " + MathUtils.formatNumbers(tEUt) + " EU/t", -16777216); + if (this.mRecipeMap.mShowVoltageAmperageInNEI) { + drawText(10, 93, "Voltage: " + MathUtils.formatNumbers(tEUt / this.mRecipeMap.mAmperage) + " EU", -16777216); + drawText(10, 103, "Amperage: " + this.mRecipeMap.mAmperage, -16777216); + } else { + drawText(10, 93, "Voltage: unspecified", -16777216); + drawText(10, 103, "Amperage: unspecified", -16777216); + } + } + if (tDuration > 0) { + drawText(10, 113, "Time: " + (tDuration < 20 ? "< 1" : MathUtils.formatNumbers(Long.valueOf(tDuration / 20))) + " secs", -16777216); + } + if ((GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePre)) || (GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePost))) { + drawText(10, 123, this.mRecipeMap.mNEISpecialValuePre + (((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue * this.mRecipeMap.mNEISpecialValueMultiplier) + this.mRecipeMap.mNEISpecialValuePost, -16777216); + } + } + + public static class GT_RectHandler + implements IContainerInputHandler, IContainerTooltipHandler { + @Override + public boolean mouseClicked(final GuiContainer gui, final int mousex, final int mousey, final int button) { + if (this.canHandle(gui)) { + if (button == 0) { + return this.transferRect(gui, false); + } + if (button == 1) { + return this.transferRect(gui, true); + } + } + return false; + } + + @Override + public boolean lastKeyTyped(final GuiContainer gui, final char keyChar, final int keyCode) { + return false; + } + + public boolean canHandle(final GuiContainer gui) { + return (((gui instanceof GT_GUIContainer_BasicMachine)) && (GT_Utility.isStringValid(((GT_GUIContainer_BasicMachine) gui).mNEI))); + } + + @Override + public List<String> handleTooltip(final GuiContainer gui, final int mousex, final int mousey, final List<String> currenttip) { + if ((this.canHandle(gui)) && (currenttip.isEmpty())) { + if ((gui instanceof GT_GUIContainer_BasicMachine) && new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + currenttip.add("Recipes"); + } + } + return currenttip; + } + + private boolean transferRect(final GuiContainer gui, final boolean usage) { + if (gui instanceof GT_GUIContainer_BasicMachine) { + return (this.canHandle(gui)) && (new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI, new Object[0]) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI, new Object[0])); + } + return false; + } + + @Override + public List<String> handleItemDisplayName(final GuiContainer gui, final ItemStack itemstack, final List<String> currenttip) { + return currenttip; + } + + @Override + public List<String> handleItemTooltip(final GuiContainer gui, final ItemStack itemstack, final int mousex, final int mousey, final List<String> currenttip) { + return currenttip; + } + + @Override + public boolean keyTyped(final GuiContainer gui, final char keyChar, final int keyCode) { + return false; + } + + @Override + public void onKeyTyped(final GuiContainer gui, final char keyChar, final int keyID) { + } + + @Override + public void onMouseClicked(final GuiContainer gui, final int mousex, final int mousey, final int button) { + } + + @Override + public void onMouseUp(final GuiContainer gui, final int mousex, final int mousey, final int button) { + } + + @Override + public boolean mouseScrolled(final GuiContainer gui, final int mousex, final int mousey, final int scrolled) { + return false; + } + + @Override + public void onMouseScrolled(final GuiContainer gui, final int mousex, final int mousey, final int scrolled) { + } + + @Override + public void onMouseDragged(final GuiContainer gui, final int mousex, final int mousey, final int button, final long heldTime) { + } + } + + public class FixedPositionedStack + extends PositionedStack { + public final int mChance; + public boolean permutated = false; + + public FixedPositionedStack(final Object object, final int x, final int y) { + this(object, x, y, 0); + } + + public FixedPositionedStack(final Object object, final int x, final int y, final int aChance) { + super(object, x, y, true); + this.mChance = aChance; + } + + @Override + public void generatePermutations() { + if (this.permutated) { + return; + } + final ArrayList<ItemStack> tDisplayStacks = new ArrayList<ItemStack>(); + for (final ItemStack tStack : this.items) { + if (GT_Utility.isStackValid(tStack)) { + if (tStack.getItemDamage() == 32767) { + final List<ItemStack> permutations = codechicken.nei.ItemList.itemMap.get(tStack.getItem()); + if (!permutations.isEmpty()) { + ItemStack stack; + for (final Iterator<ItemStack> i$ = permutations.iterator(); i$.hasNext(); tDisplayStacks.add(GT_Utility.copyAmount(tStack.stackSize, new Object[]{stack}))) { + stack = i$.next(); + } + } else { + final ItemStack base = new ItemStack(tStack.getItem(), tStack.stackSize); + base.stackTagCompound = tStack.stackTagCompound; + tDisplayStacks.add(base); + } + } else { + tDisplayStacks.add(GT_Utility.copy(new Object[]{tStack})); + } + } + } + this.items = (tDisplayStacks.toArray(new ItemStack[0])); + if (this.items.length == 0) { + this.items = new ItemStack[]{new ItemStack(Blocks.fire)}; + } + this.permutated = true; + this.setPermutationToRender(0); + } + } + + public class CachedDefaultRecipe extends TemplateRecipeHandler.CachedRecipe { + public final GT_Recipe mRecipe; + public final List<PositionedStack> mOutputs = new ArrayList<PositionedStack>(); + public final List<PositionedStack> mInputs = new ArrayList<PositionedStack>(); + + public CachedDefaultRecipe(final GT_Recipe aRecipe) { + super(); + this.mRecipe = aRecipe; + handleSlots(); + } + + public void handleSlots() { + int tStartIndex = 0; + switch (GTPP_NEI_DefaultHandler.this.mRecipeMap.mUsualInputCount) { + case 0: + break; + case 1: + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + break; + case 2: + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + break; + case 3: + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 12, 14)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + break; + case 4: + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 30, 5)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 48, 5)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 30, 23)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 48, 23)); + } + tStartIndex++; + break; + case 5: + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 12, 5)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 30, 5)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 48, 5)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 30, 23)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 48, 23)); + } + tStartIndex++; + break; + case 6: + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 12, 5)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 30, 5)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 48, 5)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 12, 23)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 30, 23)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 48, 23)); + } + tStartIndex++; + break; + case 7: + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 12, -4)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 30, -4)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 48, -4)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 12, 14)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 12, 32)); + } + tStartIndex++; + break; + case 8: + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 12, -4)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 30, -4)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 48, -4)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 12, 14)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 12, 32)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 30, 32)); + } + tStartIndex++; + break; + default: + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 12, -4)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 30, -4)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 48, -4)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 12, 14)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 12, 32)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 30, 32)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 48, 32)); + } + tStartIndex++; + } + if (mRecipe.mSpecialItems != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.mSpecialItems, 120, 52)); + } + tStartIndex = 0; + switch (GTPP_NEI_DefaultHandler.this.mRecipeMap.mUsualOutputCount) { + case 0: + break; + case 1: + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, 14, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 2: + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, 14, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 120, 14, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 3: + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, 14, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 120, 14, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 138, 14, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 4: + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, 5, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 120, 5, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, 23, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 120, 23, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 5: + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, 5, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 120, 5, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 138, 5, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, 23, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 120, 23, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 6: + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, 5, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 120, 5, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 138, 5, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, 23, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 120, 23, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 138, 23, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 7: + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, -4, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 120, -4, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 138, -4, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, 14, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 120, 14, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 138, 14, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, 32, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 8: + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, -4, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 120, -4, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 138, -4, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, 14, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 120, 14, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 138, 14, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, 32, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 120, 32, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + default: + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, -4, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 120, -4, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 138, -4, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, 14, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 120, 14, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 138, 14, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, 32, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 120, 32, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 138, 32, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + } + + + if ((mRecipe.mFluidInputs.length > 0) && (mRecipe.mFluidInputs[0] != null) && (mRecipe.mFluidInputs[0].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidInputs[0], true), 48, 52)); + if ((mRecipe.mFluidInputs.length > 1) && (mRecipe.mFluidInputs[1] != null) && (mRecipe.mFluidInputs[1].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidInputs[1], true), 30, 52)); + } + } + if (mRecipe.mFluidOutputs.length > 1) { + if (mRecipe.mFluidOutputs[0] != null && (mRecipe.mFluidOutputs[0].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidOutputs[0], true), 120, 5)); + } + if (mRecipe.mFluidOutputs[1] != null && (mRecipe.mFluidOutputs[1].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidOutputs[1], true), 138, 5)); + } + if (mRecipe.mFluidOutputs.length > 2 && mRecipe.mFluidOutputs[2] != null && (mRecipe.mFluidOutputs[2].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidOutputs[2], true), 102, 23)); + } + if (mRecipe.mFluidOutputs.length > 3 && mRecipe.mFluidOutputs[3] != null && (mRecipe.mFluidOutputs[3].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidOutputs[3], true), 120, 23)); + } + if (mRecipe.mFluidOutputs.length > 4 && mRecipe.mFluidOutputs[4] != null && (mRecipe.mFluidOutputs[4].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidOutputs[4], true), 138, 23)); + } + } else if ((mRecipe.mFluidOutputs.length > 0) && (mRecipe.mFluidOutputs[0] != null) && (mRecipe.mFluidOutputs[0].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidOutputs[0], true), 102, 52)); + } + } + + @Override + public List<PositionedStack> getIngredients() { + return this.getCycledIngredients(GTPP_NEI_DefaultHandler.this.cycleticks / 10, this.mInputs); + } + + @Override + public PositionedStack getResult() { + return null; + } + + @Override + public List<PositionedStack> getOtherStacks() { + return this.mOutputs; + } + } + + public class NoCellMultiDefaultRecipe extends CachedDefaultRecipe { + + public NoCellMultiDefaultRecipe(final GT_Recipe aRecipe) { + super(aRecipe); + + } + + @Override + public void handleSlots() { + + int aInputItemsCount = this.mRecipe.mInputs.length; + int aInputFluidsCount = this.mRecipe.mFluidInputs.length; + int aOutputItemsCount = this.mRecipe.mOutputs.length; + int aOutputFluidsCount = this.mRecipe.mFluidOutputs.length; + int aInputSlotsUsed = 0; + int aOutputSlotsUsed = 0; + int aSlotToCheck = 0; + + // Special Slot + if (mRecipe.mSpecialItems != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.mSpecialItems, 120, 52)); + } + + /* + * Items + */ + + // Upto 9 Inputs Slots + if (aInputItemsCount > 0) { + if (aInputItemsCount > 9) { + aInputItemsCount = 9; + } + for (int i=0;i<aInputItemsCount;i++) { + int x = mInputSlotMap.get(aInputSlotsUsed).getKey(); + int y = mInputSlotMap.get(aInputSlotsUsed).getValue(); + ItemStack aRepStack = mRecipe.getRepresentativeInput(aSlotToCheck++); + if (aRepStack != null) { + this.mInputs.add(new FixedPositionedStack(aRepStack, x, y)); + aInputSlotsUsed++; + } + } + } + aSlotToCheck = 0; + // Upto 9 Output Slots + if (aOutputItemsCount > 0) { + if (aOutputItemsCount > 9) { + aOutputItemsCount = 9; + } + for (int i=0;i<aOutputItemsCount;i++) { + int x = mOutputSlotMap.get(aOutputSlotsUsed).getKey(); + int y = mOutputSlotMap.get(aOutputSlotsUsed).getValue(); + ItemStack aRepStack = mRecipe.getOutput(aSlotToCheck++); + if (aRepStack != null) { + this.mOutputs.add(new FixedPositionedStack(aRepStack, x, y, mRecipe.getOutputChance(aSlotToCheck))); + aOutputSlotsUsed++; + } + } + } + + /* + * Fluids + */ + + // Upto 9 Fluid Inputs Slots + aSlotToCheck = aInputSlotsUsed; + if (aInputFluidsCount > 0) { + for (int i=0;i<aInputFluidsCount;i++) { + int x = mInputSlotMap.get(aSlotToCheck).getKey(); + int y = mInputSlotMap.get(aSlotToCheck).getValue(); + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidInputs[i], true), x, y)); + aSlotToCheck++; + aInputSlotsUsed++; + } + } + // Upto 9 Fluid Outputs Slots + aSlotToCheck = aOutputSlotsUsed; + if (aOutputFluidsCount > 0) { + for (int i=0;i<aOutputFluidsCount;i++) { + int x = mOutputSlotMap.get(aSlotToCheck).getKey(); + int y = mOutputSlotMap.get(aSlotToCheck).getValue(); + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidOutputs[i], true), x, y)); + aSlotToCheck++; + aOutputSlotsUsed++; + } + } + } + } +} diff --git a/src/main/java/gtPlusPlus/nei/GT_NEI_FlotationCell.java b/src/main/java/gtPlusPlus/nei/GT_NEI_FlotationCell.java new file mode 100644 index 0000000000..ca12e1c740 --- /dev/null +++ b/src/main/java/gtPlusPlus/nei/GT_NEI_FlotationCell.java @@ -0,0 +1,100 @@ +package gtPlusPlus.nei; + +import codechicken.nei.recipe.TemplateRecipeHandler; +import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; + +public class GT_NEI_FlotationCell extends GTPP_NEI_DefaultHandler { + + public GT_NEI_FlotationCell() { + super(GTPP_Recipe_Map.sFlotationCellRecipes); + } + + @Override + public TemplateRecipeHandler newInstance() { + return new GT_NEI_FlotationCell(); + } + + @Override + public CachedDefaultRecipe createCachedRecipe(GT_Recipe aRecipe) { + return new FlotationCellDefaultRecipe(aRecipe); + } + + public class FlotationCellDefaultRecipe extends CachedDefaultRecipe { + + public FlotationCellDefaultRecipe(final GT_Recipe aRecipe) { + super(aRecipe); + } + + @Override + public void handleSlots() { + int tStartIndex = 0; + + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 12, 5)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 30, 5)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 48, 5)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 12, 23)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 30, 23)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 48, 23)); + } + tStartIndex++; + + if (mRecipe.mSpecialItems != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.mSpecialItems, 120, 52)); + } + tStartIndex = 0; + + //Four Output Slots + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, 5, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 120, 5, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, 23, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 120, 23, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + + if ((mRecipe.mFluidInputs.length > 0) && (mRecipe.mFluidInputs[0] != null) && (mRecipe.mFluidInputs[0].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidInputs[0], true), 30, 52)); + if ((mRecipe.mFluidInputs.length > 1) && (mRecipe.mFluidInputs[1] != null) && (mRecipe.mFluidInputs[1].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidInputs[1], true), 48, 52)); + } + } + + if (mRecipe.mFluidOutputs.length > 0) { + if ((mRecipe.mFluidOutputs[0] != null) && (mRecipe.mFluidOutputs[0].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidOutputs[0], true), 102, 52)); + } + if ((mRecipe.mFluidOutputs.length > 1) && (mRecipe.mFluidOutputs[1] != null) && (mRecipe.mFluidOutputs[1].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidOutputs[1], true), 120, 52)); + } + } + } + + } +} diff --git a/src/main/java/gtPlusPlus/nei/GT_NEI_FluidReactor.java b/src/main/java/gtPlusPlus/nei/GT_NEI_FluidReactor.java new file mode 100644 index 0000000000..7ef76f68b2 --- /dev/null +++ b/src/main/java/gtPlusPlus/nei/GT_NEI_FluidReactor.java @@ -0,0 +1,195 @@ +package gtPlusPlus.nei; + +import java.util.List; + +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.GuiRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; +import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.item.ItemStack; + +public class GT_NEI_FluidReactor extends GTPP_NEI_DefaultHandler { + + public GT_NEI_FluidReactor() { + super(GTPP_Recipe_Map.sChemicalPlantRecipes); + } + + @Override + public TemplateRecipeHandler newInstance() { + return new GT_NEI_FluidReactor(); + } + + @Override + public CachedDefaultRecipe createCachedRecipe(GT_Recipe aRecipe) { + return new ChemPlantDefaultRecipe(aRecipe); + } + + @Override + public List<String> handleItemTooltip(final GuiRecipe gui, final ItemStack aStack, final List<String> currenttip, final int aRecipeIndex) { + final TemplateRecipeHandler.CachedRecipe tObject = this.arecipes.get(aRecipeIndex); + if ((tObject instanceof ChemPlantDefaultRecipe)) { + final ChemPlantDefaultRecipe tRecipe = (ChemPlantDefaultRecipe) tObject; + for (final PositionedStack tStack : tRecipe.mOutputs) { + if (aStack == tStack.item) { + if ((!(tStack instanceof FixedPositionedStack)) || (((FixedPositionedStack) tStack).mChance <= 0) || (((FixedPositionedStack) tStack).mChance == 10000)) { + break; + } + currenttip.add("Chance: " + (((FixedPositionedStack) tStack).mChance / 100) + "." + ((((FixedPositionedStack) tStack).mChance % 100) < 10 ? "0" + (((FixedPositionedStack) tStack).mChance % 100) : Integer.valueOf(((FixedPositionedStack) tStack).mChance % 100)) + "%"); + break; + } + } + for (final PositionedStack tStack : tRecipe.mInputs) { + if (GT_Utility.areStacksEqual(aStack, tStack.item)) { + if ((gregtech.api.enums.ItemList.Display_Fluid.isStackEqual(tStack.item, true, true)) || + (tStack.item.stackSize != 0)) { + break; + } + if (ItemUtils.isCatalyst(aStack)) { + currenttip.add("Does not always get consumed in the process"); + currenttip.add("Higher tier pipe casings allow this item to last longer"); + } + else if (ItemUtils.isControlCircuit(aStack)) { + currenttip.add("Does not get consumed in the process"); + } + break; + } + } + } + return currenttip; + } + + @Override + public void drawExtras(final int aRecipeIndex) { + final long tEUt = ((ChemPlantDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mEUt; + final int tDuration = ((ChemPlantDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mDuration; + if (tEUt != 0) { + drawText(10, 73, "Total: " + MathUtils.formatNumbers((long) (tDuration * tEUt)) + " EU", -16777216); + //drawText(10, 83, "Usage: " + tEUt + " EU/t", -16777216); + if (this.mRecipeMap.mShowVoltageAmperageInNEI) { + drawText(10, 83, "Voltage: " + MathUtils.formatNumbers((tEUt / this.mRecipeMap.mAmperage)) + " EU/t", -16777216); + drawText(10, 93, "Amperage: " + this.mRecipeMap.mAmperage, -16777216); + } else { + drawText(10, 93, "Voltage: unspecified", -16777216); + drawText(10, 103, "Amperage: unspecified", -16777216); + } + } + if (tDuration > 0) { + drawText(10, 103, "Time: " + (tDuration < 20 ? "< 1" : MathUtils.formatNumbers(Integer.valueOf(tDuration / 20))) + " secs", -16777216); + } + if ((GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePre)) || (GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePost))) { + int aTier = (((ChemPlantDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue); + String aTierMaterial = " - "; + if (aTier <= 0) { + aTierMaterial += "Bronze"; + } + else if (aTier == 1) { + aTierMaterial += "Steel"; + } + else if (aTier == 2) { + aTierMaterial += "Aluminium"; + } + else if (aTier == 3) { + aTierMaterial += "Stainless Steel"; + } + else if (aTier == 4) { + aTierMaterial += "Titanium"; + } + else if (aTier == 5) { + aTierMaterial += "Tungsten Steel"; + } + else if (aTier == 6) { + aTierMaterial += "Laurenium"; + } + else if (aTier == 7) { + aTierMaterial += "Botmium"; + } + + drawText(10, 113, this.mRecipeMap.mNEISpecialValuePre + (((ChemPlantDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue * this.mRecipeMap.mNEISpecialValueMultiplier) + aTierMaterial, -16777216); + } + } + + public class ChemPlantDefaultRecipe extends CachedDefaultRecipe { + + public ChemPlantDefaultRecipe(final GT_Recipe aRecipe) { + super(aRecipe); + } + + @Override + public void handleSlots() { + int tStartIndex = 0; + + // Four Input Slots + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 3, -4)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 21, -4)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 39, -4)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 57, -4)); + } + tStartIndex++; + + + if (mRecipe.mSpecialItems != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.mSpecialItems, 120, 52)); + } + tStartIndex = 0; + + //Four Output Slots + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, 5, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 120, 5, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, 23, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 120, 23, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + + + //New fluid display behaviour when 3 fluid inputs are detected. (Basically a mix of the code below for outputs an the code above for 9 input slots.) + if (mRecipe.mFluidInputs.length >= 1) { + if ((mRecipe.mFluidInputs[0] != null) && (mRecipe.mFluidInputs[0].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidInputs[0], true), 3, 31)); + } + if ((mRecipe.mFluidInputs.length > 1) && (mRecipe.mFluidInputs[1] != null) && (mRecipe.mFluidInputs[1].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidInputs[1], true), 21, 31)); + } + if ((mRecipe.mFluidInputs.length > 2) && (mRecipe.mFluidInputs[2] != null) && (mRecipe.mFluidInputs[2].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidInputs[2], true), 39, 31)); + } + if ((mRecipe.mFluidInputs.length > 3) && (mRecipe.mFluidInputs[3] != null) && (mRecipe.mFluidInputs[3].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidInputs[3], true), 57, 31)); + } + } + + if (mRecipe.mFluidOutputs.length > 0) { + if ((mRecipe.mFluidOutputs[0] != null) && (mRecipe.mFluidOutputs[0].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidOutputs[0], true), 138, 5)); + } + if ((mRecipe.mFluidOutputs.length > 1) && (mRecipe.mFluidOutputs[1] != null) && (mRecipe.mFluidOutputs[1].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidOutputs[1], true), 138, 23)); + } + } + + } + } +} diff --git a/src/main/java/gtPlusPlus/nei/GT_NEI_LFTR.java b/src/main/java/gtPlusPlus/nei/GT_NEI_LFTR.java new file mode 100644 index 0000000000..dd7338eccd --- /dev/null +++ b/src/main/java/gtPlusPlus/nei/GT_NEI_LFTR.java @@ -0,0 +1,118 @@ +package gtPlusPlus.nei; + +import org.lwjgl.opengl.GL11; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.recipe.TemplateRecipeHandler; +import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.util.math.MathUtils; + +public class GT_NEI_LFTR extends GTPP_NEI_DefaultHandler { + + public GT_NEI_LFTR() { + super(GTPP_Recipe_Map.sLiquidFluorineThoriumReactorRecipes); + } + + @Override + public TemplateRecipeHandler newInstance() { + return new GT_NEI_LFTR(); + } + + @Override + public CachedDefaultRecipe createCachedRecipe(GT_Recipe aRecipe) { + return new LFTRDefaultRecipe(aRecipe); + } + + @Override + public void drawBackground(final int recipe) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(this.getGuiTexture()); + GuiDraw.drawTexturedModalRect(-4, -8, 1, 3, 174, 89); + } + + @Override + public void drawExtras(final int aRecipeIndex) { + final long tEUt = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue; + final int tDuration = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mDuration; + drawText(10, 83, "Time: " + (tDuration < 20 ? "< 1" : MathUtils.formatNumbers(Integer.valueOf(tDuration / 20))) + " secs", -16777216); + drawText(10, 93, this.mRecipeMap.mNEISpecialValuePre + MathUtils.formatNumbers((((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue * this.mRecipeMap.mNEISpecialValueMultiplier)) + this.mRecipeMap.mNEISpecialValuePost, -16777216); + drawText(10, 103, "Dynamo: " + MathUtils.formatNumbers((long) (tDuration * tEUt)) + " EU", -16777216); + drawText(10, 113, "Total: " + MathUtils.formatNumbers((long) (tDuration * tEUt * 4)) + " EU", -16777216); + } + + public class LFTRDefaultRecipe extends CachedDefaultRecipe { + + public LFTRDefaultRecipe(final GT_Recipe aRecipe) { + super(aRecipe); + } + + @Override + public void handleSlots() { + int tStartIndex = 0; + if (mRecipe.mFluidInputs.length > 0) { + if ((mRecipe.mFluidInputs[0] != null) && (mRecipe.mFluidInputs[0].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidInputs[0], true), 12, 5)); + } + if ((mRecipe.mFluidInputs.length > 1) && (mRecipe.mFluidInputs[1] != null) && (mRecipe.mFluidInputs[1].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidInputs[1], true), 30, 5)); + } + if ((mRecipe.mFluidInputs.length > 2) && (mRecipe.mFluidInputs[2] != null) && (mRecipe.mFluidInputs[2].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidInputs[2], true), 48, 5)); + } + if ((mRecipe.mFluidInputs.length > 3) && (mRecipe.mFluidInputs[3] != null) && (mRecipe.mFluidInputs[3].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidInputs[3], true), 12, 23)); + } + if ((mRecipe.mFluidInputs.length > 4) && (mRecipe.mFluidInputs[4] != null) && (mRecipe.mFluidInputs[4].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidInputs[4], true), 30, 23)); + } + if ((mRecipe.mFluidInputs.length > 5) && (mRecipe.mFluidInputs[5] != null) && (mRecipe.mFluidInputs[5].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidInputs[5], true), 48, 23)); + } + if ((mRecipe.mFluidInputs.length > 6) && (mRecipe.mFluidInputs[6] != null) && (mRecipe.mFluidInputs[6].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidInputs[6], true), 12, 41)); + } + if ((mRecipe.mFluidInputs.length > 7) && (mRecipe.mFluidInputs[7] != null) && (mRecipe.mFluidInputs[7].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidInputs[7], true), 30, 41)); + } + if ((mRecipe.mFluidInputs.length > 8) && (mRecipe.mFluidInputs[8] != null) && (mRecipe.mFluidInputs[8].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidInputs[8], true), 48, 41)); + } + } + + tStartIndex = 0; + if (mRecipe.mFluidOutputs.length > 0) { + if ((mRecipe.mFluidOutputs[0] != null) && (mRecipe.mFluidOutputs[0].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidOutputs[0], true), 102, 5, mRecipe.getOutputChance(tStartIndex++))); + } + if ((mRecipe.mFluidOutputs.length > 1) && (mRecipe.mFluidOutputs[1] != null) && (mRecipe.mFluidOutputs[1].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidOutputs[1], true), 120, 5, mRecipe.getOutputChance(tStartIndex++))); + } + if ((mRecipe.mFluidOutputs.length > 2) && (mRecipe.mFluidOutputs[2] != null) && (mRecipe.mFluidOutputs[2].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidOutputs[2], true), 138, 5, mRecipe.getOutputChance(tStartIndex++))); + } + if ((mRecipe.mFluidOutputs.length > 3) && (mRecipe.mFluidOutputs[3] != null) && (mRecipe.mFluidOutputs[3].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidOutputs[3], true), 102, 23, mRecipe.getOutputChance(tStartIndex++))); + } + if ((mRecipe.mFluidOutputs.length > 4) && (mRecipe.mFluidOutputs[4] != null) && (mRecipe.mFluidOutputs[4].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidOutputs[4], true), 120, 23, mRecipe.getOutputChance(tStartIndex++))); + } + if ((mRecipe.mFluidOutputs.length > 5) && (mRecipe.mFluidOutputs[5] != null) && (mRecipe.mFluidOutputs[5].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidOutputs[5], true), 138, 23, mRecipe.getOutputChance(tStartIndex++))); + } + if ((mRecipe.mFluidOutputs.length > 6) && (mRecipe.mFluidOutputs[6] != null) && (mRecipe.mFluidOutputs[6].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidOutputs[6], true), 102, 41, mRecipe.getOutputChance(tStartIndex++))); + } + if ((mRecipe.mFluidOutputs.length > 7) && (mRecipe.mFluidOutputs[7] != null) && (mRecipe.mFluidOutputs[7].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidOutputs[7], true), 120, 41, mRecipe.getOutputChance(tStartIndex++))); + } + if ((mRecipe.mFluidOutputs.length > 8) && (mRecipe.mFluidOutputs[8] != null) && (mRecipe.mFluidOutputs[8].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidOutputs[8], true), 138, 41, mRecipe.getOutputChance(tStartIndex++))); + } + } + + } + + } +} diff --git a/src/main/java/gtPlusPlus/nei/GT_NEI_LFTR_Sparging.java b/src/main/java/gtPlusPlus/nei/GT_NEI_LFTR_Sparging.java new file mode 100644 index 0000000000..c9f9f0722a --- /dev/null +++ b/src/main/java/gtPlusPlus/nei/GT_NEI_LFTR_Sparging.java @@ -0,0 +1,372 @@ +package gtPlusPlus.nei; + +import java.awt.Rectangle; +import java.lang.ref.SoftReference; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; + +import org.lwjgl.opengl.GL11; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.GuiCraftingRecipe; +import codechicken.nei.recipe.GuiRecipe; +import codechicken.nei.recipe.GuiUsageRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; +import cpw.mods.fml.common.event.FMLInterModComms; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.objects.ItemData; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.GasSpargingRecipe; +import gregtech.api.util.GasSpargingRecipeMap; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class GT_NEI_LFTR_Sparging extends TemplateRecipeHandler { + + public static final String mNEIName = GasSpargingRecipeMap.mNEIDisplayName; + private SoftReference<List<GasSpargingRecipeNEI>> mCachedRecipes = null; + + public GT_NEI_LFTR_Sparging() { + this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(65, 13, 36, 18), this.getOverlayIdentifier(), new Object[0])); + if (!NEI_GT_Config.sIsAdded) { + FMLInterModComms.sendRuntimeMessage(GT_Values.GT, "NEIPlugins", "register-crafting-handler", "gregtechplusplus@" + this.getRecipeName() + "@" + this.getOverlayIdentifier()); + GuiCraftingRecipe.craftinghandlers.add(this); + GuiUsageRecipe.usagehandlers.add(this); + } + } + + public String getRecipeName() { + return mNEIName; + } + + public String getGuiTexture() { + return GasSpargingRecipeMap.mNEIGUIPath; + } + + public String getOverlayIdentifier() { + return gregtech.api.util.GasSpargingRecipeMap.mUnlocalizedName; + } + + public int recipiesPerPage() { + return 1; + } + + @Override + public void drawBackground(final int recipe) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(this.getGuiTexture()); + GuiDraw.drawTexturedModalRect(-4, -8, 1, 3, 174, 68); + } + + public void loadTransferRects() { + this.transferRects.add(new RecipeTransferRect(new Rectangle(72, 14, 22, 16), getRecipeName(), new Object[0])); + } + + public List<GasSpargingRecipeNEI> getCache() { + List<GasSpargingRecipeNEI> cache; + if (mCachedRecipes == null || (cache = mCachedRecipes.get()) == null) { + cache = GasSpargingRecipeMap.mRecipes.stream() // do not use parallel stream. This is already parallelized by NEI + .sorted() + .map(temp -> {return createCachedRecipe(temp);}) + .collect(Collectors.toList()); + // while the NEI parallelize handlers, for each individual handler it still uses sequential execution model + // so we do not need any synchronization here + mCachedRecipes = new SoftReference<>(cache); + } + return cache; + } + + public GasSpargingRecipeNEI createCachedRecipe(GasSpargingRecipe aRecipe) { + return new GasSpargingRecipeNEI(aRecipe); + } + + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getOverlayIdentifier())) { + arecipes.addAll(getCache()); + } else { + super.loadCraftingRecipes(outputId, results); + } + } + + public void loadCraftingRecipes(ItemStack aResult) { + ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aResult); + + ArrayList<ItemStack> tResults = new ArrayList<>(); + tResults.add(aResult); + tResults.add(GT_OreDictUnificator.get(true, aResult)); + if ((tPrefixMaterial != null) && (!tPrefixMaterial.mBlackListed) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) { + for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { + tResults.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); + } + } + FluidStack tFluid = GT_Utility.getFluidForFilledItem(aResult, true); + FluidStack tFluidStack; + if (tFluid != null) { + tFluidStack = tFluid; + tResults.add(GT_Utility.getFluidDisplayStack(tFluid, false)); + } + else tFluidStack = GT_Utility.getFluidFromDisplayStack(aResult); + if (tFluidStack != null) { + tResults.addAll(GT_Utility.getContainersFromFluid(tFluidStack)); + } + for (GasSpargingRecipeNEI recipe : getCache()) { + if (tResults.stream().anyMatch(stack -> recipe.contains(recipe.mOutputs, stack))) + arecipes.add(recipe); + } + } + + public void loadUsageRecipes(ItemStack aInput) { + ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aInput); + + ArrayList<ItemStack> tInputs = new ArrayList<>(); + tInputs.add(aInput); + tInputs.add(GT_OreDictUnificator.get(false, aInput)); + if ((tPrefixMaterial != null) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) { + for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { + tInputs.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); + } + } + FluidStack tFluid = GT_Utility.getFluidForFilledItem(aInput, true); + FluidStack tFluidStack; + if (tFluid != null) { + tFluidStack = tFluid; + tInputs.add(GT_Utility.getFluidDisplayStack(tFluid, false)); + } + else tFluidStack = GT_Utility.getFluidFromDisplayStack(aInput); + if (tFluidStack != null) { + tInputs.addAll(GT_Utility.getContainersFromFluid(tFluidStack)); + } + for (GasSpargingRecipeNEI recipe : getCache()) { + if (tInputs.stream().anyMatch(stack -> recipe.contains(recipe.mInputs, stack))) + arecipes.add(recipe); + } + } + + public void drawExtras(int aRecipeIndex) { + final long tEUt = ((GasSpargingRecipeNEI) this.arecipes.get(aRecipeIndex)).mRecipe.mEUt; + final long tDuration = ((GasSpargingRecipeNEI) this.arecipes.get(aRecipeIndex)).mRecipe.mDuration; + GT_NEI_LFTR.drawText(10, 73, "Total: " + MathUtils.formatNumbers((long) (tDuration * tEUt)) + " EU", -16777216); + GT_NEI_LFTR.drawText(10, 83, "Usage: " + MathUtils.formatNumbers(tEUt) + " EU/t", -16777216); + GT_NEI_LFTR.drawText(10, 93, "Time: " + (tDuration < 20 ? "< 1" : MathUtils.formatNumbers(Long.valueOf(tDuration / 20))) + " secs", -16777216); + GT_NEI_LFTR.drawText(10, 103, "Gas not used to sparge is", -16777216); + GT_NEI_LFTR.drawText(10, 113, "returned alongside outputs.", -16777216); + } + + @Override + public List<String> handleItemTooltip(final GuiRecipe gui, final ItemStack aStack, final List<String> currenttip, final int aRecipeIndex) { + final TemplateRecipeHandler.CachedRecipe tObject = this.arecipes.get(aRecipeIndex); + if ((tObject instanceof GasSpargingRecipeNEI)) { + final GasSpargingRecipeNEI tRecipe = (GasSpargingRecipeNEI) tObject; + ItemStack aSpargeInput = tRecipe.mOutputs.get(0).item; + ItemStack aSpentFuel = tRecipe.mOutputs.get(1).item; + for (final PositionedStack tStack : tRecipe.mOutputs) { + if (aStack == tStack.item) { + if (ItemList.Display_Fluid.isStackEqual(tStack.item, true, true)) { + if (GT_Utility.areStacksEqual(aStack, aSpentFuel, true)) { + break; + } + if (GT_Utility.areStacksEqual(aStack, aSpargeInput, true)) { + currenttip.add("The amount returned is the remainder after all other outputs."); + } + currenttip.add("Maximum Output: " + (((FixedPositionedStack) tStack).mChance / 100) + "." + ((((FixedPositionedStack) tStack).mChance % 100) < 10 ? "0" + (((FixedPositionedStack) tStack).mChance % 100) : Integer.valueOf(((FixedPositionedStack) tStack).mChance % 100)) + "L"); + break; + } + break; + } + } + for (final PositionedStack tStack : tRecipe.mInputs) { + if (GT_Utility.areStacksEqual(aStack, tStack.item)) { + if ((gregtech.api.enums.ItemList.Display_Fluid.isStackEqual(tStack.item, true, true)) || + (tStack.item.stackSize != 0)) { + break; + } + if (ItemUtils.isControlCircuit(aStack)) { + currenttip.add("Does not get consumed in the process"); + } + break; + } + } + } + return currenttip; + } + + public class FixedPositionedStack + extends PositionedStack { + public final int mChance; + public boolean permutated = false; + + public FixedPositionedStack(final Object object, final int x, final int y) { + this(object, x, y, 0); + } + + public FixedPositionedStack(final Object object, final int x, final int y, final int aChance) { + super(object, x, y, true); + this.mChance = aChance; + } + + @Override + public void generatePermutations() { + if (this.permutated) { + return; + } + final ArrayList<ItemStack> tDisplayStacks = new ArrayList<ItemStack>(); + for (final ItemStack tStack : this.items) { + if (GT_Utility.isStackValid(tStack)) { + if (tStack.getItemDamage() == 32767) { + final List<ItemStack> permutations = codechicken.nei.ItemList.itemMap.get(tStack.getItem()); + if (!permutations.isEmpty()) { + ItemStack stack; + for (final Iterator<ItemStack> i$ = permutations.iterator(); i$.hasNext(); tDisplayStacks.add(GT_Utility.copyAmount(tStack.stackSize, new Object[]{stack}))) { + stack = i$.next(); + } + } else { + final ItemStack base = new ItemStack(tStack.getItem(), tStack.stackSize); + base.stackTagCompound = tStack.stackTagCompound; + tDisplayStacks.add(base); + } + } else { + tDisplayStacks.add(GT_Utility.copy(new Object[]{tStack})); + } + } + } + this.items = (tDisplayStacks.toArray(new ItemStack[0])); + if (this.items.length == 0) { + this.items = new ItemStack[]{new ItemStack(Blocks.fire)}; + } + this.permutated = true; + this.setPermutationToRender(0); + } + } + + public class GasSpargingRecipeNEI extends CachedRecipe implements Comparable<CachedRecipe> { + + public final GasSpargingRecipe mRecipe; + public final List<PositionedStack> mOutputs = new ArrayList<PositionedStack>(); + public final List<PositionedStack> mInputs = new ArrayList<PositionedStack>(); + + public GasSpargingRecipeNEI(GasSpargingRecipe tRecipe) { + super(); + this.mRecipe = tRecipe; + int tStartIndex = 0; + if (tRecipe.mFluidInputs.length > 0) { + if ((tRecipe.mFluidInputs[0] != null) && (tRecipe.mFluidInputs[0].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(tRecipe.mFluidInputs[0], true), 30, 5)); + } + if ((tRecipe.mFluidInputs.length > 1) && (tRecipe.mFluidInputs[1] != null) && (tRecipe.mFluidInputs[1].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(tRecipe.mFluidInputs[1], true), 12, 5)); + } + if ((tRecipe.mFluidInputs.length > 2) && (tRecipe.mFluidInputs[2] != null) && (tRecipe.mFluidInputs[2].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(tRecipe.mFluidInputs[2], true), 48, 5)); + } + if ((tRecipe.mFluidInputs.length > 3) && (tRecipe.mFluidInputs[3] != null) && (tRecipe.mFluidInputs[3].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(tRecipe.mFluidInputs[3], true), 12, 23)); + } + if ((tRecipe.mFluidInputs.length > 4) && (tRecipe.mFluidInputs[4] != null) && (tRecipe.mFluidInputs[4].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(tRecipe.mFluidInputs[4], true), 30, 23)); + } + if ((tRecipe.mFluidInputs.length > 5) && (tRecipe.mFluidInputs[5] != null) && (tRecipe.mFluidInputs[5].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(tRecipe.mFluidInputs[5], true), 48, 23)); + } + if ((tRecipe.mFluidInputs.length > 6) && (tRecipe.mFluidInputs[6] != null) && (tRecipe.mFluidInputs[6].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(tRecipe.mFluidInputs[6], true), 12, 41)); + } + if ((tRecipe.mFluidInputs.length > 7) && (tRecipe.mFluidInputs[7] != null) && (tRecipe.mFluidInputs[7].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(tRecipe.mFluidInputs[7], true), 30, 41)); + } + if ((tRecipe.mFluidInputs.length > 8) && (tRecipe.mFluidInputs[8] != null) && (tRecipe.mFluidInputs[8].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(tRecipe.mFluidInputs[8], true), 48, 41)); + } + } + + tStartIndex = 0; + if (tRecipe.mFluidOutputs.length > 0) { + if ((tRecipe.mFluidOutputs[0] != null) && (tRecipe.mFluidOutputs[0].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(tRecipe.mFluidOutputs[0], false), 120, 5, tRecipe.getMaxOutput(tStartIndex++))); + } + if ((tRecipe.mFluidOutputs.length > 1) && (tRecipe.mFluidOutputs[1] != null) && (tRecipe.mFluidOutputs[1].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(tRecipe.mFluidOutputs[1], true), 102, 5, tRecipe.getMaxOutput(tStartIndex++))); + } + if ((tRecipe.mFluidOutputs.length > 2) && (tRecipe.mFluidOutputs[2] != null) && (tRecipe.mFluidOutputs[2].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(tRecipe.mFluidOutputs[2], false), 138, 5, tRecipe.getMaxOutput(tStartIndex++))); + } + if ((tRecipe.mFluidOutputs.length > 3) && (tRecipe.mFluidOutputs[3] != null) && (tRecipe.mFluidOutputs[3].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(tRecipe.mFluidOutputs[3], false), 102, 23, tRecipe.getMaxOutput(tStartIndex++))); + } + if ((tRecipe.mFluidOutputs.length > 4) && (tRecipe.mFluidOutputs[4] != null) && (tRecipe.mFluidOutputs[4].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(tRecipe.mFluidOutputs[4], false), 120, 23, tRecipe.getMaxOutput(tStartIndex++))); + } + if ((tRecipe.mFluidOutputs.length > 5) && (tRecipe.mFluidOutputs[5] != null) && (tRecipe.mFluidOutputs[5].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(tRecipe.mFluidOutputs[5], false), 138, 23, tRecipe.getMaxOutput(tStartIndex++))); + } + if ((tRecipe.mFluidOutputs.length > 6) && (tRecipe.mFluidOutputs[6] != null) && (tRecipe.mFluidOutputs[6].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(tRecipe.mFluidOutputs[6], false), 102, 41, tRecipe.getMaxOutput(tStartIndex++))); + } + if ((tRecipe.mFluidOutputs.length > 7) && (tRecipe.mFluidOutputs[7] != null) && (tRecipe.mFluidOutputs[7].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(tRecipe.mFluidOutputs[7], false), 120, 41, tRecipe.getMaxOutput(tStartIndex++))); + } + if ((tRecipe.mFluidOutputs.length > 8) && (tRecipe.mFluidOutputs[8] != null) && (tRecipe.mFluidOutputs[8].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(tRecipe.mFluidOutputs[8], false), 138, 41, tRecipe.getMaxOutput(tStartIndex++))); + } + } + } + + @Override + public int compareTo(CachedRecipe o) { + boolean b = GasSpargingRecipeNEI.class.isInstance(o); + if (b) { + GasSpargingRecipeNEI p = (GasSpargingRecipeNEI) o; + if (p.mOutputs.size() > this.mOutputs.size()) { + return 1; + } else if (p.mOutputs.size() == this.mOutputs.size()) { + return 0; + } else { + return -1; + } + } + return 0; + } + + @Override + public boolean equals(Object obj) { + if (obj != null) { + if (GasSpargingRecipeNEI.class.isInstance(obj)) { + GasSpargingRecipeNEI p = (GasSpargingRecipeNEI) obj; + if (p != null) { + if (GT_Utility.areStacksEqual(p.mInputs.get(0).item, this.mInputs.get(0).item, true)) { + if (p.mOutputs.size() == this.mOutputs.size()) { + return true; + } + } + } + } + } + return false; + } + + @Override + public List<PositionedStack> getIngredients() { + return this.getCycledIngredients(GT_NEI_LFTR_Sparging.this.cycleticks / 10, this.mInputs); + } + + @Override + public PositionedStack getResult() { + return null; + } + + @Override + public List<PositionedStack> getOtherStacks() { + return this.mOutputs; + } + + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/nei/GT_NEI_MillingMachine.java b/src/main/java/gtPlusPlus/nei/GT_NEI_MillingMachine.java new file mode 100644 index 0000000000..5d09b9003f --- /dev/null +++ b/src/main/java/gtPlusPlus/nei/GT_NEI_MillingMachine.java @@ -0,0 +1,136 @@ +package gtPlusPlus.nei; + +import java.util.List; + +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.GuiRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; +import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.item.ItemStack; + +public class GT_NEI_MillingMachine extends GTPP_NEI_DefaultHandler { + + public GT_NEI_MillingMachine() { + super(GTPP_Recipe_Map.sOreMillRecipes); + } + + @Override + public TemplateRecipeHandler newInstance() { + return new GT_NEI_MillingMachine(); + } + + @Override + public CachedDefaultRecipe createCachedRecipe(GT_Recipe aRecipe) { + return new MillingDefaultRecipe(aRecipe); + } + + @Override + public List<String> handleItemTooltip(final GuiRecipe gui, final ItemStack aStack, final List<String> currenttip, final int aRecipeIndex) { + final TemplateRecipeHandler.CachedRecipe tObject = this.arecipes.get(aRecipeIndex); + if ((tObject instanceof CachedDefaultRecipe)) { + final CachedDefaultRecipe tRecipe = (CachedDefaultRecipe) tObject; + for (final PositionedStack tStack : tRecipe.mOutputs) { + if (aStack == tStack.item) { + if ((!(tStack instanceof FixedPositionedStack)) || (((FixedPositionedStack) tStack).mChance <= 0) || (((FixedPositionedStack) tStack).mChance == 10000)) { + break; + } + currenttip.add("Chance: " + (((FixedPositionedStack) tStack).mChance / 100) + "." + ((((FixedPositionedStack) tStack).mChance % 100) < 10 ? "0" + (((FixedPositionedStack) tStack).mChance % 100) : Integer.valueOf(((FixedPositionedStack) tStack).mChance % 100)) + "%"); + break; + } + } + for (final PositionedStack tStack : tRecipe.mInputs) { + if (GT_Utility.areStacksEqual(aStack, tStack.item)) { + if ((gregtech.api.enums.ItemList.Display_Fluid.isStackEqual(tStack.item, true, true)) || + (tStack.item.stackSize != 0)) { + break; + } + if (ItemUtils.isMillingBall(aStack)) { + currenttip.add("Does not always get consumed in the process"); + } + else if (ItemUtils.isControlCircuit(aStack)) { + currenttip.add("Does not get consumed in the process"); + } + break; + } + } + } + return currenttip; + } + + public class MillingDefaultRecipe extends CachedDefaultRecipe { + + public MillingDefaultRecipe(final GT_Recipe aRecipe) { + super(aRecipe); + } + + @Override + public void handleSlots() { + int tStartIndex = 0; + + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 12, 14)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (mRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + + if (mRecipe.mSpecialItems != null) { + this.mInputs.add(new FixedPositionedStack(mRecipe.mSpecialItems, 120, 52)); + } + tStartIndex = 0; + + //Four Output Slots + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, 5, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 120, 5, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 102, 23, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (mRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(mRecipe.getOutput(tStartIndex), 120, 23, mRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + + + //New fluid display behaviour when 3 fluid inputs are detected. (Basically a mix of the code below for outputs an the code above for 9 input slots.) + if (mRecipe.mFluidInputs.length >= 1) { + if ((mRecipe.mFluidInputs[0] != null) && (mRecipe.mFluidInputs[0].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidInputs[0], true), 3, 31)); + } + if ((mRecipe.mFluidInputs.length > 1) && (mRecipe.mFluidInputs[1] != null) && (mRecipe.mFluidInputs[1].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidInputs[1], true), 21, 31)); + } + if ((mRecipe.mFluidInputs.length > 2) && (mRecipe.mFluidInputs[2] != null) && (mRecipe.mFluidInputs[2].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidInputs[2], true), 39, 31)); + } + if ((mRecipe.mFluidInputs.length > 3) && (mRecipe.mFluidInputs[3] != null) && (mRecipe.mFluidInputs[3].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidInputs[3], true), 57, 31)); + } + } + + if (mRecipe.mFluidOutputs.length > 0) { + if ((mRecipe.mFluidOutputs[0] != null) && (mRecipe.mFluidOutputs[0].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidOutputs[0], true), 138, 5)); + } + if ((mRecipe.mFluidOutputs.length > 1) && (mRecipe.mFluidOutputs[1] != null) && (mRecipe.mFluidOutputs[1].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(mRecipe.mFluidOutputs[1], true), 138, 23)); + } + } + } + } +} diff --git a/src/main/java/gtPlusPlus/nei/GT_NEI_MultiNoCell.java b/src/main/java/gtPlusPlus/nei/GT_NEI_MultiNoCell.java new file mode 100644 index 0000000000..f4f69589b6 --- /dev/null +++ b/src/main/java/gtPlusPlus/nei/GT_NEI_MultiNoCell.java @@ -0,0 +1,58 @@ +package gtPlusPlus.nei; + +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + +import org.lwjgl.opengl.GL11; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.recipe.TemplateRecipeHandler; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.util.math.MathUtils; + +public class GT_NEI_MultiNoCell extends GTPP_NEI_DefaultHandler { + + public GT_NEI_MultiNoCell(GT_Recipe_Map aMap) { + super(aMap); + } + + @Override + public TemplateRecipeHandler newInstance() { + return new GT_NEI_MultiNoCell(mRecipeMap); + } + + @Override + public CachedDefaultRecipe createCachedRecipe(GT_Recipe aRecipe) { + return new NoCellMultiDefaultRecipe(aRecipe); + } + + @Override + public void drawBackground(final int recipe) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(this.getGuiTexture()); + GuiDraw.drawTexturedModalRect(-4, -8, 1, 3, 174, 89); + } + + @Override + public String getGuiTexture() { + return RES_PATH_GUI + "basicmachines/FissionFuel.png"; + } + + @Override + public void drawExtras(final int aRecipeIndex) { + final long tEUt = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mEUt; + final int tDuration = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mDuration; + if (tEUt != 0) { + drawText(10, 90, "Total: " + MathUtils.formatNumbers((long) (tDuration * tEUt)) + " EU", -16777216); + drawText(10, 100, "Usage: " + MathUtils.formatNumbers(tEUt) + " EU/t", -16777216); + } + if (tDuration > 0) { + drawText(10, 110, "Time: " + (tDuration < 20 ? "< 1" : MathUtils.formatNumbers(Integer.valueOf(tDuration / 20))) + " secs", -16777216); + } + if ((GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePre)) || (GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePost))) { + drawText(10, 120, this.mRecipeMap.mNEISpecialValuePre + MathUtils.formatNumbers((((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue * this.mRecipeMap.mNEISpecialValueMultiplier)) + this.mRecipeMap.mNEISpecialValuePost, -16777216); + } + } + +} diff --git a/src/main/java/gtPlusPlus/nei/NEI_GT_Config.java b/src/main/java/gtPlusPlus/nei/NEI_GT_Config.java new file mode 100644 index 0000000000..0b3cf8e66e --- /dev/null +++ b/src/main/java/gtPlusPlus/nei/NEI_GT_Config.java @@ -0,0 +1,100 @@ +package gtPlusPlus.nei; + +import codechicken.nei.api.API; +import codechicken.nei.api.IConfigureNEI; +import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map; +import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map_Internal; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; + +public class NEI_GT_Config +implements IConfigureNEI { + + public static boolean sIsAdded = false; + + private static final AutoMap<String> mUniqueRecipeMapHandling = new AutoMap<String>(); + + @Override + public synchronized void loadConfig() { + + mUniqueRecipeMapHandling.add(GTPP_Recipe_Map.sFissionFuelProcessing.mUnlocalizedName); + mUniqueRecipeMapHandling.add(GTPP_Recipe_Map.sLiquidFluorineThoriumReactorRecipes.mUnlocalizedName); + mUniqueRecipeMapHandling.add(GTPP_Recipe_Map.sChemicalPlantRecipes.mUnlocalizedName); + mUniqueRecipeMapHandling.add(GTPP_Recipe_Map.sOreMillRecipes.mUnlocalizedName); + mUniqueRecipeMapHandling.add(GTPP_Recipe_Map.sFlotationCellRecipes.mUnlocalizedName); + mUniqueRecipeMapHandling.add(GTPP_Recipe_Map.sVacuumFurnaceRecipes.mUnlocalizedName); + + mUniqueRecipeMapHandling.add(GTPP_Recipe_Map.sAdvFreezerRecipes_GT.mUnlocalizedName); + mUniqueRecipeMapHandling.add(GTPP_Recipe_Map.sMultiblockCentrifugeRecipes_GT.mUnlocalizedName); + mUniqueRecipeMapHandling.add(GTPP_Recipe_Map.sMultiblockElectrolyzerRecipes_GT.mUnlocalizedName); + mUniqueRecipeMapHandling.add(GTPP_Recipe_Map.sMultiblockMixerRecipes_GT.mUnlocalizedName); + mUniqueRecipeMapHandling.add(GTPP_Recipe_Map.sAlloyBlastSmelterRecipes.mUnlocalizedName); + + // Standard GT Recipe Maps + Logger.INFO("NEI Registration: "+GTPP_Recipe_Map_Internal.sMappingsEx.size()+" sMappingEx"); + for (final GT_Recipe_Map tMap : GTPP_Recipe_Map_Internal.sMappingsEx) { + if (tMap.mNEIAllowed) { + if (!mUniqueRecipeMapHandling.contains(tMap.mUnlocalizedName)) { + Logger.INFO("NEI Registration: Registering NEI handler for "+tMap.mNEIName); + new GTPP_NEI_DefaultHandler(tMap); + } + else { + Logger.INFO("NEI Registration: Not allowed to register NEI handler for "+tMap.mNEIName); + } + } + else { + Logger.INFO("NEI Registration: Skipping registration of NEI handler for "+tMap.mNEIName); + } + } + + Logger.INFO("NEI Registration: Registering NEI handler for "+GTPP_Recipe_Map.sChemicalPlantRecipes.mNEIName); + new GT_NEI_FluidReactor(); + Logger.INFO("NEI Registration: Registering NEI handler for "+GTPP_Recipe_Map.sOreMillRecipes.mNEIName); + new GT_NEI_MillingMachine(); + Logger.INFO("NEI Registration: Registering NEI handler for "+GTPP_Recipe_Map.sFlotationCellRecipes.mNEIName); + new GT_NEI_FlotationCell(); + Logger.INFO("NEI Registration: Registering NEI handler for "+GTPP_Recipe_Map.sLiquidFluorineThoriumReactorRecipes.mNEIName); + new GT_NEI_LFTR(); + Logger.INFO("NEI Registration: Registering NEI handler for "+GTPP_Recipe_Map.sFissionFuelProcessing.mNEIName); + new GT_NEI_MultiNoCell(GTPP_Recipe_Map.sFissionFuelProcessing); + Logger.INFO("NEI Registration: Registering NEI handler for "+GTPP_Recipe_Map.sVacuumFurnaceRecipes.mNEIName); + new GT_NEI_MultiNoCell(GTPP_Recipe_Map.sVacuumFurnaceRecipes); + Logger.INFO("NEI Registration: Registering NEI handler for "+GTPP_Recipe_Map.sAdvFreezerRecipes_GT.mNEIName); + new GT_NEI_MultiNoCell(GTPP_Recipe_Map.sAdvFreezerRecipes_GT); + Logger.INFO("NEI Registration: Registering NEI handler for "+GTPP_Recipe_Map.sMultiblockCentrifugeRecipes_GT.mNEIName); + new GT_NEI_MultiNoCell(GTPP_Recipe_Map.sMultiblockCentrifugeRecipes_GT); + Logger.INFO("NEI Registration: Registering NEI handler for "+GTPP_Recipe_Map.sMultiblockElectrolyzerRecipes_GT.mNEIName); + new GT_NEI_MultiNoCell(GTPP_Recipe_Map.sMultiblockElectrolyzerRecipes_GT); + Logger.INFO("NEI Registration: Registering NEI handler for "+GTPP_Recipe_Map.sMultiblockMixerRecipes_GT.mNEIName); + new GT_NEI_MultiNoCell(GTPP_Recipe_Map.sMultiblockMixerRecipes_GT); + Logger.INFO("NEI Registration: Registering NEI handler for "+GTPP_Recipe_Map.sAlloyBlastSmelterRecipes.mNEIName); + new GT_NEI_MultiNoCell(GTPP_Recipe_Map.sAlloyBlastSmelterRecipes); + + Logger.INFO("NEI Registration: Registering NEI handler for "+DecayableRecipeHandler.mNEIName); + API.registerRecipeHandler(new DecayableRecipeHandler()); + API.registerUsageHandler(new DecayableRecipeHandler()); + + Logger.INFO("NEI Registration: Registering NEI handler for "+GT_NEI_LFTR_Sparging.mNEIName); + new GT_NEI_LFTR_Sparging(); + + // Hide Flasks + if (Utils.isClient()) { + codechicken.nei.api.API.addItemListEntry(GregtechItemList.VOLUMETRIC_FLASK_8k.get(1)); + codechicken.nei.api.API.addItemListEntry(GregtechItemList.VOLUMETRIC_FLASK_32k.get(1)); + } + sIsAdded = true; + } + + @Override + public String getName() { + return "GT++ NEI Plugin"; + } + + @Override + public String getVersion() { + return "(1.12)"; + } +} diff --git a/src/main/java/gtPlusPlus/nei/NEI_IMC_Sender.java b/src/main/java/gtPlusPlus/nei/NEI_IMC_Sender.java new file mode 100644 index 0000000000..7bc2316a04 --- /dev/null +++ b/src/main/java/gtPlusPlus/nei/NEI_IMC_Sender.java @@ -0,0 +1,51 @@ +package gtPlusPlus.nei; + +import cpw.mods.fml.common.event.FMLInterModComms; +import net.minecraft.nbt.NBTTagCompound; + +public class NEI_IMC_Sender { + public static void IMCSender() { + setNBTInfoAndSendIt("gtpp.recipe.alloyblastsmelter", "gregtech:gt.blockmachines:810", 1); + setNBTInfoAndSendIt("gtpp.recipe.rocketenginefuel", "gregtech:gt.blockmachines:793"); + setNBTInfoAndSendIt("gtpp.recipe.cyclotron", "gregtech:gt.blockmachines:828"); + setNBTInfoAndSendIt("gtpp.recipe.chemicaldehydrator", "gregtech:gt.blockmachines:911", 1); + setNBTInfoAndSendIt("gtpp.recipe.slowfusionreactor", "gregtech:gt.blockmachines:31015"); + setNBTInfoAndSendIt("gtpp.recipe.RTGgenerators", "gregtech:gt.blockmachines:869"); + setNBTInfoAndSendIt("gtpp.recipe.cokeoven", "gregtech:gt.blockmachines:791"); + setNBTInfoAndSendIt("gtpp.recipe.semifluidgeneratorfuels", "gregtech:gt.blockmachines:837"); + setNBTInfoAndSendIt("gtpp.recipe.fishpond", "gregtech:gt.blockmachines:829", 1); + setNBTInfoAndSendIt("gtpp.recipe.multimixer", "gregtech:gt.blockmachines:811"); + setNBTInfoAndSendIt("gtpp.recipe.advanced.mixer", "gregtech:gt.blockmachines:811"); + setNBTInfoAndSendIt("gtpp.recipe.cryogenicfreezer", "gregtech:gt.blockmachines:910"); + setNBTInfoAndSendIt("gtpp.recipe.geothermalfuel", "gregtech:gt.blockmachines:830"); + setNBTInfoAndSendIt("gtpp.recipe.matterfab2", "gregtech:gt.blockmachines:799"); + setNBTInfoAndSendIt("gtpp.recipe.multicentrifuge", "gregtech:gt.blockmachines:790", 1); + setNBTInfoAndSendIt("gtpp.recipe.multielectro", "gregtech:gt.blockmachines:796", 1); + setNBTInfoAndSendIt("gtpp.recipe.simplewasher", "gregtech:gt.blockmachines:767"); + setNBTInfoAndSendIt("gtpp.recipe.vacfurnace", "gregtech:gt.blockmachines:995", 1); + setNBTInfoAndSendIt("gtpp.recipe.fissionfuel", "gregtech:gt.blockmachines:835", 1); + setNBTInfoAndSendIt("gtpp.recipe.lftr", "gregtech:gt.blockmachines:751", 1); + setNBTInfoAndSendIt("gtpp.recipe.lftr.sparging", "gregtech:gt.blockmachines:31035", 1); + setNBTInfoAndSendIt("gtpp.recipe.coldtrap", "gregtech:gt.blockmachines:31034"); + setNBTInfoAndSendIt("gtpp.recipe.reactorprocessingunit", "gregtech:gt.blockmachines:31032"); + } + + + private static void setNBTInfoAndSendIt(String aRecipeName, String aBlock) { + setNBTInfoAndSendIt(aRecipeName, aBlock, 2); + } + + private static void setNBTInfoAndSendIt(String aRecipeName, String aBlock, int aRecipesPerPage) { + NBTTagCompound aNBT = new NBTTagCompound(); + aNBT.setString("handler", aRecipeName); + aNBT.setString("modName", "GT++"); + aNBT.setString("modId", "miscutils"); + aNBT.setBoolean("modRequired", true); + aNBT.setString("itemName", aBlock); + aNBT.setInteger("yShift", 6); + aNBT.setInteger("handlerHeight", 135); + aNBT.setInteger("handlerWidth", 166); + aNBT.setInteger("maxRecipesPerPage", aRecipesPerPage); + FMLInterModComms.sendMessage("NotEnoughItems", "registerHandlerInfo", aNBT); + } +} diff --git a/src/main/java/gtPlusPlus/nei/handlers/NeiTextureHandler.java b/src/main/java/gtPlusPlus/nei/handlers/NeiTextureHandler.java new file mode 100644 index 0000000000..30c159ca93 --- /dev/null +++ b/src/main/java/gtPlusPlus/nei/handlers/NeiTextureHandler.java @@ -0,0 +1,164 @@ +package gtPlusPlus.nei.handlers; + +import gtPlusPlus.core.lib.CORE; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + + +/** + * Based on crazypants.enderio.gui.IconEIO + * + * @author Original EIO Author + * + * This is free and unencumbered software released into the public + * domain. + * + * Anyone is free to copy, modify, publish, use, compile, sell, or + * distribute this software, either in source code form or as a compiled + * binary, for any purpose, commercial or non-commercial, and by any + * means. + * + * In jurisdictions that recognize copyright laws, the author or authors + * of this software dedicate any and all copyright interest in the + * software to the public domain. We make this dedication for the + * benefit of the public at large and to the detriment of our heirs and + * successors. We intend this dedication to be an overt act of + * relinquishment in perpetuity of all present and future rights to this + * software under copyright law. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * For more information, please refer to <http://unlicense.org/> + * + * https://github.com/SleepyTrousers/EnderIO/blob/release/1.7.10/2.2/src/main/java/crazypants/render/RenderUtil.java + * + */ +public final class NeiTextureHandler { + + public static final NeiTextureHandler RECIPE = new NeiTextureHandler(16, 132, 16, 16); + public static final NeiTextureHandler RECIPE_BUTTON = new NeiTextureHandler(128, 116, 24, 24); + + public final double minU; + public final double maxU; + public final double minV; + public final double maxV; + public final double width; + public final double height; + + public static final ResourceLocation TEXTURE = new ResourceLocation(CORE.MODID + ":textures/gui/nei/widgets.png"); + + public NeiTextureHandler(int x, int y) { + this(x, y, 16, 16); + } + + public NeiTextureHandler(int x, int y, int width, int height) { + this((double) width, (double) height, (double) ((float) (0.00390625D * (double) x)), + (double) ((float) (0.00390625D * (double) (x + width))), (double) ((float) (0.00390625D * (double) y)), + (double) ((float) (0.00390625D * (double) (y + height)))); + } + + public NeiTextureHandler(double width, double height, double minU, double maxU, double minV, double maxV) { + this.width = width; + this.height = height; + this.minU = minU; + this.maxU = maxU; + this.minV = minV; + this.maxV = maxV; + } + + public void renderIcon(double x, double y) { + this.renderIcon(x, y, this.width, this.height, 0.0D, false); + } + + public void renderIcon(double x, double y, boolean doDraw) { + this.renderIcon(x, y, this.width, this.height, 0.0D, doDraw); + } + + public void renderIcon(double x, double y, double width, double height, double zLevel, boolean doDraw) { + this.renderIcon(x, y, width, height, zLevel, doDraw, false); + } + + public void renderIcon(double x, double y, double width, double height, double zLevel, boolean doDraw, + boolean flipY) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + Tessellator tessellator = Tessellator.instance; + if (doDraw) { + bindTexture(TEXTURE); + tessellator.startDrawingQuads(); + } + + if (flipY) { + tessellator.addVertexWithUV(x, y + height, zLevel, this.minU, this.minV); + tessellator.addVertexWithUV(x + width, y + height, zLevel, this.maxU, this.minV); + tessellator.addVertexWithUV(x + width, y + 0.0D, zLevel, this.maxU, this.maxV); + tessellator.addVertexWithUV(x, y + 0.0D, zLevel, this.minU, this.maxV); + } else { + tessellator.addVertexWithUV(x, y + height, zLevel, this.minU, this.maxV); + tessellator.addVertexWithUV(x + width, y + height, zLevel, this.maxU, this.maxV); + tessellator.addVertexWithUV(x + width, y + 0.0D, zLevel, this.maxU, this.minV); + tessellator.addVertexWithUV(x, y + 0.0D, zLevel, this.minU, this.minV); + } + + if (doDraw) { + tessellator.draw(); + } + + } + + public static final ResourceLocation BLOCK_TEX; + public static final ResourceLocation ITEM_TEX; + public static final ResourceLocation GLINT_TEX; + public static int BRIGHTNESS_MAX; + + static { + BLOCK_TEX = TextureMap.locationBlocksTexture; + ITEM_TEX = TextureMap.locationItemsTexture; + GLINT_TEX = new ResourceLocation("textures/misc/enchanted_item_glint.png"); + BRIGHTNESS_MAX = 15728880; + } + + public static TextureManager engine() { + return Minecraft.getMinecraft().renderEngine; + } + + public static void bindItemTexture(ItemStack stack) { + engine().bindTexture(stack.getItemSpriteNumber() == 0 ? BLOCK_TEX : ITEM_TEX); + } + + public static void bindItemTexture() { + engine().bindTexture(ITEM_TEX); + } + + public static void bindBlockTexture() { + engine().bindTexture(BLOCK_TEX); + } + + public static void bindGlintTexture() { + engine().bindTexture(BLOCK_TEX); + } + + public static void bindTexture(String string) { + engine().bindTexture(new ResourceLocation(string)); + } + + public static void bindTexture(ResourceLocation tex) { + engine().bindTexture(tex); + } + + public static FontRenderer fontRenderer() { + return Minecraft.getMinecraft().fontRenderer; + } + +}
\ No newline at end of file |