Advertisement
Guest User

IRecipe class

a guest
Jul 5th, 2014
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. package com.fluffy.amnesia.handler;
  2.  
  3. import net.minecraft.inventory.InventoryCrafting;
  4. import net.minecraft.item.ItemStack;
  5. import net.minecraft.item.crafting.IRecipe;
  6. import net.minecraft.world.World;
  7.  
  8. import com.fluffy.amnesia.Amnesia;
  9. import com.fluffy.amnesia.items.ItemLanternoff;
  10.  
  11. public class LanternRefuelRecipe implements IRecipe
  12. {
  13.  
  14. public boolean matches(InventoryCrafting inv, World w)
  15. {
  16. int numoil = 0;
  17. int numlanterns = 0;
  18. int lanternslot = -1;
  19. boolean containsforeignobject = false;
  20.  
  21. for (int item = 0; item < inv.getSizeInventory(); ++item)
  22. {
  23. ItemStack oildif = inv.getStackInSlot(item);
  24.  
  25. if (oildif != null)
  26. {
  27. if (oildif.getItem() != Amnesia.lanternoffItem)
  28. {
  29. if (oildif.getItem() != Amnesia.lanternoil)
  30. {
  31. containsforeignobject = true;
  32. }
  33. else
  34. {
  35. ++numoil;
  36. }
  37. }
  38. else
  39. {
  40. ++numlanterns;
  41. lanternslot = item;
  42. }
  43. }
  44. }
  45.  
  46. if (numlanterns == 1 && lanternslot >= 0 && numoil > 0 && !containsforeignobject)
  47. {
  48. ItemStack var9 = inv.getStackInSlot(lanternslot);
  49. int var10 = Amnesia.lanternFuelCapacity * 60 - ItemLanternoff.getOilLevel(var9);
  50.  
  51. if (numoil * Amnesia.fuelMinutesPerBottle * 60 <= var10)
  52. {
  53. return true;
  54. }
  55.  
  56. if ((numoil - 1) * Amnesia.fuelMinutesPerBottle * 60 < var10)
  57. {
  58. return true;
  59. }
  60. }
  61.  
  62. return false;
  63. }
  64.  
  65. public ItemStack getCraftingResult(InventoryCrafting inv)
  66. {
  67. int numoil = 0;
  68. int lampslot = -1;
  69. boolean type = true;
  70.  
  71. for (int item = 0; item < inv.getSizeInventory(); ++item)
  72. {
  73. ItemStack newLevel = inv.getStackInSlot(item);
  74.  
  75. if (newLevel != null)
  76. {
  77. if (newLevel.getItem() == Amnesia.lanternoffItem)
  78. {
  79. lampslot = item;
  80. type = false;
  81. }
  82. else if (newLevel.getItem() == Amnesia.lanternoil)
  83. {
  84. ++numoil;
  85. }
  86. }
  87. }
  88.  
  89. if (lampslot >= 0)
  90. {
  91. ItemStack var8 = inv.getStackInSlot(lampslot);
  92. int var9 = ItemLanternoff.getOilLevel(var8) + Amnesia.fuelMinutesPerBottle * 60 * numoil;
  93.  
  94. if (var9 > Amnesia.lanternFuelCapacity * 60)
  95. {
  96. var9 = Amnesia.lanternFuelCapacity * 60;
  97. }
  98.  
  99. ItemStack out = null;
  100.  
  101. if (!type)
  102. {
  103. out = new ItemStack(Amnesia.lanternoffItem, 1);
  104. }
  105.  
  106. ItemLanternoff.setOilLevel(out, var9);
  107. return out;
  108. }
  109. else
  110. {
  111. return null;
  112. }
  113. }
  114.  
  115. public int getRecipeSize()
  116. {
  117. return 2;
  118. }
  119.  
  120. public ItemStack getRecipeOutput()
  121. {
  122. return new ItemStack(Amnesia.lanternoffItem, 1);
  123. }
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement