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.GUIMachineCyclotron; 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 CyclotronRecipeHandler 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 - 45, 6 + 18); this.input2 = new PositionedStack(input2, 66 + 9, 42 - 18); 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 "Cyclotron"; } @Override public String getGuiTexture() { return RefStrings.MODID + ":textures/gui/gui_nei_cyclotron.png"; } @Override public void loadCraftingRecipes(String outputId, Object... results) { if ((outputId.equals("cyclotronProcessing")) && getClass() == CyclotronRecipeHandler.class) { Map recipes = MachineRecipes.instance().getCyclotronRecipes(); 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().getCyclotronRecipes(); 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("cyclotronProcessing")) && getClass() == CyclotronRecipeHandler.class) { loadCraftingRecipes("cyclotronProcessing", new Object[0]); } else { super.loadUsageRecipes(inputId, ingredients); } } @Override public void loadUsageRecipes(ItemStack ingredient) { Map recipes = MachineRecipes.instance().getCyclotronRecipes(); 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(83 - 3 + 16 - 52, 5 + 18 + 1, 24, 18), "cyclotronProcessing")); transferRectsGui.add(new RecipeTransferRect(new Rectangle(61 - 4, 26 - 10, 36, 36), "cyclotronProcessing")); guiGui.add(GUIMachineCyclotron.class); RecipeTransferRectHandler.registerRectsToGuis(getRecipeTransferRectGuis(), transferRects); RecipeTransferRectHandler.registerRectsToGuis(guiGui, transferRectsGui); } @Override public void drawExtras(int recipe) { drawProgressBar(83 - 3 + 16 - 52, 5 + 18 + 1, 100, 118 + 1, 24, 16, 48, 0); } @Override public TemplateRecipeHandler newInstance() { return super.newInstance(); } }