mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-20 03:59:37 +00:00
Re-added NEI
This commit is contained in:
1 parent
c8fb800c1a
commit
517c2a7655
23 files changed
+64
-52
No files matched your search
@@ -0,0 +1,268 @@
|
||||
package mekanism.client.nei;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.changeTexture;
|
||||
import static codechicken.lib.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.AdvancedInput;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.common.ObfuscatedNames;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler
|
||||
{
|
||||
private int ticksPassed;
|
||||
|
||||
public abstract String getRecipeId();
|
||||
|
||||
public abstract Set<Entry<AdvancedInput, ItemStack>> getRecipes();
|
||||
|
||||
public abstract List<ItemStack> getFuelStacks(Gas gasType);
|
||||
|
||||
@Override
|
||||
public void drawBackground(int i)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
changeTexture(getGuiTexture());
|
||||
drawTexturedModalRect(12, 0, 28, 5, 144, 68);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int i)
|
||||
{
|
||||
CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i);
|
||||
|
||||
float f = ticksPassed >= 20 ? (ticksPassed - 20) % 20 / 20.0F : 0;
|
||||
drawProgressBar(63, 34, 176, 0, 24, 7, f, 0);
|
||||
|
||||
if(recipe.input.gasType != null)
|
||||
{
|
||||
int displayInt = ticksPassed < 20 ? ticksPassed*12 / 20 : 12;
|
||||
displayGauge(45, 32 + 12 - displayInt, 6, displayInt, new GasStack(recipe.input.gasType, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
ticksPassed++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects()
|
||||
{
|
||||
transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(63, 34, 24, 7), getRecipeId(), new Object[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results)
|
||||
{
|
||||
if(outputId.equals(getRecipeId()))
|
||||
{
|
||||
for(Map.Entry<AdvancedInput, ItemStack> irecipe : getRecipes())
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe, getFuelStacks(irecipe.getKey().gasType)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result)
|
||||
{
|
||||
for(Map.Entry<AdvancedInput, ItemStack> irecipe : getRecipes())
|
||||
{
|
||||
if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getValue(), result))
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe, getFuelStacks(irecipe.getKey().gasType)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(String inputId, Object... ingredients)
|
||||
{
|
||||
if(inputId.equals("gas") && ingredients.length == 1 && ingredients[0] instanceof GasStack)
|
||||
{
|
||||
for(Map.Entry<AdvancedInput, ItemStack> irecipe : getRecipes())
|
||||
{
|
||||
if(irecipe.getKey().gasType == ((GasStack)ingredients[0]).getGas())
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe, getFuelStacks(irecipe.getKey().gasType)));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.loadUsageRecipes(inputId, ingredients);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient)
|
||||
{
|
||||
for(Map.Entry<AdvancedInput, ItemStack> irecipe : getRecipes())
|
||||
{
|
||||
if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getKey().itemStack, ingredient))
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe, getFuelStacks(irecipe.getKey().gasType)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTooltip(GuiRecipe gui, List<String> currenttip, int recipe)
|
||||
{
|
||||
Point point = GuiDraw.getMousePosition();
|
||||
Point offset = gui.getRecipePosition(recipe);
|
||||
|
||||
int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft)-offset.x;
|
||||
int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop)-offset.y;
|
||||
|
||||
if(xAxis >= 45 && xAxis <= 51 && yAxis >= 33 && yAxis <= 45)
|
||||
{
|
||||
currenttip.add(((CachedIORecipe)arecipes.get(recipe)).input.gasType.getLocalizedName());
|
||||
}
|
||||
|
||||
return super.handleTooltip(gui, currenttip, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe)
|
||||
{
|
||||
Point point = GuiDraw.getMousePosition();
|
||||
Point offset = gui.getRecipePosition(recipe);
|
||||
|
||||
int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft)-offset.x;
|
||||
int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop)-offset.y;
|
||||
|
||||
GasStack stack = null;
|
||||
|
||||
if(xAxis >= 45 && xAxis <= 51 && yAxis >= 33 && yAxis <= 45)
|
||||
{
|
||||
stack = new GasStack(((CachedIORecipe)arecipes.get(recipe)).input.gasType, 1);
|
||||
}
|
||||
|
||||
if(stack != null)
|
||||
{
|
||||
if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe"))
|
||||
{
|
||||
if(doGasLookup(stack, false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage"))
|
||||
{
|
||||
if(doGasLookup(stack, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.keyTyped(gui, keyChar, keyCode, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(GuiRecipe gui, int button, int recipe)
|
||||
{
|
||||
Point point = GuiDraw.getMousePosition();
|
||||
Point offset = gui.getRecipePosition(recipe);
|
||||
|
||||
int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft)-offset.x;
|
||||
int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop)-offset.y;
|
||||
|
||||
GasStack stack = null;
|
||||
|
||||
if(xAxis >= 45 && xAxis <= 51 && yAxis >= 33 && yAxis <= 45)
|
||||
{
|
||||
stack = new GasStack(((CachedIORecipe)arecipes.get(recipe)).input.gasType, 1);
|
||||
}
|
||||
|
||||
if(stack != null)
|
||||
{
|
||||
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 void addGuiElements()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe
|
||||
{
|
||||
public List<ItemStack> fuelStacks;
|
||||
|
||||
public AdvancedInput input;
|
||||
|
||||
public PositionedStack outputStack;
|
||||
|
||||
@Override
|
||||
public PositionedStack getIngredient()
|
||||
{
|
||||
return new PositionedStack(input.itemStack, 40, 12);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return outputStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getOtherStack()
|
||||
{
|
||||
return new PositionedStack(fuelStacks.get(cycleticks/40 % fuelStacks.size()), 40, 48);
|
||||
}
|
||||
|
||||
public CachedIORecipe(AdvancedInput adv, ItemStack output, List<ItemStack> fuels)
|
||||
{
|
||||
input = adv;
|
||||
outputStack = new PositionedStack(output, 100, 30);
|
||||
fuelStacks = fuels;
|
||||
}
|
||||
|
||||
public CachedIORecipe(Map.Entry recipe, List<ItemStack> fuels)
|
||||
{
|
||||
this((AdvancedInput)recipe.getKey(), (ItemStack)recipe.getValue(), fuels);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
package mekanism.client.nei;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.changeTexture;
|
||||
import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect;
|
||||
import static codechicken.lib.gui.GuiDraw.gui;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.client.gui.GuiElement;
|
||||
import mekanism.client.gui.IGuiWrapper;
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.util.IIcon;
|
||||
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 implements IGuiWrapper
|
||||
{
|
||||
public BaseRecipeHandler()
|
||||
{
|
||||
addGuiElements();
|
||||
}
|
||||
|
||||
public Set<GuiElement> guiElements = new HashSet<GuiElement>();
|
||||
|
||||
public abstract void addGuiElements();
|
||||
|
||||
public void displayGauge(int length, int xPos, int yPos, int overlayX, int overlayY, int scale, FluidStack fluid, GasStack gas)
|
||||
{
|
||||
if(fluid == null && gas == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int start = 0;
|
||||
|
||||
while(true)
|
||||
{
|
||||
int renderRemaining = 0;
|
||||
|
||||
if(scale > 16)
|
||||
{
|
||||
renderRemaining = 16;
|
||||
scale -= 16;
|
||||
}
|
||||
else {
|
||||
renderRemaining = scale;
|
||||
scale = 0;
|
||||
}
|
||||
|
||||
changeTexture(MekanismRenderer.getBlocksTexture());
|
||||
|
||||
if(fluid != null)
|
||||
{
|
||||
gui.drawTexturedModelRectFromIcon(xPos, yPos + length - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining));
|
||||
}
|
||||
else if(gas != null)
|
||||
{
|
||||
gui.drawTexturedModelRectFromIcon(xPos, yPos + length - renderRemaining - start, gas.getGas().getIcon(), 16, 16 - (16 - renderRemaining));
|
||||
}
|
||||
|
||||
start+=16;
|
||||
|
||||
if(renderRemaining == 0 || scale == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
changeTexture(getGuiTexture());
|
||||
drawTexturedModalRect(xPos, yPos, overlayX, overlayY, 16, length+1);
|
||||
}
|
||||
|
||||
/*
|
||||
* true = usage, false = recipe
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
public void displayGauge(int xPos, int yPos, int sizeX, int sizeY, GasStack gas)
|
||||
{
|
||||
if(gas == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
changeTexture(MekanismRenderer.getBlocksTexture());
|
||||
gui.drawTexturedModelRectFromIcon(xPos, yPos, gas.getGas().getIcon(), sizeX, sizeY);
|
||||
}
|
||||
|
||||
/*
|
||||
* true = usage, false = recipe
|
||||
*/
|
||||
public boolean doFluidLookup(FluidStack stack, boolean type)
|
||||
{
|
||||
if(stack != null && stack.amount > 0)
|
||||
{
|
||||
if(type)
|
||||
{
|
||||
if(!GuiUsageRecipe.openRecipeGui("fluid", new Object[] {stack}))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!GuiCraftingRecipe.openRecipeGui("fluid", new Object[] {stack}))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTexturedRect(int x, int y, int u, int v, int w, int h)
|
||||
{
|
||||
drawTexturedModalRect(x, y, u, v, w, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTexturedRectFromIcon(int x, int y, IIcon icon, int w, int h)
|
||||
{
|
||||
gui.drawTexturedModelRectFromIcon(x, y, icon, w, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayTooltip(String s, int xAxis, int yAxis) {}
|
||||
|
||||
@Override
|
||||
public void displayTooltips(List<String> list, int xAxis, int yAxis) {}
|
||||
|
||||
@Override
|
||||
public FontRenderer getFont()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
package mekanism.client.nei;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.changeTexture;
|
||||
import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect;
|
||||
import static codechicken.lib.gui.GuiDraw.drawString;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.ChanceOutput;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public abstract class ChanceMachineRecipeHandler extends TemplateRecipeHandler
|
||||
{
|
||||
private int ticksPassed;
|
||||
|
||||
public abstract String getRecipeId();
|
||||
|
||||
public abstract Set<Entry<ItemStack, ChanceOutput>> getRecipes();
|
||||
|
||||
@Override
|
||||
public void drawBackground(int i)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
changeTexture(getGuiTexture());
|
||||
drawTexturedModalRect(12, 0, 28, 5, 144, 68);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int i)
|
||||
{
|
||||
CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i);
|
||||
|
||||
float f = ticksPassed >= 20 ? (ticksPassed - 20) % 20 / 20.0F : 0.0F;
|
||||
drawProgressBar(63, 34, 176, 0, 24, 7, f, 0);
|
||||
f = ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F;
|
||||
drawProgressBar(149, 12, 176, 7, 4, 52, f, 3);
|
||||
|
||||
if(recipe.output.hasSecondary())
|
||||
{
|
||||
drawString(Math.round(recipe.output.secondaryChance*100) + "%", 116, 52, 0x404040, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
ticksPassed++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects()
|
||||
{
|
||||
transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(63, 34, 24, 7), 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 void loadCraftingRecipes(ItemStack result)
|
||||
{
|
||||
for(Map.Entry<ItemStack, ChanceOutput> irecipe : getRecipes())
|
||||
{
|
||||
if(irecipe.getValue().hasPrimary() && NEIServerUtils.areStacksSameTypeCrafting(irecipe.getValue().primaryOutput, result))
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe));
|
||||
}
|
||||
else if(irecipe.getValue().hasSecondary() && NEIServerUtils.areStacksSameTypeCrafting(irecipe.getValue().secondaryOutput, result))
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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 PositionedStack input;
|
||||
public ChanceOutput output;
|
||||
|
||||
@Override
|
||||
public PositionedStack getIngredient()
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
if(output.hasPrimary())
|
||||
{
|
||||
return new PositionedStack(output.primaryOutput, 100, 30);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getOtherStack()
|
||||
{
|
||||
if(output.hasSecondary())
|
||||
{
|
||||
return new PositionedStack(output.secondaryOutput, 116, 30);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public CachedIORecipe(ItemStack itemstack, ChanceOutput chance)
|
||||
{
|
||||
input = new PositionedStack(itemstack, 40, 12);
|
||||
output = chance;
|
||||
}
|
||||
|
||||
public CachedIORecipe(Map.Entry recipe)
|
||||
{
|
||||
this((ItemStack)recipe.getKey(), (ChanceOutput)recipe.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
package mekanism.client.nei;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.changeTexture;
|
||||
import static codechicken.lib.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.gas.GasStack;
|
||||
import mekanism.client.gui.GuiChemicalCrystallizer;
|
||||
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.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public class ChemicalCrystallizerRecipeHandler extends BaseRecipeHandler
|
||||
{
|
||||
private int ticksPassed;
|
||||
|
||||
public static int xOffset = 5;
|
||||
public static int yOffset = 3;
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return MekanismUtils.localize("tile.MachineBlock2.ChemicalCrystallizer.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "chemicalcrystallizer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture()
|
||||
{
|
||||
return "mekanism:gui/nei/GuiChemicalCrystallizer.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getGuiClass()
|
||||
{
|
||||
return GuiChemicalCrystallizer.class;
|
||||
}
|
||||
|
||||
public String getRecipeId()
|
||||
{
|
||||
return "mekanism.chemicalcrystallizer";
|
||||
}
|
||||
|
||||
public Set<Entry<GasStack, ItemStack>> getRecipes()
|
||||
{
|
||||
return Recipe.CHEMICAL_CRYSTALLIZER.get().entrySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int i)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
changeTexture(getGuiTexture());
|
||||
drawTexturedModalRect(-2, 0, 3, yOffset, 147, 79);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int i)
|
||||
{
|
||||
GasStack gas = ((CachedIORecipe)arecipes.get(i)).inputStack;
|
||||
|
||||
float f = ticksPassed % 20 / 20.0F;
|
||||
drawProgressBar(53-xOffset, 61-yOffset, 176, 63, 48, 8, f, 0);
|
||||
|
||||
if(gas != null)
|
||||
{
|
||||
displayGauge(58, 6-xOffset, 5-yOffset, 176, 4, 58, null, gas);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
|
||||
ticksPassed++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects()
|
||||
{
|
||||
transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(53-xOffset, 61-yOffset, 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 void loadCraftingRecipes(ItemStack result)
|
||||
{
|
||||
for(Map.Entry irecipe : getRecipes())
|
||||
{
|
||||
if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getValue(), result))
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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 >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13)
|
||||
{
|
||||
currenttip.add(((CachedIORecipe)arecipes.get(recipe)).inputStack.getGas().getLocalizedName());
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
GasStack stack = null;
|
||||
|
||||
if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13)
|
||||
{
|
||||
stack = ((CachedIORecipe)arecipes.get(recipe)).inputStack;
|
||||
}
|
||||
|
||||
if(stack != null)
|
||||
{
|
||||
if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe"))
|
||||
{
|
||||
if(doGasLookup(stack, false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage"))
|
||||
{
|
||||
if(doGasLookup(stack, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
GasStack stack = null;
|
||||
|
||||
if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13)
|
||||
{
|
||||
stack = ((CachedIORecipe)arecipes.get(recipe)).inputStack;
|
||||
}
|
||||
|
||||
if(stack != null)
|
||||
{
|
||||
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()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(String inputId, Object... ingredients)
|
||||
{
|
||||
if(inputId.equals("gas") && ingredients.length == 1 && ingredients[0] instanceof GasStack)
|
||||
{
|
||||
for(Map.Entry<GasStack, ItemStack> irecipe : getRecipes())
|
||||
{
|
||||
if(irecipe.getKey().isGasEqual((GasStack)ingredients[0]))
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.loadUsageRecipes(inputId, ingredients);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGuiElements()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe
|
||||
{
|
||||
public GasStack inputStack;
|
||||
public PositionedStack outputStack;
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return outputStack;
|
||||
}
|
||||
|
||||
public CachedIORecipe(GasStack input, ItemStack output)
|
||||
{
|
||||
inputStack = input;
|
||||
outputStack = new PositionedStack(output, 131-xOffset, 57-yOffset);
|
||||
}
|
||||
|
||||
public CachedIORecipe(Map.Entry recipe)
|
||||
{
|
||||
this((GasStack)recipe.getKey(), (ItemStack)recipe.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,289 @@
|
||||
package mekanism.client.nei;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.changeTexture;
|
||||
import static codechicken.lib.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.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.client.gui.GuiChemicalDissolutionChamber;
|
||||
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 net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public class ChemicalDissolutionChamberRecipeHandler extends BaseRecipeHandler
|
||||
{
|
||||
private int ticksPassed;
|
||||
|
||||
public static int xOffset = 5;
|
||||
public static int yOffset = 3;
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return MekanismUtils.localize("gui.chemicalDissolutionChamber.short");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "chemicaldissolutionchamber";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture()
|
||||
{
|
||||
return "mekanism:gui/nei/GuiChemicalDissolutionChamber.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getGuiClass()
|
||||
{
|
||||
return GuiChemicalDissolutionChamber.class;
|
||||
}
|
||||
|
||||
public String getRecipeId()
|
||||
{
|
||||
return "mekanism.chemicaldissolutionchamber";
|
||||
}
|
||||
|
||||
public Set<Entry<ItemStack, GasStack>> getRecipes()
|
||||
{
|
||||
return Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().entrySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int i)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
changeTexture(getGuiTexture());
|
||||
drawTexturedModalRect(-2, 0, 3, yOffset, 170, 79);
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
displayGauge(58, 6-xOffset, 5-yOffset, 176, 4, 58, null, new GasStack(GasRegistry.getGas("sulfuricAcid"), 1));
|
||||
|
||||
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-xOffset, 40-yOffset, 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 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);
|
||||
}
|
||||
}
|
||||
|
||||
@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 >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13)
|
||||
{
|
||||
currenttip.add(GasRegistry.getGas("sulfuricAcid").getLocalizedName());
|
||||
}
|
||||
else 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 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);
|
||||
|
||||
GasStack stack = null;
|
||||
|
||||
if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13)
|
||||
{
|
||||
stack = new GasStack(GasRegistry.getGas("sulfuricAcid"), 1);
|
||||
}
|
||||
else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+4 && yAxis <= 72+4)
|
||||
{
|
||||
stack = ((CachedIORecipe)arecipes.get(recipe)).outputStack;
|
||||
}
|
||||
|
||||
if(stack != null)
|
||||
{
|
||||
if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe"))
|
||||
{
|
||||
if(doGasLookup(stack, false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage"))
|
||||
{
|
||||
if(doGasLookup(stack, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
GasStack stack = null;
|
||||
|
||||
if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13)
|
||||
{
|
||||
stack = new GasStack(GasRegistry.getGas("sulfuricAcid"), 1);
|
||||
}
|
||||
else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+4 && yAxis <= 72+4)
|
||||
{
|
||||
stack = ((CachedIORecipe)arecipes.get(recipe)).outputStack;
|
||||
}
|
||||
|
||||
if(stack != null)
|
||||
{
|
||||
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()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient)
|
||||
{
|
||||
for(Map.Entry irecipe : getRecipes())
|
||||
{
|
||||
if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getKey(), ingredient))
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGuiElements()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe
|
||||
{
|
||||
public PositionedStack inputStack;
|
||||
public GasStack outputStack;
|
||||
|
||||
@Override
|
||||
public PositionedStack getIngredient()
|
||||
{
|
||||
return inputStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public CachedIORecipe(ItemStack input, GasStack output)
|
||||
{
|
||||
inputStack = new PositionedStack(input, 26-xOffset, 36-yOffset);
|
||||
outputStack = output;
|
||||
}
|
||||
|
||||
public CachedIORecipe(Map.Entry recipe)
|
||||
{
|
||||
this((ItemStack)recipe.getKey(), (GasStack)recipe.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
package mekanism.client.nei;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.changeTexture;
|
||||
import static codechicken.lib.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.ChemicalPair;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.client.gui.GuiChemicalInfuser;
|
||||
import mekanism.client.nei.ChemicalOxidizerRecipeHandler.CachedIORecipe;
|
||||
import mekanism.common.ObfuscatedNames;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public class ChemicalInfuserRecipeHandler extends BaseRecipeHandler
|
||||
{
|
||||
private int ticksPassed;
|
||||
|
||||
public static int xOffset = 5;
|
||||
public static int yOffset = 3;
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return MekanismUtils.localize("tile.MachineBlock2.ChemicalInfuser.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "chemicalinfuser";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture()
|
||||
{
|
||||
return "mekanism:gui/nei/GuiChemicalInfuser.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getGuiClass()
|
||||
{
|
||||
return GuiChemicalInfuser.class;
|
||||
}
|
||||
|
||||
public String getRecipeId()
|
||||
{
|
||||
return "mekanism.chemicalinfuser";
|
||||
}
|
||||
|
||||
public Set<Entry<ChemicalPair, 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(-2, 0, 3, yOffset, 170, 80);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int i)
|
||||
{
|
||||
CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i);
|
||||
|
||||
drawTexturedModalRect(47-xOffset, 39-yOffset, 176, 71, 28, 8);
|
||||
drawTexturedModalRect(101-xOffset, 39-yOffset, 176, 63, 28, 8);
|
||||
|
||||
if(recipe.chemicalInput.leftGas != null)
|
||||
{
|
||||
displayGauge(58, 26-xOffset, 14-yOffset, 176, 4, 58, null, recipe.chemicalInput.leftGas);
|
||||
}
|
||||
|
||||
if(recipe.outputStack != null)
|
||||
{
|
||||
displayGauge(58, 80-xOffset, 5-yOffset, 176, 4, 58, null, recipe.outputStack);
|
||||
}
|
||||
|
||||
if(recipe.chemicalInput.rightGas != null)
|
||||
{
|
||||
displayGauge(58, 134-xOffset, 14-yOffset, 176, 4, 58, null, recipe.chemicalInput.rightGas);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
|
||||
ticksPassed++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects()
|
||||
{
|
||||
transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(47-xOffset, 39-yOffset, 28, 8), getRecipeId(), new Object[0]));
|
||||
transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(101-xOffset, 39-yOffset, 28, 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 if(outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack)
|
||||
{
|
||||
for(Map.Entry<ChemicalPair, GasStack> irecipe : getRecipes())
|
||||
{
|
||||
if(((GasStack)results[0]).isGasEqual(irecipe.getValue()))
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(String inputId, Object... ingredients)
|
||||
{
|
||||
if(inputId.equals("gas") && ingredients.length == 1 && ingredients[0] instanceof GasStack)
|
||||
{
|
||||
for(Map.Entry<ChemicalPair, GasStack> irecipe : getRecipes())
|
||||
{
|
||||
if(irecipe.getKey().containsType((GasStack)ingredients[0]))
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.loadUsageRecipes(inputId, ingredients);
|
||||
}
|
||||
}
|
||||
|
||||
@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 >= 26 && xAxis <= 42 && yAxis >= 14+13 && yAxis <= 72+13)
|
||||
{
|
||||
currenttip.add(((CachedIORecipe)arecipes.get(recipe)).chemicalInput.leftGas.getGas().getLocalizedName());
|
||||
}
|
||||
else if(xAxis >= 80 && xAxis <= 96 && yAxis >= 5+13 && yAxis <= 63+13)
|
||||
{
|
||||
currenttip.add(((CachedIORecipe)arecipes.get(recipe)).outputStack.getGas().getLocalizedName());
|
||||
}
|
||||
else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+13 && yAxis <= 72+13)
|
||||
{
|
||||
currenttip.add(((CachedIORecipe)arecipes.get(recipe)).chemicalInput.rightGas.getGas().getLocalizedName());
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
GasStack stack = null;
|
||||
|
||||
if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+13 && yAxis <= 72+13)
|
||||
{
|
||||
stack = ((CachedIORecipe)arecipes.get(recipe)).chemicalInput.leftGas;
|
||||
}
|
||||
else if(xAxis >= 80 && xAxis <= 96 && yAxis >= 5+13 && yAxis <= 63+13)
|
||||
{
|
||||
stack = ((CachedIORecipe)arecipes.get(recipe)).outputStack;
|
||||
}
|
||||
else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+13 && yAxis <= 72+13)
|
||||
{
|
||||
stack = ((CachedIORecipe)arecipes.get(recipe)).chemicalInput.rightGas;
|
||||
}
|
||||
|
||||
if(stack != null)
|
||||
{
|
||||
if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe"))
|
||||
{
|
||||
if(doGasLookup(stack, false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage"))
|
||||
{
|
||||
if(doGasLookup(stack, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
GasStack stack = null;
|
||||
|
||||
if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+13 && yAxis <= 72+13)
|
||||
{
|
||||
stack = ((CachedIORecipe)arecipes.get(recipe)).chemicalInput.leftGas;
|
||||
}
|
||||
else if(xAxis >= 80 && xAxis <= 96 && yAxis >= 5+13 && yAxis <= 63+13)
|
||||
{
|
||||
stack = ((CachedIORecipe)arecipes.get(recipe)).outputStack;
|
||||
}
|
||||
else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+13 && yAxis <= 72+13)
|
||||
{
|
||||
stack = ((CachedIORecipe)arecipes.get(recipe)).chemicalInput.rightGas;
|
||||
}
|
||||
|
||||
if(stack != null)
|
||||
{
|
||||
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()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGuiElements()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe
|
||||
{
|
||||
public ChemicalPair chemicalInput;
|
||||
public GasStack outputStack;
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public CachedIORecipe(ChemicalPair input, GasStack output)
|
||||
{
|
||||
chemicalInput = input;
|
||||
outputStack = output;
|
||||
}
|
||||
|
||||
public CachedIORecipe(Map.Entry recipe)
|
||||
{
|
||||
this((ChemicalPair)recipe.getKey(), (GasStack)recipe.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package mekanism.client.nei;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.ListUtils;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.client.gui.GuiChemicalInjectionChamber;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class ChemicalInjectionChamberRecipeHandler extends AdvancedMachineRecipeHandler
|
||||
{
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return MekanismUtils.localize("nei.chemicalInjectionChamber");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeId()
|
||||
{
|
||||
return "mekanism.chemicalinjectionchamber";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "chemicalinjectionchamber";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set getRecipes()
|
||||
{
|
||||
return Recipe.CHEMICAL_INJECTION_CHAMBER.get().entrySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture()
|
||||
{
|
||||
return "mekanism:gui/GuiChemicalInjectionChamber.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getFuelStacks(Gas gasType)
|
||||
{
|
||||
if(gasType == GasRegistry.getGas("sulfuricAcid"))
|
||||
{
|
||||
List<ItemStack> fuels = OreDictionary.getOres("dustSulfur");
|
||||
fuels.add(MekanismUtils.getFullGasTank(GasRegistry.getGas("sulfuricAcid")));
|
||||
return fuels;
|
||||
}
|
||||
else if(gasType == GasRegistry.getGas("water"))
|
||||
{
|
||||
return ListUtils.asList(MekanismUtils.getFullGasTank(GasRegistry.getGas("water")));
|
||||
}
|
||||
else if(gasType == GasRegistry.getGas("hydrogenChloride"))
|
||||
{
|
||||
List<ItemStack> fuels = OreDictionary.getOres("dustSalt");
|
||||
fuels.add(MekanismUtils.getFullGasTank(GasRegistry.getGas("hydrogenChloride")));
|
||||
return fuels;
|
||||
}
|
||||
|
||||
return new ArrayList<ItemStack>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getGuiClass()
|
||||
{
|
||||
return GuiChemicalInjectionChamber.class;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
package mekanism.client.nei;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.changeTexture;
|
||||
import static codechicken.lib.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.gas.GasStack;
|
||||
import mekanism.client.gui.GuiChemicalOxidizer;
|
||||
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.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public class ChemicalOxidizerRecipeHandler extends BaseRecipeHandler
|
||||
{
|
||||
private int ticksPassed;
|
||||
|
||||
public static int xOffset = 5;
|
||||
public static int yOffset = 12;
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return MekanismUtils.localize("tile.MachineBlock2.ChemicalOxidizer.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "chemicaloxidizer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture()
|
||||
{
|
||||
return "mekanism:gui/GuiChemicalOxidizer.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getGuiClass()
|
||||
{
|
||||
return GuiChemicalOxidizer.class;
|
||||
}
|
||||
|
||||
public String getRecipeId()
|
||||
{
|
||||
return "mekanism.chemicaloxidizer";
|
||||
}
|
||||
|
||||
public Set<Entry<ItemStack, GasStack>> getRecipes()
|
||||
{
|
||||
return Recipe.CHEMICAL_OXIDIZER.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-xOffset, 40-yOffset, 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 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);
|
||||
}
|
||||
}
|
||||
|
||||
@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 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)
|
||||
{
|
||||
GasStack stack = ((CachedIORecipe)arecipes.get(recipe)).outputStack;
|
||||
|
||||
if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe"))
|
||||
{
|
||||
if(doGasLookup(stack, false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage"))
|
||||
{
|
||||
if(doGasLookup(stack, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGuiElements()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe
|
||||
{
|
||||
public PositionedStack inputStack;
|
||||
public GasStack outputStack;
|
||||
|
||||
@Override
|
||||
public PositionedStack getIngredient()
|
||||
{
|
||||
return inputStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public CachedIORecipe(ItemStack input, GasStack output)
|
||||
{
|
||||
inputStack = new PositionedStack(input, 26-xOffset, 36-yOffset);
|
||||
outputStack = output;
|
||||
}
|
||||
|
||||
public CachedIORecipe(Map.Entry recipe)
|
||||
{
|
||||
this((ItemStack)recipe.getKey(), (GasStack)recipe.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
package mekanism.client.nei;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.changeTexture;
|
||||
import static codechicken.lib.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.ChemicalPair;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.client.gui.GuiChemicalWasher;
|
||||
import mekanism.common.ObfuscatedNames;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public class ChemicalWasherRecipeHandler extends BaseRecipeHandler
|
||||
{
|
||||
private int ticksPassed;
|
||||
|
||||
public static int xOffset = 5;
|
||||
public static int yOffset = 3;
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return MekanismUtils.localize("tile.MachineBlock2.ChemicalWasher.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "chemicalwasher";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture()
|
||||
{
|
||||
return "mekanism:gui/nei/GuiChemicalWasher.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getGuiClass()
|
||||
{
|
||||
return GuiChemicalWasher.class;
|
||||
}
|
||||
|
||||
public String getRecipeId()
|
||||
{
|
||||
return "mekanism.chemicalwasher";
|
||||
}
|
||||
|
||||
public Set<Entry<GasStack, GasStack>> getRecipes()
|
||||
{
|
||||
return Recipe.CHEMICAL_WASHER.get().entrySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int i)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
changeTexture(getGuiTexture());
|
||||
drawTexturedModalRect(-2, 0, 3, yOffset, 170, 70);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int i)
|
||||
{
|
||||
CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i);
|
||||
|
||||
drawTexturedModalRect(61-xOffset, 39-yOffset, 176, 63, 55, 8);
|
||||
|
||||
displayGauge(58, 6-xOffset, 5-yOffset, 176, 4, 58, new FluidStack(FluidRegistry.WATER, 1), null);
|
||||
|
||||
if(recipe.outputStack != null)
|
||||
{
|
||||
displayGauge(58, 27-xOffset, 14-yOffset, 176, 4, 58, null, recipe.inputStack);
|
||||
}
|
||||
|
||||
if(recipe.inputStack != null)
|
||||
{
|
||||
displayGauge(58, 134-xOffset, 14-yOffset, 176, 4, 58, null, recipe.outputStack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
|
||||
ticksPassed++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects()
|
||||
{
|
||||
transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(61-xOffset, 39-yOffset, 55, 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 if(outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack)
|
||||
{
|
||||
for(Map.Entry<GasStack, GasStack> irecipe : getRecipes())
|
||||
{
|
||||
if(((GasStack)results[0]).isGasEqual(irecipe.getValue()))
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(String inputId, Object... ingredients)
|
||||
{
|
||||
if(inputId.equals("fluid") && ingredients.length == 1 && ingredients[0] instanceof FluidStack)
|
||||
{
|
||||
if(((FluidStack)ingredients[0]).getFluid() == FluidRegistry.WATER)
|
||||
{
|
||||
for(Map.Entry<GasStack, GasStack> irecipe : getRecipes())
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(inputId.equals("gas") && ingredients.length == 1 && ingredients[0] instanceof GasStack)
|
||||
{
|
||||
for(Map.Entry<GasStack, GasStack> irecipe : getRecipes())
|
||||
{
|
||||
if(irecipe.getKey().isGasEqual((GasStack)ingredients[0]))
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.loadUsageRecipes(inputId, ingredients);
|
||||
}
|
||||
}
|
||||
|
||||
@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 >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13)
|
||||
{
|
||||
currenttip.add(FluidRegistry.WATER.getLocalizedName());
|
||||
}
|
||||
else if(xAxis >= 27 && xAxis <= 43 && yAxis >= 14+13 && yAxis <= 72+13)
|
||||
{
|
||||
currenttip.add(((CachedIORecipe)arecipes.get(recipe)).inputStack.getGas().getLocalizedName());
|
||||
}
|
||||
else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+13 && yAxis <= 72+13)
|
||||
{
|
||||
currenttip.add(((CachedIORecipe)arecipes.get(recipe)).outputStack.getGas().getLocalizedName());
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
GasStack gas = null;
|
||||
FluidStack fluid = null;
|
||||
|
||||
if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13)
|
||||
{
|
||||
fluid = new FluidStack(FluidRegistry.WATER, 1);
|
||||
}
|
||||
else if(xAxis >= 27 && xAxis <= 43 && yAxis >= 14+13 && yAxis <= 72+13)
|
||||
{
|
||||
gas = ((CachedIORecipe)arecipes.get(recipe)).inputStack;
|
||||
}
|
||||
else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+13 && yAxis <= 72+13)
|
||||
{
|
||||
gas = ((CachedIORecipe)arecipes.get(recipe)).outputStack;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
GasStack gas = null;
|
||||
FluidStack fluid = null;
|
||||
|
||||
if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13)
|
||||
{
|
||||
fluid = new FluidStack(FluidRegistry.WATER, 1);
|
||||
}
|
||||
else if(xAxis >= 27 && xAxis <= 43 && yAxis >= 14+13 && yAxis <= 72+13)
|
||||
{
|
||||
gas = ((CachedIORecipe)arecipes.get(recipe)).inputStack;
|
||||
}
|
||||
else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+13 && yAxis <= 72+13)
|
||||
{
|
||||
gas = ((CachedIORecipe)arecipes.get(recipe)).outputStack;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.mouseClicked(gui, button, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recipiesPerPage()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGuiElements()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe
|
||||
{
|
||||
public GasStack inputStack;
|
||||
public GasStack outputStack;
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public CachedIORecipe(GasStack input, GasStack output)
|
||||
{
|
||||
inputStack = input;
|
||||
outputStack = output;
|
||||
}
|
||||
|
||||
public CachedIORecipe(Map.Entry recipe)
|
||||
{
|
||||
this((GasStack)recipe.getKey(), (GasStack)recipe.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package mekanism.client.nei;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.ListUtils;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.client.gui.GuiCombiner;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class CombinerRecipeHandler extends AdvancedMachineRecipeHandler
|
||||
{
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return MekanismUtils.localize("tile.MachineBlock.Combiner.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeId()
|
||||
{
|
||||
return "mekanism.combiner";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "combiner";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set getRecipes()
|
||||
{
|
||||
return Recipe.COMBINER.get().entrySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture()
|
||||
{
|
||||
return "mekanism:gui/GuiCombiner.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getFuelStacks(Gas gasType)
|
||||
{
|
||||
return ListUtils.asList(new ItemStack(Blocks.cobblestone));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getGuiClass()
|
||||
{
|
||||
return GuiCombiner.class;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package mekanism.client.nei;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.client.gui.GuiCrusher;
|
||||
import mekanism.client.gui.GuiSlot;
|
||||
import mekanism.client.gui.GuiSlot.SlotType;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
|
||||
public class CrusherRecipeHandler extends MachineRecipeHandler
|
||||
{
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return MekanismUtils.localize("tile.MachineBlock.Crusher.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeId()
|
||||
{
|
||||
return "mekanism.crusher";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "crusher";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set getRecipes()
|
||||
{
|
||||
return Recipe.CRUSHER.get().entrySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getGuiClass()
|
||||
{
|
||||
return GuiCrusher.class;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,342 @@
|
||||
package mekanism.client.nei;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.changeTexture;
|
||||
import static codechicken.lib.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.ChemicalPair;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.client.gui.GuiElectrolyticSeparator;
|
||||
import mekanism.common.ObfuscatedNames;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public class ElectrolyticSeparatorRecipeHandler extends BaseRecipeHandler
|
||||
{
|
||||
private int ticksPassed;
|
||||
|
||||
public static int xOffset = 5;
|
||||
public static int yOffset = 9;
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return MekanismUtils.localize("tile.MachineBlock2.ElectrolyticSeparator.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "electrolyticseparator";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture()
|
||||
{
|
||||
return "mekanism:gui/GuiElectrolyticSeparator.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getGuiClass()
|
||||
{
|
||||
return GuiElectrolyticSeparator.class;
|
||||
}
|
||||
|
||||
public String getRecipeId()
|
||||
{
|
||||
return "mekanism.electrolyticseparator";
|
||||
}
|
||||
|
||||
public Set<Entry<FluidStack, ChemicalPair>> getRecipes()
|
||||
{
|
||||
return Recipe.ELECTROLYTIC_SEPARATOR.get().entrySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int i)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
changeTexture(getGuiTexture());
|
||||
drawTexturedModalRect(-1, 0, 4, yOffset, 167, 62);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int i)
|
||||
{
|
||||
CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i);
|
||||
|
||||
float f = ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F;
|
||||
drawProgressBar(165-xOffset, 17-yOffset, 176, 0, 4, 52, f, 3);
|
||||
|
||||
if(recipe.fluidInput != null)
|
||||
{
|
||||
displayGauge(58, 6-xOffset, 11-yOffset, 176, 68, 58, recipe.fluidInput, null);
|
||||
}
|
||||
|
||||
if(recipe.outputPair.leftGas != null)
|
||||
{
|
||||
displayGauge(28, 59-xOffset, 19-yOffset, 176, 68, 28, null, recipe.outputPair.leftGas);
|
||||
}
|
||||
|
||||
if(recipe.outputPair.rightGas != null)
|
||||
{
|
||||
displayGauge(28, 101-xOffset, 19-yOffset, 176, 68, 28, null, recipe.outputPair.rightGas);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
|
||||
ticksPassed++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects()
|
||||
{
|
||||
transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(80-xOffset, 30-yOffset, 16, 6), 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 if(outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack)
|
||||
{
|
||||
for(Map.Entry<FluidStack, ChemicalPair> irecipe : getRecipes())
|
||||
{
|
||||
if(irecipe.getValue().containsType((GasStack)results[0]))
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(String inputId, Object... ingredients)
|
||||
{
|
||||
if(inputId.equals("fluid") && ingredients.length == 1 && ingredients[0] instanceof FluidStack)
|
||||
{
|
||||
for(Map.Entry<FluidStack, ChemicalPair> irecipe : getRecipes())
|
||||
{
|
||||
if(irecipe.getKey().isFluidEqual((FluidStack)ingredients[0]))
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.loadUsageRecipes(inputId, ingredients);
|
||||
}
|
||||
}
|
||||
|
||||
@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 >= 6 && xAxis <= 22 && yAxis >= 11+7 && yAxis <= 69+7)
|
||||
{
|
||||
currenttip.add(((CachedIORecipe)arecipes.get(recipe)).fluidInput.getFluid().getLocalizedName());
|
||||
}
|
||||
else if(xAxis >= 59 && xAxis <= 75 && yAxis >= 19+7 && yAxis <= 47+7)
|
||||
{
|
||||
currenttip.add(((CachedIORecipe)arecipes.get(recipe)).outputPair.leftGas.getGas().getLocalizedName());
|
||||
}
|
||||
else if(xAxis >= 101 && xAxis <= 117 && yAxis >= 19+7 && yAxis <= 47+7)
|
||||
{
|
||||
currenttip.add(((CachedIORecipe)arecipes.get(recipe)).outputPair.rightGas.getGas().getLocalizedName());
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
GasStack gas = null;
|
||||
FluidStack fluid = null;
|
||||
|
||||
if(xAxis >= 6 && xAxis <= 22 && yAxis >= 11+7 && yAxis <= 69+7)
|
||||
{
|
||||
fluid = ((CachedIORecipe)arecipes.get(recipe)).fluidInput;
|
||||
}
|
||||
else if(xAxis >= 59 && xAxis <= 75 && yAxis >= 19+7 && yAxis <= 47+7)
|
||||
{
|
||||
gas = ((CachedIORecipe)arecipes.get(recipe)).outputPair.leftGas;
|
||||
}
|
||||
else if(xAxis >= 101 && xAxis <= 117 && yAxis >= 19+7 && yAxis <= 47+7)
|
||||
{
|
||||
gas = ((CachedIORecipe)arecipes.get(recipe)).outputPair.rightGas;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
GasStack gas = null;
|
||||
FluidStack fluid = null;
|
||||
|
||||
if(xAxis >= 6 && xAxis <= 22 && yAxis >= 11+7 && yAxis <= 69+7)
|
||||
{
|
||||
fluid = ((CachedIORecipe)arecipes.get(recipe)).fluidInput;
|
||||
}
|
||||
else if(xAxis >= 59 && xAxis <= 75 && yAxis >= 19+7 && yAxis <= 47+7)
|
||||
{
|
||||
gas = ((CachedIORecipe)arecipes.get(recipe)).outputPair.leftGas;
|
||||
}
|
||||
else if(xAxis >= 101 && xAxis <= 117 && yAxis >= 19+7 && yAxis <= 47+7)
|
||||
{
|
||||
gas = ((CachedIORecipe)arecipes.get(recipe)).outputPair.rightGas;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.mouseClicked(gui, button, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recipiesPerPage()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGuiElements()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe
|
||||
{
|
||||
public FluidStack fluidInput;
|
||||
public ChemicalPair outputPair;
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public CachedIORecipe(FluidStack input, ChemicalPair pair)
|
||||
{
|
||||
fluidInput = input;
|
||||
outputPair = pair;
|
||||
}
|
||||
|
||||
public CachedIORecipe(Map.Entry recipe)
|
||||
{
|
||||
this((FluidStack)recipe.getKey(), (ChemicalPair)recipe.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package mekanism.client.nei;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.client.gui.GuiEnrichmentChamber;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
|
||||
public class EnrichmentChamberRecipeHandler extends MachineRecipeHandler
|
||||
{
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return MekanismUtils.localize("tile.MachineBlock.EnrichmentChamber.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeId()
|
||||
{
|
||||
return "mekanism.chamber";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "chamber";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set getRecipes()
|
||||
{
|
||||
return Recipe.ENRICHMENT_CHAMBER.get().entrySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getGuiClass()
|
||||
{
|
||||
return GuiEnrichmentChamber.class;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
package mekanism.client.nei;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.changeTexture;
|
||||
import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect;
|
||||
import static codechicken.lib.gui.GuiDraw.gui;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.client.gui.GuiElement;
|
||||
import mekanism.client.gui.GuiProgress;
|
||||
import mekanism.client.gui.GuiProgress.IProgressInfoHandler;
|
||||
import mekanism.client.gui.GuiProgress.ProgressBar;
|
||||
import mekanism.client.gui.GuiSlot;
|
||||
import mekanism.client.gui.GuiSlot.SlotOverlay;
|
||||
import mekanism.client.gui.GuiSlot.SlotType;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public abstract class MachineRecipeHandler extends BaseRecipeHandler
|
||||
{
|
||||
private int ticksPassed;
|
||||
|
||||
public abstract String getRecipeId();
|
||||
|
||||
public abstract Set<Entry<ItemStack, ItemStack>> getRecipes();
|
||||
|
||||
@Override
|
||||
public void addGuiElements()
|
||||
{
|
||||
guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 55, 16));
|
||||
guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 55, 52).with(SlotOverlay.POWER));
|
||||
guiElements.add(new GuiSlot(SlotType.OUTPUT_LARGE, this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 111, 30));
|
||||
|
||||
guiElements.add(new GuiProgress(new IProgressInfoHandler()
|
||||
{
|
||||
@Override
|
||||
public double getProgress()
|
||||
{
|
||||
return ticksPassed >= 20 ? (ticksPassed - 20) % 20 / 20.0F : 0.0F;
|
||||
}
|
||||
}, ProgressBar.BLUE, this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 77, 37));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int i)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
changeTexture(getGuiTexture());
|
||||
drawTexturedModalRect(12, 0, 28, 5, 144, 68);
|
||||
for(GuiElement e : guiElements)
|
||||
{
|
||||
e.renderBackground(0, 0, -16, -5);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int i)
|
||||
{
|
||||
float f = ticksPassed >= 20 ? (ticksPassed - 20) % 20 / 20.0F : 0.0F;
|
||||
drawProgressBar(63, 34, 176, 0, 24, 7, f, 0);
|
||||
f = ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F;
|
||||
drawProgressBar(149, 12, 176, 7, 4, 52, f, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
ticksPassed++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects()
|
||||
{
|
||||
transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(63, 34, 24, 7), 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 void loadCraftingRecipes(ItemStack result)
|
||||
{
|
||||
for(Map.Entry irecipe : getRecipes())
|
||||
{
|
||||
if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getValue(), result))
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture()
|
||||
{
|
||||
return "mekanism:gui/GuiBasicMachine.png";
|
||||
}
|
||||
|
||||
@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 PositionedStack input;
|
||||
public PositionedStack output;
|
||||
|
||||
@Override
|
||||
public PositionedStack getIngredient()
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return output;
|
||||
}
|
||||
|
||||
public CachedIORecipe(ItemStack itemstack, ItemStack itemstack1)
|
||||
{
|
||||
super();
|
||||
input = new PositionedStack(itemstack, 40, 12);
|
||||
output = new PositionedStack(itemstack1, 100, 30);
|
||||
}
|
||||
|
||||
public CachedIORecipe(Map.Entry recipe)
|
||||
{
|
||||
this((ItemStack)recipe.getKey(), (ItemStack)recipe.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
package mekanism.client.nei;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.energy.IEnergizedItem;
|
||||
import mekanism.common.IEnergyCube;
|
||||
import mekanism.common.IFactory;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.recipe.MekanismRecipe;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.ShapedRecipeHandler;
|
||||
|
||||
public class MekanismRecipeHandler extends ShapedRecipeHandler
|
||||
{
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return "Mekanism " + MekanismUtils.localize("recipe.mekanismShaped");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results)
|
||||
{
|
||||
if(outputId.equals("crafting") && getClass() == MekanismRecipeHandler.class)
|
||||
{
|
||||
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
|
||||
|
||||
for(IRecipe irecipe : allrecipes)
|
||||
{
|
||||
if(irecipe instanceof MekanismRecipe)
|
||||
{
|
||||
MekanismRecipe energyRecipe = (MekanismRecipe)irecipe;
|
||||
CachedEnergyRecipe recipe = new CachedEnergyRecipe(energyRecipe.width, energyRecipe.height, energyRecipe.getInput(), energyRecipe.getRecipeOutput());
|
||||
arecipes.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result)
|
||||
{
|
||||
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
|
||||
|
||||
for(IRecipe irecipe : allrecipes)
|
||||
{
|
||||
if(irecipe instanceof MekanismRecipe && areItemsEqual(irecipe.getRecipeOutput(), result))
|
||||
{
|
||||
MekanismRecipe energyRecipe = (MekanismRecipe)irecipe;
|
||||
CachedEnergyRecipe recipe = new CachedEnergyRecipe(energyRecipe.width, energyRecipe.height, energyRecipe.getInput(), energyRecipe.getRecipeOutput());
|
||||
arecipes.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient)
|
||||
{
|
||||
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
|
||||
|
||||
for(IRecipe irecipe : allrecipes)
|
||||
{
|
||||
if(irecipe instanceof MekanismRecipe)
|
||||
{
|
||||
MekanismRecipe energyRecipe = (MekanismRecipe)irecipe;
|
||||
CachedEnergyRecipe recipe = new CachedEnergyRecipe(energyRecipe.width, energyRecipe.height, energyRecipe.getInput(), energyRecipe.getRecipeOutput());
|
||||
|
||||
if(recipe.contains(recipe.ingredients, ingredient))
|
||||
{
|
||||
recipe.setIngredientPermutation(recipe.ingredients, ingredient);
|
||||
arecipes.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean areItemsEqual(ItemStack stack1, ItemStack stack2)
|
||||
{
|
||||
if(stack1 == null && stack2 != null || stack1 != null && stack2 == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if(stack1 == null && stack2 == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if(stack1.getItem() != stack2.getItem())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!(stack1.getItem() instanceof IEnergizedItem) && !(stack2.getItem() instanceof IEnergizedItem))
|
||||
{
|
||||
if(stack1.getItemDamage() != stack2.getItemDamage())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(((IEnergizedItem)stack1.getItem()).isMetadataSpecific() && ((IEnergizedItem)stack2.getItem()).isMetadataSpecific())
|
||||
{
|
||||
if(stack1.getItemDamage() != stack2.getItemDamage())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(stack1.getItem() instanceof IEnergyCube && stack2.getItem() instanceof IEnergyCube)
|
||||
{
|
||||
if(((IEnergyCube)stack1.getItem()).getEnergyCubeTier(stack1) != ((IEnergyCube)stack2.getItem()).getEnergyCubeTier(stack2))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(stack1.getItem() instanceof IFactory && stack2.getItem() instanceof IFactory)
|
||||
{
|
||||
if(isFactory(stack1) && isFactory(stack2))
|
||||
{
|
||||
if(((IFactory)stack1.getItem()).getRecipeType(stack1) != ((IFactory)stack2.getItem()).getRecipeType(stack2))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isFactory(ItemStack stack)
|
||||
{
|
||||
return MachineType.get(stack) == MachineType.BASIC_FACTORY || MachineType.get(stack) == MachineType.ADVANCED_FACTORY || MachineType.get(stack) == MachineType.ELITE_FACTORY;
|
||||
}
|
||||
|
||||
public class CachedEnergyRecipe extends CachedRecipe
|
||||
{
|
||||
public ArrayList<PositionedStack> ingredients;
|
||||
public PositionedStack result;
|
||||
|
||||
public CachedEnergyRecipe(int width, int height, Object[] items, ItemStack out)
|
||||
{
|
||||
result = new PositionedStack(out, 119, 24);
|
||||
ingredients = new ArrayList<PositionedStack>();
|
||||
setIngredients(width, height, items);
|
||||
}
|
||||
|
||||
public void setIngredients(int width, int height, Object[] items)
|
||||
{
|
||||
for(int x = 0; x < width; x++)
|
||||
{
|
||||
for(int y = 0; y < height; y++)
|
||||
{
|
||||
if(items[y*width+x] == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
PositionedStack stack = new PositionedStack(items[y*width+x], 25+x*18, 6+y*18);
|
||||
stack.setMaxSize(1);
|
||||
ingredients.add(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<PositionedStack> getIngredients()
|
||||
{
|
||||
return (ArrayList<PositionedStack>)getCycledIngredients(MekanismRecipeHandler.this.cycleticks / 20, ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Collection<PositionedStack> ingredients, ItemStack ingredient)
|
||||
{
|
||||
for(PositionedStack stack : ingredients)
|
||||
{
|
||||
for(ItemStack item : stack.items)
|
||||
{
|
||||
if(areItemsEqual(item, ingredient))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
package mekanism.client.nei;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.changeTexture;
|
||||
import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.infuse.InfuseObject;
|
||||
import mekanism.api.infuse.InfuseRegistry;
|
||||
import mekanism.api.infuse.InfuseType;
|
||||
import mekanism.api.infuse.InfusionInput;
|
||||
import mekanism.api.infuse.InfusionOutput;
|
||||
import mekanism.client.gui.GuiMetallurgicInfuser;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public class MetallurgicInfuserRecipeHandler extends BaseRecipeHandler
|
||||
{
|
||||
private int ticksPassed;
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return MekanismUtils.localize("tile.MachineBlock.MetallurgicInfuser.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "infuser";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture()
|
||||
{
|
||||
return "mekanism:gui/GuiMetallurgicInfuser.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getGuiClass()
|
||||
{
|
||||
return GuiMetallurgicInfuser.class;
|
||||
}
|
||||
|
||||
public String getRecipeId()
|
||||
{
|
||||
return "mekanism.infuser";
|
||||
}
|
||||
|
||||
public List<ItemStack> getInfuseStacks(InfuseType type)
|
||||
{
|
||||
List<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
|
||||
for(Map.Entry<ItemStack, InfuseObject> obj : InfuseRegistry.getObjectMap().entrySet())
|
||||
{
|
||||
if(obj.getValue().type == type)
|
||||
{
|
||||
ret.add(obj.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Set<Entry<InfusionInput, InfusionOutput>> getRecipes()
|
||||
{
|
||||
return Recipe.METALLURGIC_INFUSER.get().entrySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int i)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
changeTexture(getGuiTexture());
|
||||
drawTexturedModalRect(0, 0, 5, 15, 166, 56);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int i)
|
||||
{
|
||||
InfuseType type = ((CachedIORecipe)arecipes.get(i)).infusionType;
|
||||
|
||||
float f = ticksPassed >= 40 ? (ticksPassed - 40) % 20 / 20.0F : 0.0F;
|
||||
drawProgressBar(67, 32, 176, 52, 32, 8, f, 0);
|
||||
|
||||
f = ticksPassed >= 20 && ticksPassed < 40 ? (ticksPassed - 20) % 20 / 20.0F : 1.0F;
|
||||
if(ticksPassed < 20) f = 0.0F;
|
||||
|
||||
f = ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F;
|
||||
drawProgressBar(160, 2, 176, 0, 4, 52, f, 3);
|
||||
|
||||
changeTexture(type.texture);
|
||||
drawProgressBar(2, 2, type.texX, type.texY, 4, 52, f, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
|
||||
ticksPassed++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects()
|
||||
{
|
||||
transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(67, 32, 32, 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, getInfuseStacks(((InfusionInput)irecipe.getKey()).infusionType), ((InfusionInput)irecipe.getKey()).infusionType));
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recipiesPerPage()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result)
|
||||
{
|
||||
for(Map.Entry irecipe : getRecipes())
|
||||
{
|
||||
if(NEIServerUtils.areStacksSameTypeCrafting(((InfusionOutput)irecipe.getValue()).resource, result))
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe, getInfuseStacks(((InfusionInput)irecipe.getKey()).infusionType), ((InfusionInput)irecipe.getKey()).infusionType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient)
|
||||
{
|
||||
for(Map.Entry irecipe : getRecipes())
|
||||
{
|
||||
if(NEIServerUtils.areStacksSameTypeCrafting(((InfusionInput)irecipe.getKey()).inputStack, ingredient))
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe, getInfuseStacks(((InfusionInput)irecipe.getKey()).infusionType), ((InfusionInput)irecipe.getKey()).infusionType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGuiElements()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe
|
||||
{
|
||||
public List<ItemStack> infuseStacks;
|
||||
|
||||
public PositionedStack inputStack;
|
||||
public PositionedStack outputStack;
|
||||
|
||||
public InfuseType infusionType;
|
||||
|
||||
@Override
|
||||
public PositionedStack getIngredient()
|
||||
{
|
||||
return inputStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return outputStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getOtherStack()
|
||||
{
|
||||
return new PositionedStack(infuseStacks.get(cycleticks/40 % infuseStacks.size()), 12, 20);
|
||||
}
|
||||
|
||||
public CachedIORecipe(ItemStack input, ItemStack output, List<ItemStack> infuses, InfuseType type)
|
||||
{
|
||||
super();
|
||||
|
||||
inputStack = new PositionedStack(input, 46, 28);
|
||||
outputStack = new PositionedStack(output, 104, 28);
|
||||
|
||||
infuseStacks = infuses;
|
||||
|
||||
infusionType = type;
|
||||
}
|
||||
|
||||
public CachedIORecipe(Map.Entry recipe, List<ItemStack> infuses, InfuseType type)
|
||||
{
|
||||
this(((InfusionInput)recipe.getKey()).inputStack, ((InfusionOutput)recipe.getValue()).resource, infuses, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package mekanism.client.nei;
|
||||
|
||||
import mekanism.client.gui.GuiChemicalCrystallizer;
|
||||
import mekanism.client.gui.GuiChemicalDissolutionChamber;
|
||||
import mekanism.client.gui.GuiChemicalInfuser;
|
||||
import mekanism.client.gui.GuiChemicalInjectionChamber;
|
||||
import mekanism.client.gui.GuiChemicalOxidizer;
|
||||
import mekanism.client.gui.GuiChemicalWasher;
|
||||
import mekanism.client.gui.GuiCombiner;
|
||||
import mekanism.client.gui.GuiCrusher;
|
||||
import mekanism.client.gui.GuiElectrolyticSeparator;
|
||||
import mekanism.client.gui.GuiEnrichmentChamber;
|
||||
import mekanism.client.gui.GuiMetallurgicInfuser;
|
||||
import mekanism.client.gui.GuiOsmiumCompressor;
|
||||
import mekanism.client.gui.GuiPrecisionSawmill;
|
||||
import mekanism.client.gui.GuiPurificationChamber;
|
||||
import mekanism.client.gui.GuiRotaryCondensentrator;
|
||||
import mekanism.client.gui.GuiSalinationController;
|
||||
import mekanism.common.Mekanism;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.IConfigureNEI;
|
||||
|
||||
public class NEIMekanismConfig implements IConfigureNEI
|
||||
{
|
||||
@Override
|
||||
public void loadConfig()
|
||||
{
|
||||
API.registerRecipeHandler(new EnrichmentChamberRecipeHandler());
|
||||
API.registerUsageHandler(new EnrichmentChamberRecipeHandler());
|
||||
|
||||
API.registerRecipeHandler(new OsmiumCompressorRecipeHandler());
|
||||
API.registerUsageHandler(new OsmiumCompressorRecipeHandler());
|
||||
|
||||
API.registerRecipeHandler(new CrusherRecipeHandler());
|
||||
API.registerUsageHandler(new CrusherRecipeHandler());
|
||||
|
||||
API.registerRecipeHandler(new CombinerRecipeHandler());
|
||||
API.registerUsageHandler(new CombinerRecipeHandler());
|
||||
|
||||
API.registerRecipeHandler(new MetallurgicInfuserRecipeHandler());
|
||||
API.registerUsageHandler(new MetallurgicInfuserRecipeHandler());
|
||||
|
||||
API.registerRecipeHandler(new PurificationChamberRecipeHandler());
|
||||
API.registerUsageHandler(new PurificationChamberRecipeHandler());
|
||||
|
||||
API.registerRecipeHandler(new ChemicalInjectionChamberRecipeHandler());
|
||||
API.registerUsageHandler(new ChemicalInjectionChamberRecipeHandler());
|
||||
|
||||
API.registerRecipeHandler(new MekanismRecipeHandler());
|
||||
API.registerUsageHandler(new MekanismRecipeHandler());
|
||||
|
||||
API.registerRecipeHandler(new ChemicalOxidizerRecipeHandler());
|
||||
API.registerUsageHandler(new ChemicalOxidizerRecipeHandler());
|
||||
|
||||
API.registerRecipeHandler(new ChemicalInfuserRecipeHandler());
|
||||
API.registerUsageHandler(new ChemicalInfuserRecipeHandler());
|
||||
|
||||
API.registerRecipeHandler(new RotaryCondensentratorRecipeHandler());
|
||||
API.registerUsageHandler(new RotaryCondensentratorRecipeHandler());
|
||||
|
||||
API.registerRecipeHandler(new ElectrolyticSeparatorRecipeHandler());
|
||||
API.registerUsageHandler(new ElectrolyticSeparatorRecipeHandler());
|
||||
|
||||
API.registerRecipeHandler(new PrecisionSawmillRecipeHandler());
|
||||
API.registerUsageHandler(new PrecisionSawmillRecipeHandler());
|
||||
|
||||
API.registerRecipeHandler(new SalinationControllerRecipeHandler());
|
||||
API.registerUsageHandler(new SalinationControllerRecipeHandler());
|
||||
|
||||
API.registerRecipeHandler(new ChemicalDissolutionChamberRecipeHandler());
|
||||
API.registerUsageHandler(new ChemicalDissolutionChamberRecipeHandler());
|
||||
|
||||
API.registerRecipeHandler(new ChemicalWasherRecipeHandler());
|
||||
API.registerUsageHandler(new ChemicalWasherRecipeHandler());
|
||||
|
||||
API.registerRecipeHandler(new ChemicalCrystallizerRecipeHandler());
|
||||
API.registerUsageHandler(new ChemicalCrystallizerRecipeHandler());
|
||||
|
||||
API.setGuiOffset(GuiEnrichmentChamber.class, 16, 6);
|
||||
API.setGuiOffset(GuiOsmiumCompressor.class, 16, 6);
|
||||
API.setGuiOffset(GuiCrusher.class, 16, 6);
|
||||
API.setGuiOffset(GuiCombiner.class, 16, 6);
|
||||
API.setGuiOffset(GuiPurificationChamber.class, 16, 6);
|
||||
API.setGuiOffset(GuiChemicalInjectionChamber.class, 16, 6);
|
||||
API.setGuiOffset(GuiMetallurgicInfuser.class, 5, 15);
|
||||
API.setGuiOffset(GuiChemicalOxidizer.class, ChemicalOxidizerRecipeHandler.xOffset, ChemicalOxidizerRecipeHandler.yOffset);
|
||||
API.setGuiOffset(GuiChemicalInfuser.class, ChemicalInfuserRecipeHandler.xOffset, ChemicalInfuserRecipeHandler.yOffset);
|
||||
API.setGuiOffset(GuiRotaryCondensentrator.class, RotaryCondensentratorRecipeHandler.xOffset, RotaryCondensentratorRecipeHandler.yOffset);
|
||||
API.setGuiOffset(GuiElectrolyticSeparator.class, ElectrolyticSeparatorRecipeHandler.xOffset, ElectrolyticSeparatorRecipeHandler.yOffset);
|
||||
API.setGuiOffset(GuiPrecisionSawmill.class, 16, 6);
|
||||
API.setGuiOffset(GuiSalinationController.class, SalinationControllerRecipeHandler.xOffset, SalinationControllerRecipeHandler.yOffset);
|
||||
API.setGuiOffset(GuiChemicalDissolutionChamber.class, ChemicalDissolutionChamberRecipeHandler.xOffset, ChemicalDissolutionChamberRecipeHandler.yOffset);
|
||||
API.setGuiOffset(GuiChemicalWasher.class, ChemicalWasherRecipeHandler.xOffset, ChemicalWasherRecipeHandler.yOffset);
|
||||
API.setGuiOffset(GuiChemicalCrystallizer.class, ChemicalCrystallizerRecipeHandler.xOffset, ChemicalCrystallizerRecipeHandler.yOffset);
|
||||
|
||||
API.hideItem(new ItemStack(Mekanism.BoundingBlock));
|
||||
API.hideItem(new ItemStack(Mekanism.ItemProxy));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "Mekanism NEI Plugin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion()
|
||||
{
|
||||
return "1.2";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package mekanism.client.nei;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.ListUtils;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.client.gui.GuiOsmiumCompressor;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class OsmiumCompressorRecipeHandler extends AdvancedMachineRecipeHandler
|
||||
{
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return MekanismUtils.localize("tile.MachineBlock.OsmiumCompressor.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeId()
|
||||
{
|
||||
return "mekanism.compressor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "compressor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set getRecipes()
|
||||
{
|
||||
return Recipe.OSMIUM_COMPRESSOR.get().entrySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture()
|
||||
{
|
||||
return "mekanism:gui/GuiCompressor.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getFuelStacks(Gas gasType)
|
||||
{
|
||||
return ListUtils.asList(new ItemStack(Mekanism.Ingot, 1, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getGuiClass()
|
||||
{
|
||||
return GuiOsmiumCompressor.class;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package mekanism.client.nei;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.client.gui.GuiPrecisionSawmill;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
|
||||
public class PrecisionSawmillRecipeHandler extends ChanceMachineRecipeHandler
|
||||
{
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return MekanismUtils.localize("tile.MachineBlock2.PrecisionSawmill.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeId()
|
||||
{
|
||||
return "mekanism.precisionsawmill";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "precisionsawmill";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set getRecipes()
|
||||
{
|
||||
return Recipe.PRECISION_SAWMILL.get().entrySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture()
|
||||
{
|
||||
return "mekanism:gui/GuiPrecisionSawmill.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getGuiClass()
|
||||
{
|
||||
return GuiPrecisionSawmill.class;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package mekanism.client.nei;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.ListUtils;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.client.gui.GuiPurificationChamber;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class PurificationChamberRecipeHandler extends AdvancedMachineRecipeHandler
|
||||
{
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return MekanismUtils.localize("tile.MachineBlock.PurificationChamber.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeId()
|
||||
{
|
||||
return "mekanism.purificationchamber";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "purificationchamber";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set getRecipes()
|
||||
{
|
||||
return Recipe.PURIFICATION_CHAMBER.get().entrySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture()
|
||||
{
|
||||
return "mekanism:gui/GuiPurificationChamber.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getFuelStacks(Gas gasType)
|
||||
{
|
||||
if(gasType == GasRegistry.getGas("oxygen"))
|
||||
{
|
||||
return ListUtils.asList(new ItemStack(Items.flint), MekanismUtils.getFullGasTank(GasRegistry.getGas("oxygen")));
|
||||
}
|
||||
|
||||
return new ArrayList<ItemStack>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getGuiClass()
|
||||
{
|
||||
return GuiPurificationChamber.class;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,346 @@
|
||||
package mekanism.client.nei;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.changeTexture;
|
||||
import static codechicken.lib.gui.GuiDraw.drawString;
|
||||
import static codechicken.lib.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;
|
||||
import mekanism.client.gui.GuiRotaryCondensentrator;
|
||||
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.lib.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
|
||||
{
|
||||
private int ticksPassed;
|
||||
|
||||
public static int xOffset = 5;
|
||||
public static int yOffset = 12;
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return MekanismUtils.localize("nei.rotaryCondensentrator");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "rotarycondensentrator";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture()
|
||||
{
|
||||
return "mekanism:gui/nei/GuiRotaryCondensentrator.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getGuiClass()
|
||||
{
|
||||
return GuiRotaryCondensentrator.class;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if(recipe.type)
|
||||
{
|
||||
drawTexturedModalRect(64-xOffset, 39-yOffset, 176, 123, 48, 8);
|
||||
}
|
||||
else {
|
||||
drawTexturedModalRect(64-xOffset, 39-yOffset, 176, 115, 48, 8);
|
||||
}
|
||||
|
||||
if(recipe.gasStack != null)
|
||||
{
|
||||
displayGauge(58, 26-xOffset, 14-yOffset, 176, 40, 58, null, recipe.gasStack);
|
||||
}
|
||||
|
||||
if(recipe.fluidStack != null)
|
||||
{
|
||||
displayGauge(58, 134-xOffset, 14-yOffset, 176, 40, 58, recipe.fluidStack, null);
|
||||
}
|
||||
|
||||
drawString(recipe.type ? MekanismUtils.localize("gui.condensentrating") : MekanismUtils.localize("gui.decondensentrating"), 6-xOffset, 74-yOffset, 0x404040, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
|
||||
ticksPassed++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects()
|
||||
{
|
||||
transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(64-xOffset, 39-yOffset, 48, 8), getRecipeId(), new Object[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results)
|
||||
{
|
||||
if(outputId.equals(getRecipeId()))
|
||||
{
|
||||
for(Gas gas : GasRegistry.getRegisteredGasses())
|
||||
{
|
||||
if(gas.hasFluid())
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack)
|
||||
{
|
||||
GasStack gas = (GasStack)results[0];
|
||||
|
||||
if(gas.getGas().hasFluid())
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(new GasStack(gas.getGas(), 1), new FluidStack(gas.getGas().getFluid(), 1), false));
|
||||
}
|
||||
}
|
||||
else if(outputId.equals("fluid") && results.length == 1 && results[0] instanceof FluidStack)
|
||||
{
|
||||
FluidStack fluid = (FluidStack)results[0];
|
||||
Gas gas = GasRegistry.getGas(fluid.getFluid());
|
||||
|
||||
if(gas != null)
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(new GasStack(gas, 1), new FluidStack(fluid.getFluid(), 1), true));
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(String inputId, Object... ingredients)
|
||||
{
|
||||
if(inputId.equals("gas") && ingredients.length == 1 && ingredients[0] instanceof GasStack)
|
||||
{
|
||||
GasStack gas = (GasStack)ingredients[0];
|
||||
|
||||
if(gas.getGas().hasFluid())
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(new GasStack(gas.getGas(), 1), new FluidStack(gas.getGas().getFluid(), 1), true));
|
||||
}
|
||||
}
|
||||
else if(inputId.equals("fluid") && ingredients.length == 1 && ingredients[0] instanceof FluidStack)
|
||||
{
|
||||
FluidStack fluid = (FluidStack)ingredients[0];
|
||||
Gas gas = GasRegistry.getGas(fluid.getFluid());
|
||||
|
||||
if(gas != null)
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(new GasStack(gas, 1), new FluidStack(fluid.getFluid(), 1), false));
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.loadUsageRecipes(inputId, ingredients);
|
||||
}
|
||||
}
|
||||
|
||||
@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 >= 26 && xAxis <= 42 && yAxis >= 14+4 && yAxis <= 72+4)
|
||||
{
|
||||
currenttip.add(((CachedIORecipe)arecipes.get(recipe)).gasStack.getGas().getLocalizedName());
|
||||
}
|
||||
else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+4 && yAxis <= 72+4)
|
||||
{
|
||||
currenttip.add(((CachedIORecipe)arecipes.get(recipe)).fluidStack.getFluid().getLocalizedName());
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
GasStack gas = null;
|
||||
FluidStack fluid = null;
|
||||
|
||||
if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+4 && yAxis <= 72+4)
|
||||
{
|
||||
gas = ((CachedIORecipe)arecipes.get(recipe)).gasStack;
|
||||
}
|
||||
else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+4 && yAxis <= 72+4)
|
||||
{
|
||||
fluid = ((CachedIORecipe)arecipes.get(recipe)).fluidStack;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
GasStack gas = null;
|
||||
FluidStack fluid = null;
|
||||
|
||||
if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+18 && yAxis <= 72+18)
|
||||
{
|
||||
gas = ((CachedIORecipe)arecipes.get(recipe)).gasStack;
|
||||
}
|
||||
else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+18 && yAxis <= 72+18)
|
||||
{
|
||||
fluid = ((CachedIORecipe)arecipes.get(recipe)).fluidStack;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.mouseClicked(gui, button, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recipiesPerPage()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGuiElements()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe
|
||||
{
|
||||
public GasStack gasStack;
|
||||
public FluidStack fluidStack;
|
||||
|
||||
/* true = condensentrating, false = decondensentrating */
|
||||
public boolean type;
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public CachedIORecipe(GasStack gas, FluidStack fluid, boolean b)
|
||||
{
|
||||
gasStack = gas;
|
||||
fluidStack = fluid;
|
||||
type = b;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,291 @@
|
||||
package mekanism.client.nei;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.changeTexture;
|
||||
import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.client.gui.GuiSalinationController;
|
||||
import mekanism.common.ObfuscatedNames;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public class SalinationControllerRecipeHandler extends BaseRecipeHandler
|
||||
{
|
||||
private int ticksPassed;
|
||||
|
||||
private static Map<FluidStack, FluidStack> recipes = new HashMap<FluidStack, FluidStack>();
|
||||
|
||||
public static int xOffset = 5;
|
||||
public static int yOffset = 12;
|
||||
|
||||
static
|
||||
{
|
||||
if(recipes.isEmpty())
|
||||
{
|
||||
recipes.put(new FluidStack(FluidRegistry.WATER, 1), new FluidStack(FluidRegistry.getFluid("brine"), 1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return MekanismUtils.localize("tile.BasicBlock.SalinationController.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "salinationcontroller";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture()
|
||||
{
|
||||
return "mekanism:gui/nei/GuiSalinationController.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getGuiClass()
|
||||
{
|
||||
return GuiSalinationController.class;
|
||||
}
|
||||
|
||||
public String getRecipeId()
|
||||
{
|
||||
return "mekanism.salinationcontroller";
|
||||
}
|
||||
|
||||
public Set<Entry<FluidStack, FluidStack>> getRecipes()
|
||||
{
|
||||
return recipes.entrySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int i)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
changeTexture(getGuiTexture());
|
||||
drawTexturedModalRect(-2, 0, 3, yOffset, 170, 62);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int i)
|
||||
{
|
||||
CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i);
|
||||
|
||||
drawProgressBar(49-xOffset, 64-yOffset, 176, 59, 78, 8, ticksPassed < 20 ? ticksPassed % 20 / 20.0F : 1.0F, 0);
|
||||
|
||||
if(recipe.fluidInput != null)
|
||||
{
|
||||
displayGauge(58, 7-xOffset, 14-yOffset, 176, 0, 58, recipe.fluidInput, null);
|
||||
}
|
||||
|
||||
if(recipe.fluidOutput != null)
|
||||
{
|
||||
displayGauge(58, 153-xOffset, 14-yOffset, 176, 0, 58, recipe.fluidOutput, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
|
||||
ticksPassed++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results)
|
||||
{
|
||||
if(outputId.equals(getRecipeId()))
|
||||
{
|
||||
for(Map.Entry irecipe : getRecipes())
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe));
|
||||
}
|
||||
}
|
||||
else if(outputId.equals("fluid") && results.length == 1 && results[0] instanceof FluidStack)
|
||||
{
|
||||
for(Map.Entry<FluidStack, FluidStack> irecipe : getRecipes())
|
||||
{
|
||||
if(((FluidStack)results[0]).isFluidEqual(irecipe.getValue()))
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(String inputId, Object... ingredients)
|
||||
{
|
||||
if(inputId.equals("fluid") && ingredients.length == 1 && ingredients[0] instanceof FluidStack)
|
||||
{
|
||||
for(Map.Entry<FluidStack, FluidStack> irecipe : getRecipes())
|
||||
{
|
||||
if(irecipe.getKey().isFluidEqual((FluidStack)ingredients[0]))
|
||||
{
|
||||
arecipes.add(new CachedIORecipe(irecipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.loadUsageRecipes(inputId, ingredients);
|
||||
}
|
||||
}
|
||||
|
||||
@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 >= 7 && xAxis <= 23 && yAxis >= 14+4 && yAxis <= 72+4)
|
||||
{
|
||||
currenttip.add(((CachedIORecipe)arecipes.get(recipe)).fluidInput.getFluid().getLocalizedName());
|
||||
}
|
||||
else if(xAxis >= 153 && xAxis <= 169 && yAxis >= 14+4 && yAxis <= 72+4)
|
||||
{
|
||||
currenttip.add(((CachedIORecipe)arecipes.get(recipe)).fluidOutput.getFluid().getLocalizedName());
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
FluidStack stack = null;
|
||||
|
||||
if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14+4 && yAxis <= 72+4)
|
||||
{
|
||||
stack = ((CachedIORecipe)arecipes.get(recipe)).fluidInput;
|
||||
}
|
||||
else if(xAxis >= 153 && xAxis <= 169 && yAxis >= 14+4 && yAxis <= 72+4)
|
||||
{
|
||||
stack = ((CachedIORecipe)arecipes.get(recipe)).fluidOutput;
|
||||
}
|
||||
|
||||
if(stack != null)
|
||||
{
|
||||
if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe"))
|
||||
{
|
||||
if(doFluidLookup(stack, false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage"))
|
||||
{
|
||||
if(doFluidLookup(stack, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
FluidStack stack = null;
|
||||
|
||||
if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14+4 && yAxis <= 72+4)
|
||||
{
|
||||
stack = ((CachedIORecipe)arecipes.get(recipe)).fluidInput;
|
||||
}
|
||||
else if(xAxis >= 153 && xAxis <= 169 && yAxis >= 14+4 && yAxis <= 72+4)
|
||||
{
|
||||
stack = ((CachedIORecipe)arecipes.get(recipe)).fluidOutput;
|
||||
}
|
||||
|
||||
if(stack != null)
|
||||
{
|
||||
if(button == 0)
|
||||
{
|
||||
if(doFluidLookup(stack, false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(button == 1)
|
||||
{
|
||||
if(doFluidLookup(stack, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.mouseClicked(gui, button, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recipiesPerPage()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGuiElements()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe
|
||||
{
|
||||
public FluidStack fluidInput;
|
||||
public FluidStack fluidOutput;
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public CachedIORecipe(FluidStack input, FluidStack output)
|
||||
{
|
||||
fluidInput = input;
|
||||
fluidOutput = output;
|
||||
}
|
||||
|
||||
public CachedIORecipe(Map.Entry recipe)
|
||||
{
|
||||
this((FluidStack)recipe.getKey(), (FluidStack)recipe.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user