Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package eriksfurnacetexturefix;
- import java.util.Arrays;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import cpw.mods.fml.common.registry.GameRegistry;
- import net.minecraft.block.Block;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- public class TextureFurnaceRecipes
- {
- private static final TextureFurnaceRecipes smeltingBase = new TextureFurnaceRecipes();
- /** The list of smelting results. */
- private Map smeltingList = new HashMap();
- private Map experienceList = new HashMap();
- private HashMap<List<Integer>, ItemStack> metaSmeltingList = new HashMap<List<Integer>, ItemStack>();
- private HashMap<List<Integer>, Float> metaExperience = new HashMap<List<Integer>, Float>();
- private Map smeltingList2 = new HashMap();
- private Map experienceList2 = new HashMap();
- private HashMap<List<Integer>, ItemStack> metaSmeltingList2 = new HashMap<List<Integer>, ItemStack>();
- private HashMap<List<Integer>, Float> metaExperience2 = new HashMap<List<Integer>, Float>();
- /**
- * Used to call methods addSmelting and getSmeltingResult.
- */
- public static final TextureFurnaceRecipes smelting()
- {
- return smeltingBase;
- }
- private TextureFurnaceRecipes()
- {
- //Recipe 1
- this.addSmelting(Block.oreIron.blockID, new ItemStack(Item.ingotIron, 2), 0.3F);
- this.addDoubleSmelting(Block.oreIron.blockID, new ItemStack(Item.ingotIron, 2), 0.3F);
- //Recipe 2
- this.addSmelting(Block.oreGold.blockID, new ItemStack(Item.ingotGold, 2), 0.3F);
- this.addDoubleSmelting(Block.oreGold.blockID, new ItemStack(Item.ingotGold, 2), 0.3F);
- }
- /**
- * Adds a smelting recipe.
- */
- public void addSmelting(int par1, ItemStack par2ItemStack, float par3)
- {
- this.smeltingList.put(Integer.valueOf(par1), par2ItemStack);
- this.experienceList.put(Integer.valueOf(par2ItemStack.itemID), Float.valueOf(par3));
- }
- public void addDoubleSmelting(int par1, ItemStack par2ItemStack, float par3)
- {
- this.smeltingList2.put(Integer.valueOf(par1), par2ItemStack);
- this.experienceList2.put(Integer.valueOf(par2ItemStack.itemID), Float.valueOf(par3));
- }
- /**
- * Returns the smelting result of an item.
- * Deprecated in favor of a metadata sensitive version
- */
- @Deprecated
- public ItemStack getSmeltingResult(int par1)
- {
- return (ItemStack)this.smeltingList.get(Integer.valueOf(par1));
- }
- public Map getSmeltingList()
- {
- return this.smeltingList;
- }
- @Deprecated //In favor of ItemStack sensitive version
- public float getExperience(int par1)
- {
- return this.experienceList.containsKey(Integer.valueOf(par1)) ? ((Float)this.experienceList.get(Integer.valueOf(par1))).floatValue() : 0.0F;
- }
- /**
- * A metadata sensitive version of adding a furnace recipe.
- */
- public void addSmelting(int itemID, int metadata, ItemStack itemstack, float experience)
- {
- metaSmeltingList.put(Arrays.asList(itemID, metadata), itemstack);
- metaExperience.put(Arrays.asList(itemID, metadata), experience);
- }
- public void addDoubleSmelting(int itemID, int metadata, ItemStack itemstack, float experience)
- {
- metaSmeltingList2.put(Arrays.asList(itemID, metadata), itemstack);
- metaExperience2.put(Arrays.asList(itemID, metadata), experience);
- }
- /**
- * Used to get the resulting ItemStack form a source ItemStack
- * @param item The Source ItemStack
- * @return The result ItemStack
- */
- public ItemStack getSmeltingResult(ItemStack item)
- {
- if (item == null)
- {
- return null;
- }
- ItemStack ret = (ItemStack)metaSmeltingList.get(Arrays.asList(item.itemID, item.getItemDamage()));
- if (ret != null)
- {
- return ret;
- }
- return (ItemStack)smeltingList.get(Integer.valueOf(item.itemID));
- }
- public ItemStack getSmeltingResult2(ItemStack item)
- {
- if (item == null)
- {
- return null;
- }
- ItemStack ret = (ItemStack)metaSmeltingList2.get(Arrays.asList(item.itemID, item.getItemDamage()));
- if (ret != null)
- {
- return ret;
- }
- return (ItemStack)smeltingList2.get(Integer.valueOf(item.itemID));
- }
- /**
- * Grabs the amount of base experience for this item to give when pulled from the furnace slot.
- */
- public float getExperience(ItemStack item)
- {
- if (item == null || item.getItem() == null)
- {
- return 0;
- }
- float ret = item.getItem().getSmeltingExperience(item);
- if (ret < 0 && metaExperience.containsKey(Arrays.asList(item.itemID, item.getItemDamage())))
- {
- ret = metaExperience.get(Arrays.asList(item.itemID, item.getItemDamage()));
- }
- if (ret < 0 && experienceList.containsKey(item.itemID))
- {
- ret = ((Float)experienceList.get(item.itemID)).floatValue();
- }
- return (ret < 0 ? 0 : ret);
- }
- public Map<List<Integer>, ItemStack> getMetaSmeltingList()
- {
- return metaSmeltingList;
- }
- public float getExperience2(ItemStack item)
- {
- if (item == null || item.getItem() == null)
- {
- return 0;
- }
- float ret = item.getItem().getSmeltingExperience(item);
- if (ret < 0 && metaExperience2.containsKey(Arrays.asList(item.itemID, item.getItemDamage())))
- {
- ret = metaExperience2.get(Arrays.asList(item.itemID, item.getItemDamage()));
- }
- if (ret < 0 && experienceList2.containsKey(item.itemID))
- {
- ret = ((Float)experienceList2.get(item.itemID)).floatValue();
- }
- return (ret < 0 ? 0 : ret);
- }
- public Map<List<Integer>, ItemStack> getMetaSmeltingList2()
- {
- return metaSmeltingList2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment