Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package izzyaxel.InfusedMetals;
- import net.minecraft.inventory.InventoryCrafting;
- public class CraftingHelper
- {
- public static int repairHelper(InventoryCrafting crafting)
- {
- int firstItem = -1;
- int secondItem = -1;
- int firstMaxDamage = 0;
- int secondMaxDamage = 0;
- int numItems = 0;
- int combinedDurability = 0;
- for (int i = 1; i < crafting.getSizeInventory(); i++)
- {
- if (crafting.getStackInSlot(i) != null)
- {
- numItems = numItems + 1;
- if (numItems == 2)
- {
- i = 10;
- }
- if (firstItem == secondItem)
- {
- firstItem = crafting.getStackInSlot(i).getItemDamage();
- firstMaxDamage = crafting.getStackInSlot(i).getMaxDamage();
- }
- else
- secondItem = crafting.getStackInSlot(i).getItemDamage();
- secondMaxDamage = crafting.getStackInSlot(i).getMaxDamage();
- }
- }
- combinedDurability = (firstMaxDamage - firstItem) + (secondMaxDamage - secondItem);
- combinedDurability = firstMaxDamage - combinedDurability - 1;
- if (combinedDurability < 0)
- {
- combinedDurability = 0;
- }
- return combinedDurability;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement