diff --git a/recipes/Ingredient.java b/recipes/Ingredient.java index 860a2571..d93feb60 100644 --- a/recipes/Ingredient.java +++ b/recipes/Ingredient.java @@ -103,6 +103,8 @@ public class Ingredient implements IIngredient } else throw new RecipeError( input + " : Needs at least Namespace and Name." ); + + handler.data.knownItem.add( toString() ); } @Override @@ -171,7 +173,7 @@ public class Ingredient implements IIngredient } if ( set.length == 0 ) - throw new MissingIngredientError( toString() + " - ore dictionary could not be resolved to any items." ); + throw new MissingIngredientError( getItemName() + " - ore dictionary could not be resolved to any items." ); return set; } diff --git a/recipes/RecipeHandler.java b/recipes/RecipeHandler.java index 5b2412f4..8b66ba0f 100644 --- a/recipes/RecipeHandler.java +++ b/recipes/RecipeHandler.java @@ -11,6 +11,8 @@ import java.util.Map.Entry; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; +import com.google.common.collect.HashMultimap; + import net.minecraft.item.ItemStack; import appeng.api.AEApi; import appeng.api.exceptions.MissingIngredientError; @@ -133,37 +135,50 @@ public class RecipeHandler implements IRecipeHandler { ZipOutputStream out = new ZipOutputStream( new FileOutputStream( "recipes.zip" ) ); + HashMultimap combined = HashMultimap.create(); + for (String s : data.knownItem) { - try - { + try { + Ingredient i = new Ingredient( this, s, 1 ); + for (ItemStack is : i.getItemStackSet()) { + String realName = getName( is ); List recipes = findRecipe( is ); if ( !recipes.isEmpty() ) - { - int offset = 0; - String realName = getName( is ); - - for (IWebsiteSeralizer ws : recipes) - { - out.putNextEntry( new ZipEntry( realName + "_" + offset + ".txt" ) ); - offset++; - out.write( ws.getPattern( this ).getBytes() ); - } - - } + combined.putAll(realName, recipes); } + + } catch (RecipeError e1) { + + } catch (MissedIngredientSet e1) { + + } catch (RegistrationError e1) { + + } catch (MissingIngredientError e1) { + } - catch (Throwable t) + } + + for ( String realName : combined.keySet() ) + { + int offset = 0; + + for ( IWebsiteSeralizer ws : combined.get(realName) ) { - // :P - } + String rew = ws.getPattern( this ); + if ( rew != null && rew.length() > 0 ) + { + out.putNextEntry( new ZipEntry( realName + "_" + offset + ".txt" ) ); + offset++; + out.write( rew.getBytes() ); + } + } } out.close(); - } catch (FileNotFoundException e1) { @@ -256,7 +271,7 @@ public class RecipeHandler implements IRecipeHandler switch (is.getItemDamage()) { case 1: - realName = realName.replace( "blockCraftingUnit", "blockCraftingAccelerator" ); + realName = realName.replace( "Unit", "Accelerator" ); break; default: } @@ -585,7 +600,6 @@ public class RecipeHandler implements IRecipeHandler if ( gi != null ) return gi.copy( qty ); - data.knownItem.add( v ); try { return new Ingredient( this, v, qty ); diff --git a/recipes/handlers/Shaped.java b/recipes/handlers/Shaped.java index 8cfe1d93..e2750d8b 100644 --- a/recipes/handlers/Shaped.java +++ b/recipes/handlers/Shaped.java @@ -93,6 +93,21 @@ public class Shaped implements ICraftHandler, IWebsiteSeralizer @Override public boolean canCraft(ItemStack reqOutput) throws RegistrationError, MissingIngredientError { + for (int y = 0; y < rows; y++) + for (int x = 0; x < cols; x++) + { + IIngredient i = inputs.get( y ).get( x ); + + if ( !i.isAir() ) + { + for ( ItemStack r : i.getItemStackSet() ) + { + if ( Platform.isSameItemPrecise( r, reqOutput) ) + return false; + } + } + } + return Platform.isSameItemPrecise( output.getItemStack(), reqOutput ); } diff --git a/recipes/handlers/Shapeless.java b/recipes/handlers/Shapeless.java index 5c0f50c6..6a514444 100644 --- a/recipes/handlers/Shapeless.java +++ b/recipes/handlers/Shapeless.java @@ -60,6 +60,20 @@ public class Shapeless implements ICraftHandler, IWebsiteSeralizer @Override public boolean canCraft(ItemStack reqOutput) throws RegistrationError, MissingIngredientError { + + for ( int y = 0; y < inputs.size(); y++ ) + { + IIngredient i = inputs.get(y); + if ( !i.isAir() ) + { + for ( ItemStack r : i.getItemStackSet() ) + { + if ( Platform.isSameItemPrecise( r, reqOutput) ) + return false; + } + } + } + return Platform.isSameItemPrecise( output.getItemStack(),reqOutput ); }