NEI gas lookups for usage and crafting working!

This commit is contained in:
Aidan C. Brady 2014-01-09 19:25:44 -05:00
parent 40684e2bab
commit 723be4cdee
2 changed files with 57 additions and 3 deletions

View file

@ -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;
}
}

View file

@ -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()