SerriniaCorp

Dual Smelting problem

Aug 3rd, 2013
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package eriksfurnacetexturefix;
  2.  
  3. import java.util.Arrays;
  4. import java.util.HashMap;
  5. import java.util.List;
  6. import java.util.Map;
  7.  
  8. import cpw.mods.fml.common.registry.GameRegistry;
  9. import net.minecraft.block.Block;
  10. import net.minecraft.item.Item;
  11. import net.minecraft.item.ItemStack;
  12.  
  13. public class TextureFurnaceRecipes
  14. {
  15.     private static final TextureFurnaceRecipes smeltingBase = new TextureFurnaceRecipes();
  16.  
  17.     /** The list of smelting results. */
  18.     private Map smeltingList = new HashMap();
  19.     private Map experienceList = new HashMap();
  20.     private HashMap<List<Integer>, ItemStack> metaSmeltingList = new HashMap<List<Integer>, ItemStack>();
  21.     private HashMap<List<Integer>, Float> metaExperience = new HashMap<List<Integer>, Float>();
  22.     private Map smeltingList2 = new HashMap();
  23.     private Map experienceList2 = new HashMap();
  24.     private HashMap<List<Integer>, ItemStack> metaSmeltingList2 = new HashMap<List<Integer>, ItemStack>();
  25.     private HashMap<List<Integer>, Float> metaExperience2 = new HashMap<List<Integer>, Float>();
  26.  
  27.     /**
  28.      * Used to call methods addSmelting and getSmeltingResult.
  29.      */
  30.     public static final TextureFurnaceRecipes smelting()
  31.     {
  32.         return smeltingBase;
  33.     }
  34.  
  35.     private TextureFurnaceRecipes()
  36.     {
  37. //Recipe 1
  38.         this.addSmelting(Block.oreIron.blockID, new ItemStack(Item.ingotIron, 2), 0.3F);
  39.         this.addDoubleSmelting(Block.oreIron.blockID, new ItemStack(Item.ingotIron, 2), 0.3F);
  40. //Recipe 2
  41.         this.addSmelting(Block.oreGold.blockID, new ItemStack(Item.ingotGold, 2), 0.3F);
  42.         this.addDoubleSmelting(Block.oreGold.blockID, new ItemStack(Item.ingotGold, 2), 0.3F);
  43.        
  44.     }
  45.  
  46.     /**
  47.      * Adds a smelting recipe.
  48.      */
  49.     public void addSmelting(int par1, ItemStack par2ItemStack, float par3)
  50.     {
  51.         this.smeltingList.put(Integer.valueOf(par1), par2ItemStack);
  52.         this.experienceList.put(Integer.valueOf(par2ItemStack.itemID), Float.valueOf(par3));
  53.     }
  54.     public void addDoubleSmelting(int par1, ItemStack par2ItemStack, float par3)
  55.     {
  56.         this.smeltingList2.put(Integer.valueOf(par1), par2ItemStack);
  57.         this.experienceList2.put(Integer.valueOf(par2ItemStack.itemID), Float.valueOf(par3));
  58.     }
  59.  
  60.     /**
  61.      * Returns the smelting result of an item.
  62.      * Deprecated in favor of a metadata sensitive version
  63.      */
  64.     @Deprecated
  65.     public ItemStack getSmeltingResult(int par1)
  66.     {
  67.         return (ItemStack)this.smeltingList.get(Integer.valueOf(par1));
  68.     }
  69.  
  70.     public Map getSmeltingList()
  71.     {
  72.         return this.smeltingList;
  73.     }
  74.  
  75.     @Deprecated //In favor of ItemStack sensitive version
  76.     public float getExperience(int par1)
  77.     {
  78.         return this.experienceList.containsKey(Integer.valueOf(par1)) ? ((Float)this.experienceList.get(Integer.valueOf(par1))).floatValue() : 0.0F;
  79.     }
  80.  
  81.     /**
  82.      * A metadata sensitive version of adding a furnace recipe.
  83.      */
  84.     public void addSmelting(int itemID, int metadata, ItemStack itemstack, float experience)
  85.     {
  86.         metaSmeltingList.put(Arrays.asList(itemID, metadata), itemstack);
  87.         metaExperience.put(Arrays.asList(itemID, metadata), experience);
  88.     }
  89.     public void addDoubleSmelting(int itemID, int metadata, ItemStack itemstack, float experience)
  90.     {
  91.         metaSmeltingList2.put(Arrays.asList(itemID, metadata), itemstack);
  92.         metaExperience2.put(Arrays.asList(itemID, metadata), experience);
  93.     }
  94.  
  95.     /**
  96.      * Used to get the resulting ItemStack form a source ItemStack
  97.      * @param item The Source ItemStack
  98.      * @return The result ItemStack
  99.      */
  100.     public ItemStack getSmeltingResult(ItemStack item)
  101.     {
  102.         if (item == null)
  103.         {
  104.             return null;
  105.         }
  106.         ItemStack ret = (ItemStack)metaSmeltingList.get(Arrays.asList(item.itemID, item.getItemDamage()));
  107.         if (ret != null)
  108.         {
  109.             return ret;
  110.         }
  111.         return (ItemStack)smeltingList.get(Integer.valueOf(item.itemID));
  112.     }
  113.     public ItemStack getSmeltingResult2(ItemStack item)
  114.     {
  115.         if (item == null)
  116.         {
  117.             return null;
  118.         }
  119.         ItemStack ret = (ItemStack)metaSmeltingList2.get(Arrays.asList(item.itemID, item.getItemDamage()));
  120.         if (ret != null)
  121.         {
  122.             return ret;
  123.         }
  124.         return (ItemStack)smeltingList2.get(Integer.valueOf(item.itemID));
  125.     }
  126.  
  127.     /**
  128.      * Grabs the amount of base experience for this item to give when pulled from the furnace slot.
  129.      */
  130.     public float getExperience(ItemStack item)
  131.     {
  132.         if (item == null || item.getItem() == null)
  133.         {
  134.             return 0;
  135.         }
  136.         float ret = item.getItem().getSmeltingExperience(item);
  137.         if (ret < 0 && metaExperience.containsKey(Arrays.asList(item.itemID, item.getItemDamage())))
  138.         {
  139.             ret = metaExperience.get(Arrays.asList(item.itemID, item.getItemDamage()));
  140.         }
  141.         if (ret < 0 && experienceList.containsKey(item.itemID))
  142.         {
  143.             ret = ((Float)experienceList.get(item.itemID)).floatValue();
  144.         }
  145.         return (ret < 0 ? 0 : ret);
  146.     }
  147.  
  148.     public Map<List<Integer>, ItemStack> getMetaSmeltingList()
  149.     {
  150.         return metaSmeltingList;
  151.     }
  152.     public float getExperience2(ItemStack item)
  153.     {
  154.         if (item == null || item.getItem() == null)
  155.         {
  156.             return 0;
  157.         }
  158.         float ret = item.getItem().getSmeltingExperience(item);
  159.         if (ret < 0 && metaExperience2.containsKey(Arrays.asList(item.itemID, item.getItemDamage())))
  160.         {
  161.             ret = metaExperience2.get(Arrays.asList(item.itemID, item.getItemDamage()));
  162.         }
  163.         if (ret < 0 && experienceList2.containsKey(item.itemID))
  164.         {
  165.             ret = ((Float)experienceList2.get(item.itemID)).floatValue();
  166.         }
  167.         return (ret < 0 ? 0 : ret);
  168.     }
  169.  
  170.     public Map<List<Integer>, ItemStack> getMetaSmeltingList2()
  171.     {
  172.         return metaSmeltingList2;
  173.     }
  174. }
Advertisement
Add Comment
Please, Sign In to add comment