Fixing things, still more to do

This commit is contained in:
pahimar 2012-05-08 17:22:15 -04:00
parent 76a986361e
commit 9b8c4b57aa

View file

@ -41,12 +41,12 @@ public class RecipesPhilStone {
private static ItemStack boneMeal = new ItemStack(Item.dyePowder, 1, 15); private static ItemStack boneMeal = new ItemStack(Item.dyePowder, 1, 15);
public static void initRecipes() { public static void initRecipes() {
determineBaseMaterials(); //determineBaseMaterials();
//initTransmutationRecipes(); initTransmutationRecipes();
//initEquivalencyRecipes(); initEquivalencyRecipes();
//initReconstructiveRecipes(); initReconstructiveRecipes();
//initDestructorRecipes(); initDestructorRecipes();
//initPortableSmeltingRecipes(); initPortableSmeltingRecipes();
} }
public static void determineBaseMaterials() { public static void determineBaseMaterials() {
@ -86,60 +86,81 @@ public class RecipesPhilStone {
e.printStackTrace(System.err); 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 */ public static void addOneWayRecipe(Object input, int n, Object output) {
/* Give it an input Item/Block/ItemStack, the number inputs required, and an output ItemStack */ addOneWayRecipe(input, n, output, 1);
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 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; 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; list[0] = philStone;
for(int i = 1; i <= n; i++) for(int i = 1; i < numOfInputs + 1; i++) {
list[i] = input; list[i] = inputStack;
ModLoader.addShapelessRecipe(output, list); }
ModLoader.addShapelessRecipe(outputStack, list);
} }
/* Adds a recipe AND its exact reversal */ /* Adds a recipe AND its exact reversal */
public static void addTwoWayRecipe(Object input, int n, ItemStack output) { public static void addTwoWayRecipe(Object input, Object output) {
/* Adds the one-way recipe */ addOneWayRecipe(input, output);
addOneWayRecipe(input, n, output); addOneWayRecipe(output, input);
}
/* Reverses the recipe by making a list of the output */
Object[] list = new Object[output.stackSize]; public static void addTwoWayRecipe(Object input, int numOfInputs, Object output, int outputStackSize) {
for(int i = 0; i < output.stackSize; i++) addOneWayRecipe(input, numOfInputs, output, outputStackSize);
list[i] = new ItemStack(output.itemID, 1, output.getItemDamage()); addOneWayRecipe(output, outputStackSize, input, numOfInputs);
/* 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);
}
} }
/* Pass this a Block, Item or ItemStack and the maximum number of indexes, EXCLUDING zero */ /* Pass this a Block, Item or ItemStack and the maximum number of indexes, EXCLUDING zero */
public static void addMetaCycleRecipe(Object input, int n) { public static void addMetaCycleRecipe(Object input, int n) {
/* Decrements n by 1, so that it will include the zero index */ int outputI;
n -= 1;
/* Makes a single item cycle through its meta values when it's crafted with a PStone */ /* Makes a single item cycle through its meta values when it's crafted with a PStone */
for(int i = 0; i <= n; i++) { for(int i = 0; i < n; i++) {
if(input instanceof Block) outputI = (i == n - 1 ? 0 : i + 1);
ModLoader.addShapelessRecipe(new ItemStack((Block)input, 1, (i == n - 1 ? 0 : i + 1)), new Object[] {
new ItemStack((Block)input, 1, i) if(input instanceof Block) {
}); ModLoader.addShapelessRecipe(new ItemStack((Block)input, 1, outputI), new Object[] {
else if (input instanceof Item) philStone, new ItemStack((Block)input, 1, i)
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 Item) {
else if (input instanceof ItemStack) { ModLoader.addShapelessRecipe(new ItemStack((Item)input, 1, outputI), new Object[] {
ModLoader.addShapelessRecipe(new ItemStack(((ItemStack)input).itemID, 1, (i == n - 1 ? 0 : i + 1)), new Object[] { philStone, new ItemStack((Item)input, 1, i)
new ItemStack(((ItemStack)input).itemID, 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 */ /* Initialize constructive/destructive recipes */
/* 4 Cobble <-> 1 Flint */ /* 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 */ /* 4 Dirt/Sand -> 1 Gravel, 1 Gravel -> 4 Dirt */
addTwoWayRecipe(Block.dirt, 4, new ItemStack(Block.gravel, 1)); addTwoWayRecipe(Block.dirt, 4, Block.gravel, 1);
addOneWayRecipe(Block.sand, 4, new ItemStack(Block.gravel, 1)); addOneWayRecipe(Block.sand, 4, Block.gravel, 1);
/* 2 Sticks -> Wood Plank */ /* 2 Sticks -> Wood Plank */
addOneWayRecipe(Item.stick, 2, planks(0)); addOneWayRecipe(Item.stick, 2, planks(0));
@ -195,31 +216,31 @@ public class RecipesPhilStone {
addOneWayRecipe(planks(i), 1, wood(i)); addOneWayRecipe(planks(i), 1, wood(i));
/* 4 Gravel/Sandstone/Flint -> 1 Clay Ball, 1 Clay Ball -> 4 Gravel */ /* 4 Gravel/Sandstone/Flint -> 1 Clay Ball, 1 Clay Ball -> 4 Gravel */
addTwoWayRecipe(Block.gravel, 4, new ItemStack(Item.clay, 1)); addTwoWayRecipe(Block.gravel, 4, Item.clay, 1);
addOneWayRecipe(Block.sandStone, 4, new ItemStack(Item.clay, 1)); addOneWayRecipe(Block.sandStone, 4, Item.clay, 1);
addOneWayRecipe(Item.flint, 4, new ItemStack(Item.clay, 1)); addOneWayRecipe(Item.flint, 4, Item.clay, 1);
/* 2 Wood Log <-> 1 Obsidian */ /* 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 */ /* 4 Obsidian/Clay Block -> 1 Iron Ingot, Iron Ingot -> Clay Block */
addTwoWayRecipe(Block.blockClay, 4, new ItemStack(Item.ingotIron, 1)); addTwoWayRecipe(Block.blockClay, 4, Item.ingotIron, 1);
addOneWayRecipe(Block.obsidian, 4, new ItemStack(Item.ingotIron, 1)); addOneWayRecipe(Block.obsidian, 4, Item.ingotIron, 1);
/* 8 Iron Ingot <-> 1 Gold Ingot */ /* 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 */ /* 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 */ /* 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 */ /* 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 */ /* 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() { public static void initEquivalencyRecipes() {
@ -244,40 +265,40 @@ public class RecipesPhilStone {
addMetaCycleRecipe(Block.cloth, 16); addMetaCycleRecipe(Block.cloth, 16);
/* Dirt -> Cobble -> Sand -> Dirt */ /* Dirt -> Cobble -> Sand -> Dirt */
addOneWayRecipe(Block.dirt, 1, new ItemStack(Block.cobblestone, 1)); addOneWayRecipe(Block.dirt, Block.cobblestone);
addOneWayRecipe(Block.cobblestone, 1, new ItemStack(Block.sand, 1)); addOneWayRecipe(Block.cobblestone, Block.sand);
addOneWayRecipe(Block.sand, 1, new ItemStack(Block.dirt, 1)); addOneWayRecipe(Block.sand, Block.dirt);
/* 2 Gravel -> 2 Flint -> 2 Sandstone (Cycles) -> 2 Gravel*/ /* 2 Gravel -> 2 Flint -> 2 Sandstone (Cycles) -> 2 Gravel*/
addOneWayRecipe(Block.gravel, 2, new ItemStack(Item.flint, 2)); addOneWayRecipe(Block.gravel, 2, Item.flint, 2);
addOneWayRecipe(Item.flint, 2, sandStone(2, 0)); addOneWayRecipe(Item.flint, 2, sandStone(2, 0), 2);
addOneWayRecipe(sandStone(0), 2, sandStone(1)); addOneWayRecipe(sandStone(0), 2, sandStone(1), 2);
addOneWayRecipe(sandStone(1), 2, sandStone(2)); addOneWayRecipe(sandStone(1), 2, sandStone(2), 2);
addOneWayRecipe(sandStone(2), 2, new ItemStack(Block.gravel, 2)); addOneWayRecipe(sandStone(2), 2, Block.gravel, 2);
/* Flower Equivalence Recipes */ /* 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 // RP2 flower recipe goes here, it SHOULD make them cycle instead of two-way if RP2 is present
/* Mushroom Equivalence Recipes */ /* Mushroom Equivalence Recipes */
addTwoWayRecipe(Block.mushroomBrown, 1, new ItemStack(Block.mushroomRed, 1)); addTwoWayRecipe(Block.mushroomBrown, Block.mushroomRed);
/* Books/ */ /* Books/ */
/* Reeds <-> Paper <-> Sugar Equivalence Recipes */ /* Reeds <-> Paper <-> Sugar Equivalence Recipes */
addOneWayRecipe(Item.book, 1, new ItemStack(Item.paper, 3)); addOneWayRecipe(Item.book, 1, Item.paper, 3);
addOneWayRecipe(Item.paper, 3, new ItemStack(Item.reed, 3)); addOneWayRecipe(Item.paper, 3, Item.reed, 3);
addOneWayRecipe(Item.sugar, 1, new ItemStack(Item.reed, 1)); addOneWayRecipe(Item.sugar, Item.reed);
/* Melon <-> Pumpkin Equivalence Recipes */ /* Melon <-> Pumpkin Equivalence Recipes */
addTwoWayRecipe(Item.pumpkinSeeds, 1, new ItemStack(Item.melonSeeds, 1)); addTwoWayRecipe(Item.pumpkinSeeds, Item.melonSeeds);
addTwoWayRecipe(Block.pumpkin, 1, new ItemStack(Block.melon, 1)); addTwoWayRecipe(Block.pumpkin, Block.melon);
} }
public static void initReconstructiveRecipes() { public static void initReconstructiveRecipes() {
/* 3 Bone Meal <-> 1 Bone */ /* 3 Bone Meal --> 1 Bone */
addOneWayRecipe(boneMeal, 3, new ItemStack(Item.bone, 1)); 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)); 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)); addOneWayRecipe(Block.blockClay, 1, new ItemStack(Item.clay, 4));
/* Smooth Stone -> Cobble Stone */ /* Smooth Stone -> Cobble Stone */
addOneWayRecipe(Block.stone, 1, new ItemStack(Block.cobblestone, 1)); addOneWayRecipe(Block.stone, Block.cobblestone);
/* Glass -> Sand */ /* Glass -> Sand */
addOneWayRecipe(Block.glass, 1, new ItemStack(Block.sand, 1)); addOneWayRecipe(Block.glass, Block.sand);
/* Glowstone Block -> 4 Glowstone Dust */ /* Glowstone Block -> 4 Glowstone Dust */
addOneWayRecipe(Block.glowStone, 1, new ItemStack(Item.lightStoneDust, 4)); addOneWayRecipe(Block.glowStone, 1, new ItemStack(Item.lightStoneDust, 4));
@ -308,14 +329,12 @@ public class RecipesPhilStone {
/* Smelt iron ore */ /* Smelt iron ore */
addSmeltingRecipe(Block.oreIron); addSmeltingRecipe(Block.oreIron);
/* Smelt gold ore */ /* Smelt gold ore */
addSmeltingRecipe(Block.oreGold); addSmeltingRecipe(Block.oreGold);
/* Smelt sand */ /* Smelt sand */
addSmeltingRecipe(Block.sand); addSmeltingRecipe(Block.sand);
/* Cook chicken */ /* Cook chicken */
addSmeltingRecipe(Item.chickenRaw); addSmeltingRecipe(Item.chickenRaw);