From 1cb05052f26b7647a25447a34bc9b312304d6fa0 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Thu, 11 Sep 2014 23:06:46 -0500 Subject: [PATCH] Updated Craft Guide Integration to match new version of Recipe System. --- integration/modules/CraftGuide.java | 68 ++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 6 deletions(-) diff --git a/integration/modules/CraftGuide.java b/integration/modules/CraftGuide.java index 7e837579..4eb78b6c 100644 --- a/integration/modules/CraftGuide.java +++ b/integration/modules/CraftGuide.java @@ -22,6 +22,9 @@ import uristqwerty.CraftGuide.api.StackInfo; import uristqwerty.CraftGuide.api.StackInfoSource; import uristqwerty.gui_craftguide.texture.DynamicTexture; import uristqwerty.gui_craftguide.texture.TextureClip; +import appeng.api.exceptions.MissingIngredientError; +import appeng.api.exceptions.RegistrationError; +import appeng.api.recipes.IIngredient; import appeng.integration.IIntegrationModule; import appeng.recipes.game.ShapedRecipe; import appeng.recipes.game.ShapelessRecipe; @@ -222,8 +225,21 @@ public class CraftGuide extends CraftGuideAPIObject implements IIntegrationModul if ( output[i] instanceof ItemStack[] ) output[i] = Arrays.asList( (ItemStack[]) output[i] ); - // if ( output[i] instanceof List ) - // output[i] = ((List) output[i]).get( 0 ); + if ( output[i] instanceof IIngredient ) + { + try + { + output[i] = toCG( ((IIngredient) output[i]).getItemStackSet() ); + } + catch (RegistrationError e) + { + + } + catch (MissingIngredientError e) + { + + } + } } output[9] = recipeOutput; @@ -244,8 +260,21 @@ public class CraftGuide extends CraftGuideAPIObject implements IIntegrationModul if ( output[i] instanceof ItemStack[] ) output[i] = Arrays.asList( (ItemStack[]) output[i] ); - // if ( output[i] instanceof List ) - // output[i] = ((List) output[i]).get( 0 ); + if ( output[i] instanceof IIngredient ) + { + try + { + output[i] = toCG( ((IIngredient) output[i]).getItemStackSet() ); + } + catch (RegistrationError e) + { + + } + catch (MissingIngredientError e) + { + + } + } } } @@ -267,8 +296,21 @@ public class CraftGuide extends CraftGuideAPIObject implements IIntegrationModul if ( output[i] instanceof ItemStack[] ) output[i] = Arrays.asList( (ItemStack[]) output[i] ); - // if ( output[i] instanceof List ) - // output[i] = ((List) output[i]).get( 0 ); + if ( output[i] instanceof IIngredient ) + { + try + { + output[i] = toCG( ((IIngredient) output[i]).getItemStackSet() ); + } + catch (RegistrationError e) + { + + } + catch (MissingIngredientError e) + { + + } + } } } @@ -276,6 +318,20 @@ public class CraftGuide extends CraftGuideAPIObject implements IIntegrationModul return output; } + private Object toCG(ItemStack[] itemStackSet) + { + List list = Arrays.asList( itemStackSet ); + + for (int x = 0; x < list.size(); x++) + { + list.set( x, list.get( x ).copy() ); + if ( list.get( x ).stackSize == 0 ) + list.get( x ).stackSize = 1; + } + + return list; + } + @Override public Object[] getCraftingRecipe(IRecipe recipe, boolean allowSmallGrid) {