Start work on Electrolytic Separator and Chemical Oxidizer recipe handlers. Also start work on gas/fluid NEI lookups!
This commit is contained in:
parent
973dd92931
commit
40684e2bab
5 changed files with 236 additions and 12 deletions
|
@ -101,6 +101,16 @@ public class GasStack
|
|||
return new GasStack(type, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not this GasStack's gas type is equal to the other defined GasStack.
|
||||
* @param stack - GasStack to check
|
||||
* @return if the GasStacks contain the same gas type
|
||||
*/
|
||||
public boolean isGasEqual(GasStack stack)
|
||||
{
|
||||
return stack != null && getGas() == stack.getGas();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ 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.PositionedStack;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public abstract class BaseRecipeHandler extends TemplateRecipeHandler
|
||||
|
@ -60,17 +59,8 @@ public abstract class BaseRecipeHandler extends TemplateRecipeHandler
|
|||
/*
|
||||
* true = usage, false = recipe
|
||||
*/
|
||||
public void doGasTransfer(int recipe, boolean type)
|
||||
public boolean doGasLookup(int recipe, boolean type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class ExtraRecipe extends TemplateRecipeHandler.CachedRecipe
|
||||
{
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
178
common/mekanism/client/nei/ChemicalInfuserRecipeHandler.java
Normal file
178
common/mekanism/client/nei/ChemicalInfuserRecipeHandler.java
Normal file
|
@ -0,0 +1,178 @@
|
|||
package mekanism.client.nei;
|
||||
|
||||
import static codechicken.core.gui.GuiDraw.changeTexture;
|
||||
import static codechicken.core.gui.GuiDraw.drawTexturedModalRect;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.ChemicalInput;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.client.gui.GuiChemicalInfuser;
|
||||
import mekanism.common.ObfuscatedNames;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.core.gui.GuiDraw;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public class ChemicalInfuserRecipeHandler extends BaseRecipeHandler
|
||||
{
|
||||
private int ticksPassed;
|
||||
|
||||
public int xOffset = 5;
|
||||
public int yOffset = 12;
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return "Chemical Infuser";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "chemicalinfuser";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture()
|
||||
{
|
||||
return "mekanism:gui/GuiChemicalInfuser.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getGuiClass()
|
||||
{
|
||||
return GuiChemicalInfuser.class;
|
||||
}
|
||||
|
||||
public String getRecipeId()
|
||||
{
|
||||
return "mekanism.chemicalinfuser";
|
||||
}
|
||||
|
||||
public Set<Entry<ChemicalInput, GasStack>> getRecipes()
|
||||
{
|
||||
return Recipe.CHEMICAL_INFUSER.get().entrySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int i)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
changeTexture(getGuiTexture());
|
||||
drawTexturedModalRect(0, 0, xOffset, yOffset, 147, 62);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int i)
|
||||
{
|
||||
GasStack gas = ((CachedIORecipe)arecipes.get(i)).outputStack;
|
||||
|
||||
float f = ticksPassed % 20 / 20.0F;
|
||||
drawProgressBar(64-xOffset, 40-yOffset, 176, 63, 48, 8, f, 0);
|
||||
|
||||
if(gas != null)
|
||||
{
|
||||
displayGauge(58, 134-xOffset, 14-yOffset, 176, 4, 58, null, gas);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
|
||||
ticksPassed++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects()
|
||||
{
|
||||
transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(64-5, 40-12, 48, 8), getRecipeId(), new Object[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results)
|
||||
{
|
||||
if(outputId.equals(getRecipeId()))
|
||||
{
|
||||
for(Map.Entry irecipe : getRecipes())
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe));
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTooltip(GuiRecipe gui, List<String> currenttip, 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)
|
||||
{
|
||||
currenttip.add(((CachedIORecipe)arecipes.get(recipe)).outputStack.getGas().getLocalizedName());
|
||||
}
|
||||
|
||||
return super.handleTooltip(gui, currenttip, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recipiesPerPage()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient)
|
||||
{
|
||||
for(Map.Entry irecipe : getRecipes())
|
||||
{
|
||||
if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getKey(), ingredient))
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe
|
||||
{
|
||||
public ChemicalInput chemicalInput;
|
||||
public GasStack outputStack;
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public CachedIORecipe(ChemicalInput input, GasStack output)
|
||||
{
|
||||
chemicalInput = input;
|
||||
outputStack = output;
|
||||
}
|
||||
|
||||
public CachedIORecipe(Map.Entry recipe)
|
||||
{
|
||||
this((ChemicalInput)recipe.getKey(), (GasStack)recipe.getValue());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@ import net.minecraft.item.ItemStack;
|
|||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.core.gui.GuiDraw;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
|
@ -113,6 +114,16 @@ public class ChemicalOxidizerRecipeHandler extends BaseRecipeHandler
|
|||
arecipes.add(new CachedIORecipe(irecipe));
|
||||
}
|
||||
}
|
||||
else if(outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack)
|
||||
{
|
||||
for(Map.Entry<ItemStack, GasStack> irecipe : getRecipes())
|
||||
{
|
||||
if(((GasStack)results[0]).isGasEqual(irecipe.getValue()))
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
|
@ -134,6 +145,35 @@ public class ChemicalOxidizerRecipeHandler extends BaseRecipeHandler
|
|||
return super.handleTooltip(gui, currenttip, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, 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)
|
||||
{
|
||||
if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe"))
|
||||
{
|
||||
if(doGasLookup(recipe, false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage"))
|
||||
{
|
||||
if(doGasLookup(recipe, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.keyTyped(gui, keyChar, keyCode, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recipiesPerPage()
|
||||
{
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
package mekanism.client.nei;
|
||||
|
||||
public class ElectrolyticSeparatorRecipeHandler //extends BaseRecipeHandler
|
||||
{
|
||||
|
||||
}
|
Loading…
Reference in a new issue