package com.hbm.handler.nei; import java.awt.Rectangle; import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.Map; import com.hbm.inventory.MachineRecipes; import com.hbm.inventory.gui.GUIMachineCMBFactory; import com.hbm.lib.RefStrings; import codechicken.nei.NEIServerUtils; import codechicken.nei.PositionedStack; import codechicken.nei.recipe.TemplateRecipeHandler; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.item.ItemStack; public class CMBFurnaceRecipeHandler extends TemplateRecipeHandler { public LinkedList transferRectsRec = new LinkedList(); public LinkedList transferRectsGui = new LinkedList(); public LinkedList> guiRec = new LinkedList>(); public LinkedList> guiGui = new LinkedList>(); public class SmeltingSet extends TemplateRecipeHandler.CachedRecipe { PositionedStack input1; PositionedStack input2; PositionedStack result; public SmeltingSet(ItemStack input1, ItemStack input2, ItemStack result) { input1.stackSize = 1; input2.stackSize = 1; this.input1 = new PositionedStack(input1, 66, 6); this.input2 = new PositionedStack(input2, 66, 42); this.result = new PositionedStack(result, 129, 24); } @Override public List getIngredients() { return getCycledIngredients(cycleticks / 48, Arrays.asList(new PositionedStack[] {input1, input2})); } @Override public PositionedStack getResult() { return result; } } @Override public String getRecipeName() { return "CMB Steel Furnace"; } @Override public String getGuiTexture() { return RefStrings.MODID + ":textures/gui/gui_nei_cmb.png"; } @Override public void loadCraftingRecipes(String outputId, Object... results) { if ((outputId.equals("cmbsmelting")) && getClass() == CMBFurnaceRecipeHandler.class) { Map recipes = MachineRecipes.instance().getCMBRecipes(); for (Map.Entry recipe : recipes.entrySet()) { this.arecipes.add(new SmeltingSet((ItemStack)recipe.getKey()[0], (ItemStack)recipe.getKey()[1], (ItemStack)recipe.getValue())); } } else { super.loadCraftingRecipes(outputId, results); } } @Override public void loadCraftingRecipes(ItemStack result) { Map recipes = MachineRecipes.instance().getCMBRecipes(); for (Map.Entry recipe : recipes.entrySet()) { if (NEIServerUtils.areStacksSameType((ItemStack)recipe.getValue(), result)) this.arecipes.add(new SmeltingSet((ItemStack)recipe.getKey()[0], (ItemStack)recipe.getKey()[1], (ItemStack)recipe.getValue())); } } @Override public void loadUsageRecipes(String inputId, Object... ingredients) { if ((inputId.equals("cmbsmelting")) && getClass() == CMBFurnaceRecipeHandler.class) { loadCraftingRecipes("cmbsmelting", new Object[0]); } else { super.loadUsageRecipes(inputId, ingredients); } } @Override public void loadUsageRecipes(ItemStack ingredient) { Map recipes = MachineRecipes.instance().getCMBRecipes(); for (Map.Entry recipe : recipes.entrySet()) { if (NEIServerUtils.areStacksSameType(ingredient, (ItemStack)recipe.getKey()[0]) || NEIServerUtils.areStacksSameType(ingredient, (ItemStack)recipe.getKey()[1])) this.arecipes.add(new SmeltingSet((ItemStack)recipe.getKey()[0], (ItemStack)recipe.getKey()[1], (ItemStack)recipe.getValue())); } } @Override public Class getGuiClass() { //return GUITestDiFurnace.class; return null; } @Override public void loadTransferRects() { transferRectsGui = new LinkedList(); guiGui = new LinkedList>(); transferRects.add(new RecipeTransferRect(new Rectangle(74 + 6, 23, 24, 18), "cmbsmelting")); transferRectsGui.add(new RecipeTransferRect(new Rectangle(63 - 7 + 4, 89 - 11, 34, 18), "cmbsmelting")); guiGui.add(GUIMachineCMBFactory.class); RecipeTransferRectHandler.registerRectsToGuis(getRecipeTransferRectGuis(), transferRects); RecipeTransferRectHandler.registerRectsToGuis(guiGui, transferRectsGui); } @Override public void drawExtras(int recipe) { drawProgressBar(83 - (18 * 4) - 9 + 1, 6, 36, 86, 16, 18 * 3 - 2, 480, 7); drawProgressBar(83 - (18 * 4) - 9 + 1 + 18, 6, 36 + 48, 86, 16, 18 * 3 - 2, 480, 7); drawProgressBar(83 - 3 + 16, 5 + 18, 100, 118, 24, 16, 48, 0); } @Override public TemplateRecipeHandler newInstance() { return super.newInstance(); } }