cjcj55

Fusion Furnace Recipes Class

Mar 3rd, 2019
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. package com.cjcj55.cmod.objects.blocks.fusionfurnace;
  2.  
  3. import java.util.Map;
  4. import java.util.Map.Entry;
  5.  
  6. import com.cjcj55.cmod.init.BlockInit;
  7. import com.google.common.collect.HashBasedTable;
  8. import com.google.common.collect.Maps;
  9. import com.google.common.collect.Table;
  10.  
  11. import net.minecraft.init.Blocks;
  12. import net.minecraft.init.Items;
  13. import net.minecraft.item.ItemStack;
  14.  
  15. public class FusionFurnaceRecipes
  16. {
  17. private static final FusionFurnaceRecipes INSTANCE = new FusionFurnaceRecipes();
  18. private final Table<ItemStack, ItemStack, ItemStack> smeltingList = HashBasedTable.<ItemStack, ItemStack, ItemStack>create();
  19. private final Map<ItemStack, Float> experienceList = Maps.<ItemStack, Float>newHashMap();
  20.  
  21. public static FusionFurnaceRecipes getInstance()
  22. {
  23. return INSTANCE;
  24. }
  25.  
  26. private FusionFurnaceRecipes()
  27. {
  28. addFusionFurnaceRecipe(new ItemStack(Items.DIAMOND), new ItemStack(BlockInit.BAKED_OBSIDIAN_BLOCK), new ItemStack(BlockInit.BLUE_EMERALD_BLOCK), 5.0F);
  29. }
  30.  
  31.  
  32. public void addFusionFurnaceRecipe(ItemStack input1, ItemStack input2, ItemStack result, float experience)
  33. {
  34. if(getFusionFurnaceResult(input1, input2) != ItemStack.EMPTY) return;
  35. this.smeltingList.put(input1, input2, result);
  36. this.experienceList.put(result, Float.valueOf(experience));
  37. }
  38.  
  39. public ItemStack getFusionFurnaceResult(ItemStack input1, ItemStack input2)
  40. {
  41. for(Entry<ItemStack, Map<ItemStack, ItemStack>> entry : this.smeltingList.columnMap().entrySet())
  42. {
  43. if(this.compareItemStacks(input1, (ItemStack)entry.getKey()))
  44. {
  45. for(Entry<ItemStack, ItemStack> ent : entry.getValue().entrySet())
  46. {
  47. if(this.compareItemStacks(input2, (ItemStack)ent.getKey()))
  48. {
  49. return (ItemStack)ent.getValue();
  50. }
  51. }
  52. }
  53. }
  54. return ItemStack.EMPTY;
  55. }
  56.  
  57. private boolean compareItemStacks(ItemStack stack1, ItemStack stack2)
  58. {
  59. return stack2.getItem() == stack1.getItem() && (stack2.getMetadata() == 32767 || stack2.getMetadata() == stack1.getMetadata());
  60. }
  61.  
  62. public Table<ItemStack, ItemStack, ItemStack> getDualSmeltingList()
  63. {
  64. return this.smeltingList;
  65. }
  66.  
  67. public float getFusionFurnaceExperience(ItemStack stack)
  68. {
  69. for (Entry<ItemStack, Float> entry : this.experienceList.entrySet())
  70. {
  71. if(this.compareItemStacks(stack, (ItemStack)entry.getKey()))
  72. {
  73. return ((Float)entry.getValue()).floatValue();
  74. }
  75. }
  76. return 0.0F;
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment