Added in a recipe handler for the Chemical Oxidizer

This commit is contained in:
Aidan C. Brady 2014-01-09 18:06:44 -05:00
parent d21415fcae
commit 47e24b8575
8 changed files with 276 additions and 8 deletions

View file

@ -17,7 +17,7 @@ import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
public abstract class AdvancedMachineRecipeHandler extends TemplateRecipeHandler
public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler
{
private int ticksPassed;

View file

@ -0,0 +1,76 @@
package mekanism.client.nei;
import static codechicken.core.gui.GuiDraw.changeTexture;
import static codechicken.core.gui.GuiDraw.drawTexturedModalRect;
import static codechicken.core.gui.GuiDraw.gui;
import mekanism.api.gas.GasStack;
import mekanism.client.render.MekanismRenderer;
import net.minecraftforge.fluids.FluidStack;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
public abstract class BaseRecipeHandler extends TemplateRecipeHandler
{
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 void doGasTransfer(int recipe, boolean type)
{
}
public class ExtraRecipe extends TemplateRecipeHandler.CachedRecipe
{
@Override
public PositionedStack getResult()
{
return null;
}
}
}

View file

@ -0,0 +1,184 @@
package mekanism.client.nei;
import static codechicken.core.gui.GuiDraw.changeTexture;
import static codechicken.core.gui.GuiDraw.drawTexturedModalRect;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import mekanism.api.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.core.gui.GuiDraw;
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 int xOffset = 5;
public int yOffset = 12;
@Override
public String getRecipeName()
{
return "Chemical Oxidizer";
}
@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;
drawTexturedModalRect(64-xOffset, 40-yOffset, 176, 63, 48, 8);
if(gas != null)
{
displayGauge(58, 134-xOffset, 14-yOffset, 176, 4, 58, null, gas);
}
}
@Override
public void onUpdate()
{
super.onUpdate();
ticksPassed++;
}
@Override
public void loadTransferRects()
{
transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(64-5, 40-12, 48, 8), getRecipeId(), new Object[0]));
}
@Override
public void loadCraftingRecipes(String outputId, Object... results)
{
if(outputId.equals(getRecipeId()))
{
for(Map.Entry irecipe : getRecipes())
{
arecipes.add(new CachedIORecipe(irecipe));
}
}
else {
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public List<String> handleTooltip(GuiRecipe gui, List<String> currenttip, int recipe)
{
Point point = GuiDraw.getMousePosition();
int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft);
int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop);
System.out.println(xAxis + " " + yAxis);
if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+4 && yAxis <= 72+4)
{
currenttip.add(((CachedIORecipe)arecipes.get(recipe)).outputStack.getGas().getLocalizedName());
}
return super.handleTooltip(gui, currenttip, recipe);
}
@Override
public int recipiesPerPage()
{
return 2;
}
@Override
public void loadUsageRecipes(ItemStack ingredient)
{
for(Map.Entry irecipe : getRecipes())
{
if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getKey(), ingredient))
{
arecipes.add(new CachedIORecipe(irecipe));
}
}
}
public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe
{
public 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());
}
}
}

View file

@ -1,5 +1,8 @@
package mekanism.client.nei;
import static codechicken.core.gui.GuiDraw.changeTexture;
import static codechicken.core.gui.GuiDraw.drawTexturedModalRect;
import java.awt.Rectangle;
import java.util.Map;
import java.util.Map.Entry;
@ -13,9 +16,7 @@ import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import static codechicken.core.gui.GuiDraw.*;
public abstract class MachineRecipeHandler extends TemplateRecipeHandler
public abstract class MachineRecipeHandler extends BaseRecipeHandler
{
private int ticksPassed;

View file

@ -25,7 +25,7 @@ import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
public class MetallurgicInfuserRecipeHandler extends TemplateRecipeHandler
public class MetallurgicInfuserRecipeHandler extends BaseRecipeHandler
{
private int ticksPassed;

View file

@ -1,6 +1,7 @@
package mekanism.client.nei;
import mekanism.client.gui.GuiChemicalInjectionChamber;
import mekanism.client.gui.GuiChemicalOxidizer;
import mekanism.client.gui.GuiCombiner;
import mekanism.client.gui.GuiCrusher;
import mekanism.client.gui.GuiEnrichmentChamber;
@ -40,6 +41,9 @@ public class NEIMekanismConfig implements IConfigureNEI
API.registerRecipeHandler(new MekanismRecipeHandler());
API.registerUsageHandler(new MekanismRecipeHandler());
API.registerRecipeHandler(new ChemicalOxidizerRecipeHandler());
API.registerUsageHandler(new ChemicalOxidizerRecipeHandler());
API.setGuiOffset(GuiEnrichmentChamber.class, 16, 6);
API.setGuiOffset(GuiOsmiumCompressor.class, 16, 6);
API.setGuiOffset(GuiCrusher.class, 16, 6);
@ -47,6 +51,7 @@ public class NEIMekanismConfig implements IConfigureNEI
API.setGuiOffset(GuiPurificationChamber.class, 16, 6);
API.setGuiOffset(GuiChemicalInjectionChamber.class, 16, 6);
API.setGuiOffset(GuiMetallurgicInfuser.class, 5, 15);
API.setGuiOffset(GuiChemicalOxidizer.class, 5, 12);
API.hideItem(Mekanism.boundingBlockID);
API.hideItem(Mekanism.ItemProxy.itemID);

View file

@ -525,13 +525,13 @@ public class Mekanism
"SRS", Character.valueOf('S'), "ingotSteel", Character.valueOf('R'), Item.redstone
}));
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 1, 1), new Object[] {
"ETE", Character.valueOf('E'), EnrichedAlloy, Character.valueOf('T'), new ItemStack(PartTransmitter, 8, 0)
"ETE", Character.valueOf('E'), EnrichedAlloy, Character.valueOf('T'), new ItemStack(PartTransmitter, 1, 0)
}));
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 1, 2), new Object[] {
"CTC", Character.valueOf('C'), "circuitBasic", Character.valueOf('T'), new ItemStack(PartTransmitter, 8, 1)
"CTC", Character.valueOf('C'), "circuitBasic", Character.valueOf('T'), new ItemStack(PartTransmitter, 1, 1)
}));
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 1, 3), new Object[] {
"CTC", Character.valueOf('C'), AtomicCore, Character.valueOf('T'), new ItemStack(PartTransmitter, 8, 2)
"CTC", Character.valueOf('C'), AtomicCore, Character.valueOf('T'), new ItemStack(PartTransmitter, 1, 2)
}));
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 8, 4), new Object[] {
"SBS", Character.valueOf('S'), "ingotSteel", Character.valueOf('B'), Item.bucketEmpty

View file

@ -11,4 +11,6 @@ public final class ObfuscatedNames
public static String[] GuiContainer_xSize = new String[] {"xSize", "field_74194_b", "c"};
public static String[] GuiContainer_ySize = new String[] {"ySize", "field_74195_c", "d"};
public static String[] GuiScreen_fontRenderer = new String[] {"fontRenderer", "field_73886_k", "o"};
public static String[] GuiContainer_guiLeft = new String[] {"guiLeft", "field_74198_m"};
public static String[] GuiContainer_guiTop = new String[] {"guiTop", "field_74197_n"};
}