This commit is contained in:
pahimar 2013-06-21 13:04:55 -04:00
parent 9ac6722860
commit 5f7ea23a4f
2 changed files with 35 additions and 26 deletions

View file

@ -164,33 +164,31 @@ public class RecipeHelper {
return ItemUtil.collateStacks(getRecipeInputs(recipe));
}
public static ArrayList<IRecipe> 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<IRecipe>();
}
@SuppressWarnings("unchecked")
public static ArrayList<IRecipe> getReverseRecipes(ItemStack itemStack) {
public static ArrayList<IRecipe> getReverseRecipes(CustomWrappedStack wrappedStack) {
ArrayList<IRecipe> reverseRecipeList = new ArrayList<IRecipe>();
if (itemStack != null) {
ArrayList<IRecipe> craftingManagerRecipeList = new ArrayList<IRecipe>(CraftingManager.getInstance().getRecipeList());
ArrayList<IRecipe> recipeList = new ArrayList<IRecipe>(CraftingManager.getInstance().getRecipeList());
for (IRecipe recipe : recipeList) {
for (IRecipe recipe : craftingManagerRecipeList) {
if (recipe.getRecipeOutput() != null) {
if (ItemUtil.compare(itemStack, recipe.getRecipeOutput())) {
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);
}
}
}
}
}

View file

@ -21,7 +21,6 @@ public class RecipeRegistry {
private Multimap<CustomWrappedStack, List<CustomWrappedStack>> recipeMap;
@SuppressWarnings("unused")
private List<CustomWrappedStack> 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<CustomWrappedStack> collatedStacks = new ArrayList<CustomWrappedStack>();
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<IRecipe> recipes = RecipeHelper.getReverseRecipes(recipeOutput);
for (IRecipe recipe : recipes) {
recipeRegistry.addRecipe(recipeOutput, RecipeHelper.getRecipeInputs(recipe));
recipeRegistry.addRecipe(new CustomWrappedStack(recipe.getRecipeOutput()), RecipeHelper.getRecipeInputs(recipe));
}
}
}