More work on the Philosopher Stone recipes. Starting on some recursive stuff on the CraftingManager to determine base items for all the loaded recipes.

This commit is contained in:
pahimar 2012-05-06 21:09:51 -04:00
parent 14599c50a9
commit 37e620adf4
4 changed files with 420 additions and 16 deletions

View file

@ -1,22 +1,280 @@
package net.minecraft.src.ee3.core;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import net.minecraft.src.Block;
import net.minecraft.src.CraftingManager;
import net.minecraft.src.IRecipe;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.ModLoader;
import net.minecraft.src.ShapedRecipes;
import net.minecraft.src.ShapelessRecipes;
import net.minecraft.src.ee3.item.ModItems;
import net.minecraft.src.ee3.item.ItemPhilosopherStone;
public class RecipesPhilStone {
public void init() {
// X dirt == X cobblestone == X stone == X sand
// X gravel == X sandstone
// X rose == X dandelion == X indigo flower (RP2)
// X sapling == X birch sapling == X pine sapling == X jungle sapling
// X wood == X birch wood == X pine wood == X jungle wood
// X wood plank == X birch wood plank == X pine wood plank == X jungle wood plank
// X wool == X wool (next meta colour)
/* Cobblestone to diamond recipe path */
// X cobblestone == X/4 gravel
// X gravel == X/8 wood
// X wood == X/2 obsidian
// X obsidian == X/4 iron ingot
// X iron ingot == X/8 gold ingot
// X gold ingot == X/4 diamond
/* Therefore, 8192 cobblestone == 2048 gravel == 256 wood == 128 obsidian == 32 iron ingot == 4 gold ingot == 1 diamond */
public static ItemStack philStone = new ItemStack(ModItems.philStone, 1, -1);
private static ItemStack coal = new ItemStack(Item.coal, 1, 0);
private static ItemStack charcoal = new ItemStack(Item.coal, 1, 1);
private static ItemStack oakWood = new ItemStack(Block.wood, 1, 0);
private static ItemStack birchWood = new ItemStack(Block.wood, 1, 1);
private static ItemStack pineWood = new ItemStack(Block.wood, 1, 2);
private static ItemStack jungleWood = new ItemStack(Block.wood, 1, 3);
public static void initRecipes() {
determineBaseMaterials();
//initEquivalencyRecipes();
//initDestructorRecipes();
//initPortableSmeltingRecipes();
}
public static void determineBaseMaterials() {
CraftingManager instance = CraftingManager.getInstance();
List recipeList = instance.getRecipeList();
IRecipe recipe;
ShapedRecipes shapedRecipe;
ShapelessRecipes shapelessRecipe;
Iterator<IRecipe> recipeIter = recipeList.iterator();
while (recipeIter.hasNext()) {
recipe = recipeIter.next();
if (recipe instanceof ShapedRecipes)
System.out.println("Shaped");
else if (recipe instanceof ShapelessRecipes)
System.out.println("Shapeless");
}
}
public static void initEquivalencyRecipes() {
/* Dirt <-> Cobble <-> Sand Equivalence Recipes */
ModLoader.addShapelessRecipe(new ItemStack(Block.cobblestone, 1), new Object[] {
philStone, Block.dirt
});
ModLoader.addShapelessRecipe(new ItemStack(Block.sand, 1), new Object[] {
philStone, Block.cobblestone
});
ModLoader.addShapelessRecipe(new ItemStack(Block.dirt, 1), new Object[] {
philStone, Block.sand
});
/* Sapling Equivalence Recipes */
ModLoader.addShapelessRecipe(new ItemStack(Block.sapling, 1, 1), new Object[] {
philStone, new ItemStack(Block.sapling, 1, 0)
});
ModLoader.addShapelessRecipe(new ItemStack(Block.sapling, 1, 2), new Object[] {
philStone, new ItemStack(Block.sapling, 1, 1)
});
ModLoader.addShapelessRecipe(new ItemStack(Block.sapling, 1, 3), new Object[] {
philStone, new ItemStack(Block.sapling, 1, 2)
});
ModLoader.addShapelessRecipe(new ItemStack(Block.sapling, 1, 0), new Object[] {
philStone, new ItemStack(Block.sapling, 1, 3)
});
/* Leaf Equivalence Recipes */
ModLoader.addShapelessRecipe(new ItemStack(Block.leaves, 1, 1), new Object[] {
philStone, new ItemStack(Block.leaves, 1, 0)
});
ModLoader.addShapelessRecipe(new ItemStack(Block.leaves, 1, 2), new Object[] {
philStone, new ItemStack(Block.leaves, 1, 1)
});
ModLoader.addShapelessRecipe(new ItemStack(Block.leaves, 1, 3), new Object[] {
philStone, new ItemStack(Block.leaves, 1, 2)
});
ModLoader.addShapelessRecipe(new ItemStack(Block.leaves, 1, 0), new Object[] {
philStone, new ItemStack(Block.leaves, 1, 3)
});
/* Wood Log Equivalence Recipes */
ModLoader.addShapelessRecipe(new ItemStack(Block.wood, 1, 1), new Object[] {
philStone, new ItemStack(Block.wood, 1, 0)
});
ModLoader.addShapelessRecipe(new ItemStack(Block.wood, 1, 2), new Object[] {
philStone, new ItemStack(Block.wood, 1, 1)
});
ModLoader.addShapelessRecipe(new ItemStack(Block.wood, 1, 3), new Object[] {
philStone, new ItemStack(Block.wood, 1, 2)
});
ModLoader.addShapelessRecipe(new ItemStack(Block.wood, 1, 0), new Object[] {
philStone, new ItemStack(Block.wood, 1, 3)
});
/* Wood Plank Equivalence Recipes */
ModLoader.addShapelessRecipe(new ItemStack(Block.planks, 1, 1), new Object[] {
philStone, new ItemStack(Block.planks, 1, 0)
});
ModLoader.addShapelessRecipe(new ItemStack(Block.planks, 1, 2), new Object[] {
philStone, new ItemStack(Block.planks, 1, 1)
});
ModLoader.addShapelessRecipe(new ItemStack(Block.planks, 1, 3), new Object[] {
philStone, new ItemStack(Block.planks, 1, 2)
});
ModLoader.addShapelessRecipe(new ItemStack(Block.planks, 1, 0), new Object[] {
philStone, new ItemStack(Block.planks, 1, 3)
});
/* Flower Equivalence Recipes */
ModLoader.addShapelessRecipe(new ItemStack(Block.plantRed, 1), new Object[] {
philStone, Block.plantYellow
});
ModLoader.addShapelessRecipe(new ItemStack(Block.plantYellow, 1), new Object[] {
philStone, Block.plantRed
});
// RP2 flower recipe goes here
/* Mushroom Equivalence Recipes */
ModLoader.addShapelessRecipe(new ItemStack(Block.mushroomBrown, 1), new Object[] {
philStone, Block.mushroomRed
});
ModLoader.addShapelessRecipe(new ItemStack(Block.mushroomRed, 1), new Object[] {
philStone, Block.mushroomBrown
});
/* Gravel <-> Sandstone <-> Fancy Sandstone I <-> Fancy Sandstone II Equivalence Recipes */
ModLoader.addShapelessRecipe(new ItemStack(Block.sandStone, 1, 0), new Object[] {
philStone, new ItemStack(Block.gravel, 1)
});
ModLoader.addShapelessRecipe(new ItemStack(Block.sandStone, 1, 1), new Object[] {
philStone, new ItemStack(Block.sandStone, 1, 0)
});
ModLoader.addShapelessRecipe(new ItemStack(Block.sandStone, 1, 2), new Object[] {
philStone, new ItemStack(Block.sandStone, 1, 1)
});
ModLoader.addShapelessRecipe(new ItemStack(Block.gravel, 1), new Object[] {
philStone, new ItemStack(Block.sandStone, 1, 2)
});
/* Reeds <-> Paper <-> Sugar Equivalence Recipes */
ModLoader.addShapelessRecipe(new ItemStack(Item.reed, 3), new Object[] {
philStone, Item.paper, Item.paper, Item.paper
});
ModLoader.addShapelessRecipe(new ItemStack(Item.reed, 1), new Object[] {
philStone, Item.sugar
});
/* Melon <-> Pumpkin Equivalence Recipes */
ModLoader.addShapelessRecipe(new ItemStack(Item.pumpkinSeeds, 1), new Object[] {
philStone, Item.melonSeeds
});
ModLoader.addShapelessRecipe(new ItemStack(Item.melonSeeds, 1), new Object[] {
philStone, Item.pumpkinSeeds
});
ModLoader.addShapelessRecipe(new ItemStack(Block.pumpkin, 1), new Object[] {
philStone, Block.melon
});
ModLoader.addShapelessRecipe(new ItemStack(Block.melon, 1), new Object[] {
philStone, Block.pumpkin
});
/* Tall Grass Equivalence Recipes */
ModLoader.addShapelessRecipe(new ItemStack(Block.tallGrass, 1, 1), new Object[] {
philStone, new ItemStack(Block.tallGrass, 1, 0)
});
ModLoader.addShapelessRecipe(new ItemStack(Block.tallGrass, 1, 2), new Object[] {
philStone, new ItemStack(Block.tallGrass, 1, 1)
});
ModLoader.addShapelessRecipe(new ItemStack(Block.tallGrass, 1, 0), new Object[] {
philStone, new ItemStack(Block.tallGrass, 1, 2)
});
}
public static void initDestructorRecipes() {
/* Clay Block -> 4 Clay Balls */
//ModLoader.addShapelessRecipe(new ItemStack(Item.clay, 4), new Object[] {
ModLoader.addShapelessRecipe(new ItemStack(Item.clay, 4), new Object[] {
philStone, Block.blockClay
});
/* Smooth Stone -> Cobble Stone */
ModLoader.addShapelessRecipe(new ItemStack(Block.cobblestone, 1), new Object[] {
philStone, Block.stone
});
/* Glass -> Sand */
ModLoader.addShapelessRecipe(new ItemStack(Block.sand, 1), new Object[] {
philStone, Block.glass
});
/* Glowstone Block -> 4 Glowstone Dust */
ModLoader.addShapelessRecipe(new ItemStack(Item.lightStoneDust, 4), new Object[] {
philStone, Block.glowStone
});
/* Brick Block -> 4 Bricks */
ModLoader.addShapelessRecipe(new ItemStack(Item.brick, 4), new Object[] {
philStone, Block.brick
});
}
public static void initPortableSmeltingRecipes() {
/* 7 Cobble + 1 Coal|Charcoal = 7 Stone */
ModLoader.addShapelessRecipe(new ItemStack(Block.stone, 7), new Object[] {
philStone, Block.cobblestone, Block.cobblestone, Block.cobblestone, Block.cobblestone, Block.cobblestone, Block.cobblestone, Block.cobblestone, coal
});
ModLoader.addShapelessRecipe(new ItemStack(Block.stone, 7), new Object[] {
philStone, Block.cobblestone, Block.cobblestone, Block.cobblestone, Block.cobblestone, Block.cobblestone, Block.cobblestone, Block.cobblestone, charcoal
});
/* 7 Wood Logs + 1 Coal|Charcoal = 7 Charcoal */
ModLoader.addShapelessRecipe(new ItemStack(Item.coal, 7, 1), new Object[] {
philStone, coal, oakWood, oakWood, oakWood, oakWood, oakWood, oakWood, oakWood
});
ModLoader.addShapelessRecipe(new ItemStack(Item.coal, 7, 1), new Object[] {
philStone, charcoal, oakWood, oakWood, oakWood, oakWood, oakWood, oakWood, oakWood
});
ModLoader.addShapelessRecipe(new ItemStack(Item.coal, 7, 1), new Object[] {
philStone, coal, birchWood, birchWood, birchWood, birchWood, birchWood, birchWood, birchWood
});
ModLoader.addShapelessRecipe(new ItemStack(Item.coal, 7, 1), new Object[] {
philStone, charcoal, birchWood, birchWood, birchWood, birchWood, birchWood, birchWood, birchWood
});
ModLoader.addShapelessRecipe(new ItemStack(Item.coal, 7, 1), new Object[] {
philStone, coal, pineWood, pineWood, pineWood, pineWood, pineWood, pineWood, pineWood
});
ModLoader.addShapelessRecipe(new ItemStack(Item.coal, 7, 1), new Object[] {
philStone, charcoal, pineWood, pineWood, pineWood, pineWood, pineWood, pineWood, pineWood
});
ModLoader.addShapelessRecipe(new ItemStack(Item.coal, 7, 1), new Object[] {
philStone, coal, jungleWood, jungleWood, jungleWood, jungleWood, jungleWood, jungleWood, jungleWood
});
ModLoader.addShapelessRecipe(new ItemStack(Item.coal, 7, 1), new Object[] {
philStone, charcoal, jungleWood, jungleWood, jungleWood, jungleWood, jungleWood, jungleWood, jungleWood
});
/* 7 Iron Ore + 1 Coal|Charcoal = 7 Iron Ingot */
ModLoader.addShapelessRecipe(new ItemStack(Item.ingotIron, 7), new Object[] {
philStone, coal, Block.oreIron, Block.oreIron, Block.oreIron, Block.oreIron, Block.oreIron, Block.oreIron, Block.oreIron
});
ModLoader.addShapelessRecipe(new ItemStack(Item.ingotIron, 7), new Object[] {
philStone, charcoal, Block.oreIron, Block.oreIron, Block.oreIron, Block.oreIron, Block.oreIron, Block.oreIron, Block.oreIron
});
/* 7 Gold Ore + 1 Coal|Charcoal = 7 Gold Ingot */
ModLoader.addShapelessRecipe(new ItemStack(Item.ingotGold, 7), new Object[] {
philStone, coal, Block.oreGold, Block.oreGold, Block.oreGold, Block.oreGold, Block.oreGold, Block.oreGold, Block.oreGold
});
ModLoader.addShapelessRecipe(new ItemStack(Item.ingotGold, 7), new Object[] {
philStone, charcoal, Block.oreGold, Block.oreGold, Block.oreGold, Block.oreGold, Block.oreGold, Block.oreGold, Block.oreGold
});
/* 7 Sand + 1 Coal|Charcoal = 7 Glass */
ModLoader.addShapelessRecipe(new ItemStack(Block.glass, 7), new Object[] {
philStone, coal, Block.sand, Block.sand, Block.sand, Block.sand, Block.sand, Block.sand, Block.sand
});
ModLoader.addShapelessRecipe(new ItemStack(Block.glass, 7), new Object[] {
philStone, charcoal, Block.sand, Block.sand, Block.sand, Block.sand, Block.sand, Block.sand, Block.sand
});
}
}

View file

@ -1,6 +1,8 @@
package net.minecraft.src.ee3.item;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.ee3.lib.Reference;
import net.minecraft.src.forge.ITextureProvider;
@ -17,4 +19,122 @@ public class ItemMod extends Item implements ITextureProvider {
return Reference.SPRITE_SHEET_LOCATION + Reference.ITEM_SPRITE_SHEET;
}
public String getString(ItemStack ist, String s) {
if (ist.stackTagCompound == null)
ist.setTagCompound(new NBTTagCompound());
if (!ist.stackTagCompound.hasKey(s))
setString(ist, s, "");
return ist.stackTagCompound.getString(s);
}
public void setString(ItemStack ist, String s, String s1) {
if (ist.stackTagCompound == null)
ist.setTagCompound(new NBTTagCompound());
ist.stackTagCompound.setString(s, s1);
}
public boolean getBoolean(ItemStack ist, String s) {
if (ist.stackTagCompound == null)
ist.setTagCompound(new NBTTagCompound());
if (!ist.stackTagCompound.hasKey(s))
setBoolean(ist, s, false);
return ist.stackTagCompound.getBoolean(s);
}
public void setBoolean(ItemStack ist, String s, boolean b) {
if (ist.stackTagCompound == null)
ist.setTagCompound(new NBTTagCompound());
ist.stackTagCompound.setBoolean(s, b);
}
public short getShort(ItemStack ist, String s) {
if (ist.stackTagCompound == null)
ist.setTagCompound(new NBTTagCompound());
if (!ist.stackTagCompound.hasKey(s))
setShort(ist, s, 0);
return (short)(ist.stackTagCompound.getShort(s));
}
public void setShort(ItemStack ist, String s, int i) {
if (ist.stackTagCompound == null)
ist.setTagCompound(new NBTTagCompound());
ist.stackTagCompound.setShort(s, (short)i);
}
public int getInteger(ItemStack ist, String s) {
if (ist.stackTagCompound == null)
ist.setTagCompound(new NBTTagCompound());
if (!ist.stackTagCompound.hasKey(s))
setInteger(ist, s, 0);
return ist.stackTagCompound.getInteger(s);
}
public void setInteger(ItemStack ist, String s, int i) {
if (ist.stackTagCompound == null)
ist.setTagCompound(new NBTTagCompound());
ist.stackTagCompound.setInteger(s, i);
}
public byte getByte(ItemStack ist, String s) {
if (ist.stackTagCompound == null)
ist.setTagCompound(new NBTTagCompound());
if (!ist.stackTagCompound.hasKey(s))
setByte(ist, s, (byte)0);
return ist.stackTagCompound.getByte(s);
}
public void setByte(ItemStack ist, String s, byte i) {
if (ist.stackTagCompound == null)
ist.setTagCompound(new NBTTagCompound());
ist.stackTagCompound.setByte(s, i);
}
public long getLong(ItemStack ist, String s) {
if (ist.stackTagCompound == null)
ist.setTagCompound(new NBTTagCompound());
if (!ist.stackTagCompound.hasKey(s))
setLong(ist, s, 0);
return ist.stackTagCompound.getLong(s);
}
public void setLong(ItemStack ist, String s, long i) {
if (ist.stackTagCompound == null)
ist.setTagCompound(new NBTTagCompound());
ist.stackTagCompound.setLong(s, i);
}
public float getFloat(ItemStack ist, String s) {
if (ist.stackTagCompound == null)
ist.setTagCompound(new NBTTagCompound());
if (!ist.stackTagCompound.hasKey(s))
setFloat(ist, s, 0F);
return ist.stackTagCompound.getFloat(s);
}
public void setFloat(ItemStack ist, String s, float f) {
if (ist.stackTagCompound == null)
ist.setTagCompound(new NBTTagCompound());
ist.stackTagCompound.setFloat(s, f);
}
}

View file

@ -0,0 +1,21 @@
package net.minecraft.src.ee3.item;
import net.minecraft.src.Item;
import net.minecraft.src.ModLoader;
public class ModItems {
private static boolean initialized;
public static Item philStone;
public static void init() {
if (initialized)
initialized = true;
philStone = new ItemPhilosopherStone(27270).setIconCoord(0, 0).setItemName("philStone");
philStone.setContainerItem(philStone);
ModLoader.addName(philStone, "Philosopher's Stone");
}
}

View file

@ -2,10 +2,12 @@ package net.minecraft.src;
import net.minecraft.src.ModLoader;
import net.minecraft.src.ee3.core.ConfigurationManager;
import net.minecraft.src.ee3.core.RecipesPhilStone;
import net.minecraft.src.ee3.core.ServerClientProxy;
import net.minecraft.src.ee3.core.Version;
import net.minecraft.src.ee3.core.interfaces.IProxy;
import net.minecraft.src.ee3.gui.GuiHandler;
import net.minecraft.src.ee3.item.ModItems;
import net.minecraft.src.ee3.lib.Reference;
import net.minecraft.src.ee3.lib.Sounds;
import net.minecraft.src.ee3.network.PacketHandler;
@ -43,6 +45,9 @@ public class mod_EE3 extends NetworkMod {
// Initialise the configuration settings from file
config.init();
ModItems.init();
RecipesPhilStone.initRecipes();
}
@Override