From 3a807968326cdfe4b22b172b1a2435291b5ff076 Mon Sep 17 00:00:00 2001 From: Alex_hawks Date: Sun, 5 Jan 2014 15:53:12 +0800 Subject: [PATCH] change the recipe handler, and add a simple get output method --- .../resonantinduction/api/MachineRecipes.java | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/main/java/resonantinduction/api/MachineRecipes.java b/src/main/java/resonantinduction/api/MachineRecipes.java index 2f73e3506..0804d913b 100644 --- a/src/main/java/resonantinduction/api/MachineRecipes.java +++ b/src/main/java/resonantinduction/api/MachineRecipes.java @@ -4,7 +4,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import resonantinduction.api.RecipeUtils.Resource; +import net.minecraft.item.ItemStack; + +import resonantinduction.api.RecipeUtils.*; public final class MachineRecipes { @@ -19,7 +21,7 @@ public final class MachineRecipes METAL_FORMER; } - private final Map, List>> recipes = new HashMap, List>>(); + private final Map> recipes = new HashMap>(); public static final MachineRecipes INSTANCE = new MachineRecipes(); @@ -27,28 +29,40 @@ public final class MachineRecipes { for (RecipeType machine : RecipeType.values()) { - this.recipes.put(machine, new HashMap, List>()); + this.recipes.put(machine, new HashMap()); } } - public void addRecipe(RecipeType machine, List input, List output) + public void addRecipe(RecipeType machine, Resource[] input, Resource[] output) { this.recipes.get(machine).put(input, output); } - public void removeRecipe(RecipeType machine, List input) + public void removeRecipe(RecipeType machine, Resource[] input) { this.recipes.get(machine).remove(input); } - public Map, List> getRecipes(RecipeType machine) + public MapgetRecipes(RecipeType machine) { - return new HashMap, List>(this.recipes.get(machine)); + return new HashMap(this.recipes.get(machine)); } - public Map, List>> getRecipes() + public Map> getRecipes() { - return new HashMap, List>>(this.recipes); + return new HashMap>(this.recipes); + } + + public Resource[] getRecipe(RecipeType machine, ItemStack primary, ItemStack... secondary) + { + Resource[] input = new Resource[secondary.length +1]; + input[0] = new ItemStackResource(primary); + for (int i = 0; i < secondary.length; i++) + { + input[i+1] = new ItemStackResource(secondary[i]); + } + + return this.getRecipes(machine).get(input); } }