From 5f7ea23a4f785fdf1ef4272e9634ce5f049063b2 Mon Sep 17 00:00:00 2001 From: pahimar Date: Fri, 21 Jun 2013 13:04:55 -0400 Subject: [PATCH] Blargh --- .../pahimar/ee3/core/util/RecipeHelper.java | 42 +++++++++---------- .../ee3/item/crafting/RecipeRegistry.java | 19 +++++++-- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/ee3_common/com/pahimar/ee3/core/util/RecipeHelper.java b/ee3_common/com/pahimar/ee3/core/util/RecipeHelper.java index 41076c3c..7d7f512b 100644 --- a/ee3_common/com/pahimar/ee3/core/util/RecipeHelper.java +++ b/ee3_common/com/pahimar/ee3/core/util/RecipeHelper.java @@ -164,33 +164,31 @@ public class RecipeHelper { return ItemUtil.collateStacks(getRecipeInputs(recipe)); } - public static ArrayList getReverseRecipes(CustomWrappedStack customWrappedStack) { - - if (customWrappedStack.getWrappedStack() instanceof ItemStack) { - return getReverseRecipes((ItemStack) customWrappedStack.getWrappedStack()); - } - else if (customWrappedStack.getWrappedStack() instanceof OreStack) { - // TODO Return recipes for OreStacks - LogHelper.debug("ReverseRecipe for OreStack: " + customWrappedStack.toString()); - } - - return new ArrayList(); - } - - @SuppressWarnings("unchecked") - public static ArrayList getReverseRecipes(ItemStack itemStack) { - + public static ArrayList getReverseRecipes(CustomWrappedStack wrappedStack) { + ArrayList reverseRecipeList = new ArrayList(); - if (itemStack != null) { - ArrayList craftingManagerRecipeList = new ArrayList(CraftingManager.getInstance().getRecipeList()); - - for (IRecipe recipe : craftingManagerRecipeList) { - if (recipe.getRecipeOutput() != null) { - if (ItemUtil.compare(itemStack, recipe.getRecipeOutput())) { + ArrayList recipeList = new ArrayList(CraftingManager.getInstance().getRecipeList()); + + for (IRecipe recipe : recipeList) { + + if (recipe.getRecipeOutput() != null) { + + if (wrappedStack.getWrappedStack() instanceof ItemStack) { + + if (ItemUtil.compare((ItemStack) wrappedStack.getWrappedStack(), recipe.getRecipeOutput())) { reverseRecipeList.add(recipe); } } + else if (wrappedStack.getWrappedStack() instanceof OreStack) { + + if (OreDictionary.getOreID(recipe.getRecipeOutput()) != -1) { + // TODO Generalize comparison of OreStacks and OreStacks|ItemStacks + if (OreDictionary.getOreID(((OreStack)wrappedStack.getWrappedStack()).oreName) == OreDictionary.getOreID(recipe.getRecipeOutput())) { + reverseRecipeList.add(recipe); + } + } + } } } diff --git a/ee3_common/com/pahimar/ee3/item/crafting/RecipeRegistry.java b/ee3_common/com/pahimar/ee3/item/crafting/RecipeRegistry.java index 27798a9c..e3b64eb7 100644 --- a/ee3_common/com/pahimar/ee3/item/crafting/RecipeRegistry.java +++ b/ee3_common/com/pahimar/ee3/item/crafting/RecipeRegistry.java @@ -21,7 +21,6 @@ public class RecipeRegistry { private Multimap> recipeMap; - @SuppressWarnings("unused") private List wildCardList; private RecipeRegistry() { @@ -71,13 +70,20 @@ public class RecipeRegistry { return getRecipes(new CustomWrappedStack(itemStack)); } + /* + * Item: + * Item (Output) <- { ... } + * + */ public void addRecipe(CustomWrappedStack recipeOutput, List recipeInputs) { - @SuppressWarnings("unused") ArrayList collatedStacks = new ArrayList(); CustomWrappedStack wrappedInputStack = null; + LogHelper.debug("Recipe Output: " + recipeOutput.toString() + ", size: " + recipeOutput.getStackSize()); + LogHelper.debug("Recipe Inputs: " + recipeInputs.toString()); + /** * For every input in the input list, check to see if we have discovered * it already - If we have, add it to the one we already have - If we @@ -92,17 +98,22 @@ public class RecipeRegistry { wrappedInputStack = (CustomWrappedStack) object; } - LogHelper.warning(wrappedInputStack.toString()); + for (CustomWrappedStack collatedStack : collatedStacks) { + + } } + + LogHelper.debug("Collated Recipe Inputs: " + collatedStacks.toString()); } // TODO Temporary for testing, remove this later static { + recipeRegistry = new RecipeRegistry(); CustomWrappedStack recipeOutput = new CustomWrappedStack(new ItemStack(Item.stick)); List recipes = RecipeHelper.getReverseRecipes(recipeOutput); for (IRecipe recipe : recipes) { - recipeRegistry.addRecipe(recipeOutput, RecipeHelper.getRecipeInputs(recipe)); + recipeRegistry.addRecipe(new CustomWrappedStack(recipe.getRecipeOutput()), RecipeHelper.getRecipeInputs(recipe)); } } }