From 723be4cdeeff4b5001fc920626f702a8d2a8b958 Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Thu, 9 Jan 2014 19:25:44 -0500 Subject: [PATCH] NEI gas lookups for usage and crafting working! --- .../client/nei/BaseRecipeHandler.java | 23 +++++++++++- .../nei/ChemicalOxidizerRecipeHandler.java | 37 ++++++++++++++++++- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/common/mekanism/client/nei/BaseRecipeHandler.java b/common/mekanism/client/nei/BaseRecipeHandler.java index 71645b54b..5a9ee3427 100644 --- a/common/mekanism/client/nei/BaseRecipeHandler.java +++ b/common/mekanism/client/nei/BaseRecipeHandler.java @@ -6,6 +6,8 @@ import static codechicken.core.gui.GuiDraw.gui; import mekanism.api.gas.GasStack; import mekanism.client.render.MekanismRenderer; import net.minecraftforge.fluids.FluidStack; +import codechicken.nei.recipe.GuiCraftingRecipe; +import codechicken.nei.recipe.GuiUsageRecipe; import codechicken.nei.recipe.TemplateRecipeHandler; public abstract class BaseRecipeHandler extends TemplateRecipeHandler @@ -59,8 +61,27 @@ public abstract class BaseRecipeHandler extends TemplateRecipeHandler /* * true = usage, false = recipe */ - public boolean doGasLookup(int recipe, boolean type) + public boolean doGasLookup(GasStack stack, boolean type) { + if(stack != null && stack.amount > 0) + { + if(type) + { + if(!GuiUsageRecipe.openRecipeGui("gas", new Object[] {stack})) + { + return false; + } + } + else { + if(!GuiCraftingRecipe.openRecipeGui("gas", new Object[] {stack})) + { + return false; + } + } + + return true; + } + return false; } } diff --git a/common/mekanism/client/nei/ChemicalOxidizerRecipeHandler.java b/common/mekanism/client/nei/ChemicalOxidizerRecipeHandler.java index 7de11d5eb..0d69071ed 100644 --- a/common/mekanism/client/nei/ChemicalOxidizerRecipeHandler.java +++ b/common/mekanism/client/nei/ChemicalOxidizerRecipeHandler.java @@ -155,16 +155,18 @@ public class ChemicalOxidizerRecipeHandler extends BaseRecipeHandler if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+4 && yAxis <= 72+4) { + GasStack stack = ((CachedIORecipe)arecipes.get(recipe)).outputStack; + if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) { - if(doGasLookup(recipe, false)) + if(doGasLookup(stack, false)) { return true; } } else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage")) { - if(doGasLookup(recipe, true)) + if(doGasLookup(stack, true)) { return true; } @@ -173,6 +175,37 @@ public class ChemicalOxidizerRecipeHandler extends BaseRecipeHandler return super.keyTyped(gui, keyChar, keyCode, recipe); } + + @Override + public boolean mouseClicked(GuiRecipe gui, int button, int recipe) + { + Point point = GuiDraw.getMousePosition(); + + int xAxis = point.x - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); + int yAxis = point.y - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + + if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+4 && yAxis <= 72+4) + { + GasStack stack = ((CachedIORecipe)arecipes.get(recipe)).outputStack; + + if(button == 0) + { + if(doGasLookup(stack, false)) + { + return true; + } + } + else if(button == 1) + { + if(doGasLookup(stack, true)) + { + return true; + } + } + } + + return super.mouseClicked(gui, button, recipe); + } @Override public int recipiesPerPage()