    001    package net.minecraft.src;
    002
    003    import java.util.Arrays;
    004    import java.util.HashMap;
    005    import java.util.Map;
    006
    007    public class FurnaceRecipes
    008    {
    009        private static final FurnaceRecipes smeltingBase = new FurnaceRecipes();
    010
    011        /** The list of smelting results. */
    012        private Map smeltingList = new HashMap();
    013        private Map experienceList = new HashMap();
    014        private Map metaSmeltingList = new HashMap();
    015
    016        /**
    017         * Used to call methods addSmelting and getSmeltingResult.
    018         */
    019        public static final FurnaceRecipes smelting()
    020        {
    021            return smeltingBase;
    022        }
    023
    024        private FurnaceRecipes()
    025        {
    026            this.addSmelting(Block.oreIron.blockID, new ItemStack(Item.ingotIron), 0.7F);
    027            this.addSmelting(Block.oreGold.blockID, new ItemStack(Item.ingotGold), 1.0F);
    028            this.addSmelting(Block.oreDiamond.blockID, new ItemStack(Item.diamond), 1.0F);
    029            this.addSmelting(Block.sand.blockID, new ItemStack(Block.glass), 0.1F);
    030            this.addSmelting(Item.porkRaw.shiftedIndex, new ItemStack(Item.porkCooked), 0.3F);
    031            this.addSmelting(Item.beefRaw.shiftedIndex, new ItemStack(Item.beefCooked), 0.3F);
    032            this.addSmelting(Item.chickenRaw.shiftedIndex, new ItemStack(Item.chickenCooked), 0.3F);
    033            this.addSmelting(Item.fishRaw.shiftedIndex, new ItemStack(Item.fishCooked), 0.3F);
    034            this.addSmelting(Block.cobblestone.blockID, new ItemStack(Block.stone), 0.1F);
    035            this.addSmelting(Item.clay.shiftedIndex, new ItemStack(Item.brick), 0.2F);
    036            this.addSmelting(Block.cactus.blockID, new ItemStack(Item.dyePowder, 1, 2), 0.2F);
    037            this.addSmelting(Block.wood.blockID, new ItemStack(Item.coal, 1, 1), 0.1F);
    038            this.addSmelting(Block.oreEmerald.blockID, new ItemStack(Item.emerald), 1.0F);
    039            this.addSmelting(Block.oreCoal.blockID, new ItemStack(Item.coal), 0.1F);
    040            this.addSmelting(Block.oreRedstone.blockID, new ItemStack(Item.redstone), 0.7F);
    041            this.addSmelting(Block.oreLapis.blockID, new ItemStack(Item.dyePowder, 1, 4), 0.2F);
    042        }
    043
    044        /**
    045         * Adds a smelting recipe.
    046         */
    047        public void addSmelting(int par1, ItemStack par2ItemStack, float par3)
    048        {
    049            this.smeltingList.put(Integer.valueOf(par1), par2ItemStack);
    050            this.experienceList.put(Integer.valueOf(par2ItemStack.itemID), Float.valueOf(par3));
    051        }
    052
    053        /**
    054         * Returns the smelting result of an item.
    055         * Deprecated in favor of a metadata sensitive version
    056         */
    057        @Deprecated
    058        public ItemStack getSmeltingResult(int par1)
    059        {
    060            return (ItemStack)this.smeltingList.get(Integer.valueOf(par1));
    061        }
    062
    063        public Map getSmeltingList()
    064        {
    065            return this.smeltingList;
    066        }
    067
    068        public float getExperience(int par1)
    069        {
    070            return this.experienceList.containsKey(Integer.valueOf(par1)) ? ((Float)this.experienceList.get(Integer.valueOf(par1))).floatValue() : 0.0F;
    071        }
    072
    073        /**
    074         * Add a metadata-sensitive furnace recipe
    075         * @param itemID The Item ID
    076         * @param metadata The Item Metadata
    077         * @param itemstack The ItemStack for the result
    078         */
    079        public void addSmelting(int itemID, int metadata, ItemStack itemstack)
    080        {
    081            metaSmeltingList.put(Arrays.asList(itemID, metadata), itemstack);
    082        }
    083
    084        /**
    085         * Used to get the resulting ItemStack form a source ItemStack
    086         * @param item The Source ItemStack
    087         * @return The result ItemStack
    088         */
    089        public ItemStack getSmeltingResult(ItemStack item)
    090        {
    091            if (item == null)
    092            {
    093                return null;
    094            }
    095            ItemStack ret = (ItemStack)metaSmeltingList.get(Arrays.asList(item.itemID, item.getItemDamage()));
    096            if (ret != null)
    097            {
    098                return ret;
    099            }
    100            return (ItemStack)smeltingList.get(Integer.valueOf(item.itemID));
    101        }
    102    }