2014-01-10 02:52:19 +01:00
|
|
|
package mekanism.client.nei;
|
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
import static codechicken.core.gui.GuiDraw.changeTexture;
|
2014-01-10 14:12:47 +01:00
|
|
|
import static codechicken.core.gui.GuiDraw.drawString;
|
2014-01-10 04:09:48 +01:00
|
|
|
import static codechicken.core.gui.GuiDraw.drawTexturedModalRect;
|
|
|
|
|
|
|
|
import java.awt.Point;
|
|
|
|
import java.awt.Rectangle;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import mekanism.api.gas.Gas;
|
|
|
|
import mekanism.api.gas.GasRegistry;
|
|
|
|
import mekanism.api.gas.GasStack;
|
2014-01-10 14:12:47 +01:00
|
|
|
import mekanism.client.gui.GuiRotaryCondensentrator;
|
2014-01-10 04:09:48 +01:00
|
|
|
import mekanism.common.ObfuscatedNames;
|
|
|
|
import mekanism.common.util.MekanismUtils;
|
|
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
|
|
import net.minecraftforge.fluids.FluidStack;
|
|
|
|
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
|
|
|
import codechicken.core.gui.GuiDraw;
|
|
|
|
import codechicken.nei.NEIClientConfig;
|
|
|
|
import codechicken.nei.PositionedStack;
|
|
|
|
import codechicken.nei.recipe.GuiRecipe;
|
|
|
|
import codechicken.nei.recipe.TemplateRecipeHandler;
|
|
|
|
|
|
|
|
public class RotaryCondensentratorRecipeHandler extends BaseRecipeHandler
|
2014-01-10 02:52:19 +01:00
|
|
|
{
|
2014-01-10 04:09:48 +01:00
|
|
|
private int ticksPassed;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
public static int xOffset = 5;
|
2014-01-10 14:12:47 +01:00
|
|
|
public static int yOffset = 12;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
@Override
|
|
|
|
public String getRecipeName()
|
|
|
|
{
|
2014-01-25 22:29:36 +01:00
|
|
|
return MekanismUtils.localize("nei.rotaryCondensentrator");
|
2014-01-10 04:09:48 +01:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
@Override
|
|
|
|
public String getOverlayIdentifier()
|
|
|
|
{
|
|
|
|
return "rotarycondensentrator";
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
@Override
|
|
|
|
public String getGuiTexture()
|
|
|
|
{
|
|
|
|
return "mekanism:gui/nei/GuiRotaryCondensentrator.png";
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
@Override
|
|
|
|
public Class getGuiClass()
|
|
|
|
{
|
2014-01-10 14:12:47 +01:00
|
|
|
return GuiRotaryCondensentrator.class;
|
2014-01-10 04:09:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getRecipeId()
|
|
|
|
{
|
|
|
|
return "mekanism.rotarycondensentrator";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawBackground(int i)
|
|
|
|
{
|
|
|
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
|
|
changeTexture(getGuiTexture());
|
|
|
|
drawTexturedModalRect(-2, 0, 3, yOffset, 170, 71);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawExtras(int i)
|
|
|
|
{
|
|
|
|
CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 14:12:47 +01:00
|
|
|
if(recipe.type)
|
|
|
|
{
|
|
|
|
drawTexturedModalRect(64-xOffset, 39-yOffset, 176, 123, 48, 8);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
drawTexturedModalRect(64-xOffset, 39-yOffset, 176, 115, 48, 8);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
if(recipe.gasStack != null)
|
|
|
|
{
|
2014-03-08 02:00:25 +01:00
|
|
|
displayGauge(58, 26-xOffset, 14-yOffset, 176, 40, 58, null, recipe.gasStack);
|
2014-01-10 04:09:48 +01:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
if(recipe.fluidStack != null)
|
|
|
|
{
|
2014-03-08 02:00:25 +01:00
|
|
|
displayGauge(58, 134-xOffset, 14-yOffset, 176, 40, 58, recipe.fluidStack, null);
|
2014-01-10 04:09:48 +01:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 14:12:47 +01:00
|
|
|
drawString(recipe.type ? MekanismUtils.localize("gui.condensentrating") : MekanismUtils.localize("gui.decondensentrating"), 6-xOffset, 74-yOffset, 0x404040, false);
|
2014-01-10 04:09:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onUpdate()
|
|
|
|
{
|
|
|
|
super.onUpdate();
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
ticksPassed++;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void loadTransferRects()
|
|
|
|
{
|
2014-01-10 14:12:47 +01:00
|
|
|
transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(64-xOffset, 39-yOffset, 48, 8), getRecipeId(), new Object[0]));
|
2014-01-10 04:09:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void loadCraftingRecipes(String outputId, Object... results)
|
|
|
|
{
|
|
|
|
if(outputId.equals(getRecipeId()))
|
|
|
|
{
|
|
|
|
for(Gas gas : GasRegistry.getRegisteredGasses())
|
|
|
|
{
|
|
|
|
if(gas.hasFluid())
|
|
|
|
{
|
2014-01-10 14:12:47 +01:00
|
|
|
arecipes.add(new CachedIORecipe(new GasStack(gas, 1), new FluidStack(gas.getFluid(), 1), true));
|
|
|
|
arecipes.add(new CachedIORecipe(new GasStack(gas, 1), new FluidStack(gas.getFluid(), 1), false));
|
2014-01-10 04:09:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack)
|
|
|
|
{
|
|
|
|
GasStack gas = (GasStack)results[0];
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
if(gas.getGas().hasFluid())
|
|
|
|
{
|
2014-01-10 14:12:47 +01:00
|
|
|
arecipes.add(new CachedIORecipe(new GasStack(gas.getGas(), 1), new FluidStack(gas.getGas().getFluid(), 1), false));
|
2014-01-10 04:09:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(outputId.equals("fluid") && results.length == 1 && results[0] instanceof FluidStack)
|
|
|
|
{
|
|
|
|
FluidStack fluid = (FluidStack)results[0];
|
|
|
|
Gas gas = GasRegistry.getGas(fluid.getFluid());
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
if(gas != null)
|
|
|
|
{
|
2014-01-10 14:12:47 +01:00
|
|
|
arecipes.add(new CachedIORecipe(new GasStack(gas, 1), new FluidStack(fluid.getFluid(), 1), true));
|
2014-01-10 04:09:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
super.loadCraftingRecipes(outputId, results);
|
|
|
|
}
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
@Override
|
|
|
|
public void loadUsageRecipes(String inputId, Object... ingredients)
|
|
|
|
{
|
|
|
|
if(inputId.equals("gas") && ingredients.length == 1 && ingredients[0] instanceof GasStack)
|
|
|
|
{
|
|
|
|
GasStack gas = (GasStack)ingredients[0];
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
if(gas.getGas().hasFluid())
|
|
|
|
{
|
2014-01-10 14:12:47 +01:00
|
|
|
arecipes.add(new CachedIORecipe(new GasStack(gas.getGas(), 1), new FluidStack(gas.getGas().getFluid(), 1), true));
|
2014-01-10 04:09:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(inputId.equals("fluid") && ingredients.length == 1 && ingredients[0] instanceof FluidStack)
|
|
|
|
{
|
|
|
|
FluidStack fluid = (FluidStack)ingredients[0];
|
|
|
|
Gas gas = GasRegistry.getGas(fluid.getFluid());
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
if(gas != null)
|
|
|
|
{
|
2014-01-10 14:12:47 +01:00
|
|
|
arecipes.add(new CachedIORecipe(new GasStack(gas, 1), new FluidStack(fluid.getFluid(), 1), false));
|
2014-01-10 04:09:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
super.loadUsageRecipes(inputId, ingredients);
|
|
|
|
}
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
@Override
|
|
|
|
public List<String> handleTooltip(GuiRecipe gui, List<String> currenttip, int recipe)
|
|
|
|
{
|
|
|
|
Point point = GuiDraw.getMousePosition();
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
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);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 18:58:05 +01:00
|
|
|
if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+4 && yAxis <= 72+4)
|
2014-01-10 04:09:48 +01:00
|
|
|
{
|
|
|
|
currenttip.add(((CachedIORecipe)arecipes.get(recipe)).gasStack.getGas().getLocalizedName());
|
|
|
|
}
|
2014-01-10 18:58:05 +01:00
|
|
|
else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+4 && yAxis <= 72+4)
|
2014-01-10 04:09:48 +01:00
|
|
|
{
|
|
|
|
currenttip.add(((CachedIORecipe)arecipes.get(recipe)).fluidStack.getFluid().getLocalizedName());
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
return super.handleTooltip(gui, currenttip, recipe);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe)
|
|
|
|
{
|
|
|
|
Point point = GuiDraw.getMousePosition();
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
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);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
GasStack gas = null;
|
|
|
|
FluidStack fluid = null;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 18:58:05 +01:00
|
|
|
if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+4 && yAxis <= 72+4)
|
2014-01-10 04:09:48 +01:00
|
|
|
{
|
|
|
|
gas = ((CachedIORecipe)arecipes.get(recipe)).gasStack;
|
|
|
|
}
|
2014-01-10 18:58:05 +01:00
|
|
|
else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+4 && yAxis <= 72+4)
|
2014-01-10 04:09:48 +01:00
|
|
|
{
|
|
|
|
fluid = ((CachedIORecipe)arecipes.get(recipe)).fluidStack;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
if(gas != null)
|
|
|
|
{
|
|
|
|
if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe"))
|
|
|
|
{
|
|
|
|
if(doGasLookup(gas, false))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage"))
|
|
|
|
{
|
|
|
|
if(doGasLookup(gas, true))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(fluid != null)
|
|
|
|
{
|
|
|
|
if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe"))
|
|
|
|
{
|
|
|
|
if(doFluidLookup(fluid, false))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage"))
|
|
|
|
{
|
|
|
|
if(doFluidLookup(fluid, true))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
return super.keyTyped(gui, keyChar, keyCode, recipe);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
@Override
|
|
|
|
public boolean mouseClicked(GuiRecipe gui, int button, int recipe)
|
|
|
|
{
|
|
|
|
Point point = GuiDraw.getMousePosition();
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
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);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
GasStack gas = null;
|
|
|
|
FluidStack fluid = null;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 18:58:05 +01:00
|
|
|
if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+18 && yAxis <= 72+18)
|
2014-01-10 04:09:48 +01:00
|
|
|
{
|
|
|
|
gas = ((CachedIORecipe)arecipes.get(recipe)).gasStack;
|
|
|
|
}
|
2014-01-10 18:58:05 +01:00
|
|
|
else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+18 && yAxis <= 72+18)
|
2014-01-10 04:09:48 +01:00
|
|
|
{
|
|
|
|
fluid = ((CachedIORecipe)arecipes.get(recipe)).fluidStack;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
if(gas != null)
|
|
|
|
{
|
|
|
|
if(button == 0)
|
|
|
|
{
|
|
|
|
if(doGasLookup(gas, false))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(button == 1)
|
|
|
|
{
|
|
|
|
if(doGasLookup(gas, true))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(fluid != null)
|
|
|
|
{
|
|
|
|
if(button == 0)
|
|
|
|
{
|
|
|
|
if(doFluidLookup(fluid, false))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(button == 1)
|
|
|
|
{
|
|
|
|
if(doFluidLookup(fluid, true))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
return super.mouseClicked(gui, button, recipe);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 04:09:48 +01:00
|
|
|
@Override
|
|
|
|
public int recipiesPerPage()
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe
|
|
|
|
{
|
|
|
|
public GasStack gasStack;
|
|
|
|
public FluidStack fluidStack;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 14:12:47 +01:00
|
|
|
/* true = condensentrating, false = decondensentrating */
|
|
|
|
public boolean type;
|
2014-01-10 04:09:48 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public PositionedStack getResult()
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
2014-01-10 02:52:19 +01:00
|
|
|
|
2014-01-10 14:12:47 +01:00
|
|
|
public CachedIORecipe(GasStack gas, FluidStack fluid, boolean b)
|
2014-01-10 04:09:48 +01:00
|
|
|
{
|
|
|
|
gasStack = gas;
|
|
|
|
fluidStack = fluid;
|
2014-01-10 14:12:47 +01:00
|
|
|
type = b;
|
2014-01-10 04:09:48 +01:00
|
|
|
}
|
|
|
|
}
|
2014-01-10 02:52:19 +01:00
|
|
|
}
|