    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.35F);
    031            this.addSmelting(Item.beefRaw.shiftedIndex, new ItemStack(Item.beefCooked), 0.35F);
    032            this.addSmelting(Item.chickenRaw.shiftedIndex, new ItemStack(Item.chickenCooked), 0.35F);
    033            this.addSmelting(Item.fishRaw.shiftedIndex, new ItemStack(Item.fishCooked), 0.35F);
    034            this.addSmelting(Block.cobblestone.blockID, new ItemStack(Block.stone), 0.1F);
    035            this.addSmelting(Item.clay.shiftedIndex, new ItemStack(Item.brick), 0.3F);
    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.15F);
    038            this.addSmelting(Block.oreEmerald.blockID, new ItemStack(Item.emerald), 1.0F);
    039            this.addSmelting(Item.field_82794_bL.shiftedIndex, new ItemStack(Item.field_82795_bM), 0.35F);
    040            this.addSmelting(Block.oreCoal.blockID, new ItemStack(Item.coal), 0.1F);
    041            this.addSmelting(Block.oreRedstone.blockID, new ItemStack(Item.redstone), 0.7F);
    042            this.addSmelting(Block.oreLapis.blockID, new ItemStack(Item.dyePowder, 1, 4), 0.2F);
    043        }
    044
    045        /**
    046         * Adds a smelting recipe.
    047         */
    048        public void addSmelting(int par1, ItemStack par2ItemStack, float par3)
    049        {
    050            this.smeltingList.put(Integer.valueOf(par1), par2ItemStack);
    051            this.experienceList.put(Integer.valueOf(par2ItemStack.itemID), Float.valueOf(par3));
    052        }
    053
    054        /**
    055         * Returns the smelting result of an item.
    056         * Deprecated in favor of a metadata sensitive version
    057         */
    058        @Deprecated
    059        public ItemStack getSmeltingResult(int par1)
    060        {
    061            return (ItemStack)this.smeltingList.get(Integer.valueOf(par1));
    062        }
    063
    064        public Map getSmeltingList()
    065        {
    066            return this.smeltingList;
    067        }
    068
    069        public float getExperience(int par1)
    070        {
    071            return this.experienceList.containsKey(Integer.valueOf(par1)) ? ((Float)this.experienceList.get(Integer.valueOf(par1))).floatValue() : 0.0F;
    072        }
    073
    074        /**
    075         * Add a metadata-sensitive furnace recipe
    076         * @param itemID The Item ID
    077         * @param metadata The Item Metadata
    078         * @param itemstack The ItemStack for the result
    079         */
    080        public void addSmelting(int itemID, int metadata, ItemStack itemstack)
    081        {
    082            metaSmeltingList.put(Arrays.asList(itemID, metadata), itemstack);
    083        }
    084
    085        /**
    086         * Used to get the resulting ItemStack form a source ItemStack
    087         * @param item The Source ItemStack
    088         * @return The result ItemStack
    089         */
    090        public ItemStack getSmeltingResult(ItemStack item)
    091        {
    092            if (item == null)
    093            {
    094                return null;
    095            }
    096            ItemStack ret = (ItemStack)metaSmeltingList.get(Arrays.asList(item.itemID, item.getItemDamage()));
    097            if (ret != null)
    098            {
    099                return ret;
    100            }
    101            return (ItemStack)smeltingList.get(Integer.valueOf(item.itemID));
    102        }
    103    }