From 9b8c4b57aa943d432ee2a15671492d18e8b96694 Mon Sep 17 00:00:00 2001 From: pahimar Date: Tue, 8 May 2012 17:22:15 -0400 Subject: [PATCH] Fixing things, still more to do --- ee3_common/ee3/core/RecipesPhilStone.java | 183 ++++++++++++---------- 1 file changed, 101 insertions(+), 82 deletions(-) diff --git a/ee3_common/ee3/core/RecipesPhilStone.java b/ee3_common/ee3/core/RecipesPhilStone.java index 729b7255..eedcbcf4 100644 --- a/ee3_common/ee3/core/RecipesPhilStone.java +++ b/ee3_common/ee3/core/RecipesPhilStone.java @@ -41,12 +41,12 @@ public class RecipesPhilStone { private static ItemStack boneMeal = new ItemStack(Item.dyePowder, 1, 15); public static void initRecipes() { - determineBaseMaterials(); - //initTransmutationRecipes(); - //initEquivalencyRecipes(); - //initReconstructiveRecipes(); - //initDestructorRecipes(); - //initPortableSmeltingRecipes(); + //determineBaseMaterials(); + initTransmutationRecipes(); + initEquivalencyRecipes(); + initReconstructiveRecipes(); + initDestructorRecipes(); + initPortableSmeltingRecipes(); } public static void determineBaseMaterials() { @@ -86,60 +86,81 @@ public class RecipesPhilStone { e.printStackTrace(System.err); } } + + public static void addOneWayRecipe(Object input, Object output) { + addOneWayRecipe(input, 1, output, 1); + } - /* Just a speed-loader for a linear recipes requiring the PStone */ - /* Give it an input Item/Block/ItemStack, the number inputs required, and an output ItemStack */ - public static void addOneWayRecipe(Object input, int n, ItemStack output) { - if(!(input instanceof Item || input instanceof Block || input instanceof ItemStack)) + public static void addOneWayRecipe(Object input, int n, Object output) { + addOneWayRecipe(input, n, output, 1); + } + + public static void addOneWayRecipe(Object input, int numOfInputs, Object output, int outputStackSize) { + ItemStack inputStack, outputStack = null; + + if (input instanceof Item) + inputStack = new ItemStack((Item)input); + else if (input instanceof Block) + inputStack = new ItemStack((Block)input); + else if (input instanceof ItemStack) + inputStack = (ItemStack) input; + else return; - Object[] list = new Object[n]; + + if (output instanceof Item) + outputStack = new ItemStack((Item)output); + else if (output instanceof Block) + outputStack = new ItemStack((Block)output); + else if (output instanceof ItemStack) + outputStack = (ItemStack) output; + else + return; + + outputStack.stackSize = outputStackSize; + + Object[] list = new Object[numOfInputs + 1]; list[0] = philStone; - for(int i = 1; i <= n; i++) - list[i] = input; - ModLoader.addShapelessRecipe(output, list); + for(int i = 1; i < numOfInputs + 1; i++) { + list[i] = inputStack; + } + + ModLoader.addShapelessRecipe(outputStack, list); } /* Adds a recipe AND its exact reversal */ - public static void addTwoWayRecipe(Object input, int n, ItemStack output) { - /* Adds the one-way recipe */ - addOneWayRecipe(input, n, output); - - /* Reverses the recipe by making a list of the output */ - Object[] list = new Object[output.stackSize]; - for(int i = 0; i < output.stackSize; i++) - list[i] = new ItemStack(output.itemID, 1, output.getItemDamage()); - - /* Checks the type of the input so it can make a proper ItemStack */ - if(input instanceof Item) - ModLoader.addShapelessRecipe(new ItemStack((Item)input, n), list); - else if(input instanceof Block) - ModLoader.addShapelessRecipe(new ItemStack((Block)input, n), list); - else if(input instanceof ItemStack) { - ItemStack ist = new ItemStack(((ItemStack)input).itemID, n, ((ItemStack)input).getItemDamage()); - ModLoader.addShapelessRecipe(ist, list); - } + public static void addTwoWayRecipe(Object input, Object output) { + addOneWayRecipe(input, output); + addOneWayRecipe(output, input); + } + + public static void addTwoWayRecipe(Object input, int numOfInputs, Object output, int outputStackSize) { + addOneWayRecipe(input, numOfInputs, output, outputStackSize); + addOneWayRecipe(output, outputStackSize, input, numOfInputs); } /* Pass this a Block, Item or ItemStack and the maximum number of indexes, EXCLUDING zero */ public static void addMetaCycleRecipe(Object input, int n) { - /* Decrements n by 1, so that it will include the zero index */ - n -= 1; + int outputI; + /* Makes a single item cycle through its meta values when it's crafted with a PStone */ - for(int i = 0; i <= n; i++) { - if(input instanceof Block) - ModLoader.addShapelessRecipe(new ItemStack((Block)input, 1, (i == n - 1 ? 0 : i + 1)), new Object[] { - new ItemStack((Block)input, 1, i) - }); - else if (input instanceof Item) - ModLoader.addShapelessRecipe(new ItemStack((Item)input, 1, (i == n - 1 ? 0 : i + 1)), new Object[] { - new ItemStack((Item)input, 1, i) - }); - else if (input instanceof ItemStack) { - ModLoader.addShapelessRecipe(new ItemStack(((ItemStack)input).itemID, 1, (i == n - 1 ? 0 : i + 1)), new Object[] { - new ItemStack(((ItemStack)input).itemID, 1, i) + for(int i = 0; i < n; i++) { + outputI = (i == n - 1 ? 0 : i + 1); + + if(input instanceof Block) { + ModLoader.addShapelessRecipe(new ItemStack((Block)input, 1, outputI), new Object[] { + philStone, new ItemStack((Block)input, 1, i) + }); + } + else if (input instanceof Item) { + ModLoader.addShapelessRecipe(new ItemStack((Item)input, 1, outputI), new Object[] { + philStone, new ItemStack((Item)input, 1, i) + }); + } + else if (input instanceof ItemStack) { + ModLoader.addShapelessRecipe(new ItemStack(((ItemStack)input).itemID, 1, outputI), new Object[] { + philStone, new ItemStack(((ItemStack)input).itemID, 1, i) }); } - } } @@ -181,11 +202,11 @@ public class RecipesPhilStone { /* Initialize constructive/destructive recipes */ /* 4 Cobble <-> 1 Flint */ - addTwoWayRecipe(Block.cobblestone, 4, new ItemStack(Item.flint, 1)); + addTwoWayRecipe(Block.cobblestone, 4, Item.flint, 1); /* 4 Dirt/Sand -> 1 Gravel, 1 Gravel -> 4 Dirt */ - addTwoWayRecipe(Block.dirt, 4, new ItemStack(Block.gravel, 1)); - addOneWayRecipe(Block.sand, 4, new ItemStack(Block.gravel, 1)); + addTwoWayRecipe(Block.dirt, 4, Block.gravel, 1); + addOneWayRecipe(Block.sand, 4, Block.gravel, 1); /* 2 Sticks -> Wood Plank */ addOneWayRecipe(Item.stick, 2, planks(0)); @@ -195,31 +216,31 @@ public class RecipesPhilStone { addOneWayRecipe(planks(i), 1, wood(i)); /* 4 Gravel/Sandstone/Flint -> 1 Clay Ball, 1 Clay Ball -> 4 Gravel */ - addTwoWayRecipe(Block.gravel, 4, new ItemStack(Item.clay, 1)); - addOneWayRecipe(Block.sandStone, 4, new ItemStack(Item.clay, 1)); - addOneWayRecipe(Item.flint, 4, new ItemStack(Item.clay, 1)); + addTwoWayRecipe(Block.gravel, 4, Item.clay, 1); + addOneWayRecipe(Block.sandStone, 4, Item.clay, 1); + addOneWayRecipe(Item.flint, 4, Item.clay, 1); /* 2 Wood Log <-> 1 Obsidian */ - addTwoWayRecipe(anyWood, 2, new ItemStack(Block.obsidian, 1)); + addTwoWayRecipe(anyWood, 2, Block.obsidian, 1); /* 4 Obsidian/Clay Block -> 1 Iron Ingot, Iron Ingot -> Clay Block */ - addTwoWayRecipe(Block.blockClay, 4, new ItemStack(Item.ingotIron, 1)); - addOneWayRecipe(Block.obsidian, 4, new ItemStack(Item.ingotIron, 1)); + addTwoWayRecipe(Block.blockClay, 4, Item.ingotIron, 1); + addOneWayRecipe(Block.obsidian, 4, Item.ingotIron, 1); /* 8 Iron Ingot <-> 1 Gold Ingot */ - addTwoWayRecipe(Item.ingotIron, 8, new ItemStack(Item.ingotGold, 1)); + addTwoWayRecipe(Item.ingotIron, 8, Item.ingotGold, 1); /* 4 Gold Ingot <-> 1 Diamond */ - addTwoWayRecipe(Item.ingotGold, 4, new ItemStack(Item.diamond, 1)); + addTwoWayRecipe(Item.ingotGold, 4, Item.diamond, 1); /* 8 Iron Block <-> 1 Gold Block */ - addTwoWayRecipe(Block.blockSteel, 8, new ItemStack(Block.blockGold, 1)); + addTwoWayRecipe(Block.blockSteel, 8, Block.blockGold, 1); /* 4 Gold Block <-> 1 Diamond Block */ - addTwoWayRecipe(Block.blockGold, 4, new ItemStack(Block.blockDiamond, 1)); + addTwoWayRecipe(Block.blockGold, 4, Block.blockDiamond, 1); /* 1 Ender Pearl <-> 4 Iron Ingot */ - addTwoWayRecipe(Item.ingotIron, 4, new ItemStack(Item.enderPearl, 1)); + addTwoWayRecipe(Item.ingotIron, 4, Item.enderPearl, 1); } public static void initEquivalencyRecipes() { @@ -244,40 +265,40 @@ public class RecipesPhilStone { addMetaCycleRecipe(Block.cloth, 16); /* Dirt -> Cobble -> Sand -> Dirt */ - addOneWayRecipe(Block.dirt, 1, new ItemStack(Block.cobblestone, 1)); - addOneWayRecipe(Block.cobblestone, 1, new ItemStack(Block.sand, 1)); - addOneWayRecipe(Block.sand, 1, new ItemStack(Block.dirt, 1)); + addOneWayRecipe(Block.dirt, Block.cobblestone); + addOneWayRecipe(Block.cobblestone, Block.sand); + addOneWayRecipe(Block.sand, Block.dirt); /* 2 Gravel -> 2 Flint -> 2 Sandstone (Cycles) -> 2 Gravel*/ - addOneWayRecipe(Block.gravel, 2, new ItemStack(Item.flint, 2)); - addOneWayRecipe(Item.flint, 2, sandStone(2, 0)); - addOneWayRecipe(sandStone(0), 2, sandStone(1)); - addOneWayRecipe(sandStone(1), 2, sandStone(2)); - addOneWayRecipe(sandStone(2), 2, new ItemStack(Block.gravel, 2)); + addOneWayRecipe(Block.gravel, 2, Item.flint, 2); + addOneWayRecipe(Item.flint, 2, sandStone(2, 0), 2); + addOneWayRecipe(sandStone(0), 2, sandStone(1), 2); + addOneWayRecipe(sandStone(1), 2, sandStone(2), 2); + addOneWayRecipe(sandStone(2), 2, Block.gravel, 2); /* Flower Equivalence Recipes */ - addTwoWayRecipe(Block.plantYellow, 1, new ItemStack(Block.plantRed, 1)); + addTwoWayRecipe(Block.plantYellow, Block.plantRed); // RP2 flower recipe goes here, it SHOULD make them cycle instead of two-way if RP2 is present /* Mushroom Equivalence Recipes */ - addTwoWayRecipe(Block.mushroomBrown, 1, new ItemStack(Block.mushroomRed, 1)); + addTwoWayRecipe(Block.mushroomBrown, Block.mushroomRed); /* Books/ */ /* Reeds <-> Paper <-> Sugar Equivalence Recipes */ - addOneWayRecipe(Item.book, 1, new ItemStack(Item.paper, 3)); - addOneWayRecipe(Item.paper, 3, new ItemStack(Item.reed, 3)); - addOneWayRecipe(Item.sugar, 1, new ItemStack(Item.reed, 1)); + addOneWayRecipe(Item.book, 1, Item.paper, 3); + addOneWayRecipe(Item.paper, 3, Item.reed, 3); + addOneWayRecipe(Item.sugar, Item.reed); /* Melon <-> Pumpkin Equivalence Recipes */ - addTwoWayRecipe(Item.pumpkinSeeds, 1, new ItemStack(Item.melonSeeds, 1)); - addTwoWayRecipe(Block.pumpkin, 1, new ItemStack(Block.melon, 1)); + addTwoWayRecipe(Item.pumpkinSeeds, Item.melonSeeds); + addTwoWayRecipe(Block.pumpkin, Block.melon); } public static void initReconstructiveRecipes() { - /* 3 Bone Meal <-> 1 Bone */ + /* 3 Bone Meal --> 1 Bone */ addOneWayRecipe(boneMeal, 3, new ItemStack(Item.bone, 1)); - /* 2 Blaze Powder <-> 1 Blaze Rod */ + /* 2 Blaze Powder --> 1 Blaze Rod */ addOneWayRecipe(Item.blazePowder, 2, new ItemStack(Item.blazeRod, 1)); } @@ -286,10 +307,10 @@ public class RecipesPhilStone { addOneWayRecipe(Block.blockClay, 1, new ItemStack(Item.clay, 4)); /* Smooth Stone -> Cobble Stone */ - addOneWayRecipe(Block.stone, 1, new ItemStack(Block.cobblestone, 1)); + addOneWayRecipe(Block.stone, Block.cobblestone); /* Glass -> Sand */ - addOneWayRecipe(Block.glass, 1, new ItemStack(Block.sand, 1)); + addOneWayRecipe(Block.glass, Block.sand); /* Glowstone Block -> 4 Glowstone Dust */ addOneWayRecipe(Block.glowStone, 1, new ItemStack(Item.lightStoneDust, 4)); @@ -308,14 +329,12 @@ public class RecipesPhilStone { /* Smelt iron ore */ addSmeltingRecipe(Block.oreIron); - /* Smelt gold ore */ addSmeltingRecipe(Block.oreGold); /* Smelt sand */ addSmeltingRecipe(Block.sand); - /* Cook chicken */ addSmeltingRecipe(Item.chickenRaw);