Advertisement
TechMage66

HandlerSouls

Jan 30th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. package com.techmage.magetech;
  2.  
  3. import net.minecraft.entity.player.EntityPlayer;
  4. import net.minecraft.item.ItemStack;
  5.  
  6. public class HandlerSouls
  7. {
  8.     public static boolean hasEnoughSouls(EntityPlayer player, int amount)
  9.     {
  10.         if (findNextUrnWithStoredSouls(player, amount) != null)
  11.             return true;
  12.  
  13.         return false;
  14.     }
  15.    
  16.     public static void useSouls(EntityPlayer player, int amount)
  17.     {
  18.         findNextUrnWithStoredSouls(player, amount).useSouls(amount);
  19.     }
  20.  
  21.     private static ItemUrn findNextUrnWithStoredSouls(EntityPlayer player, int amount)
  22.     {
  23.         for (int index = 0; index < player.inventory.getSizeInventory(); index ++)
  24.         {
  25.             ItemStack stack = player.inventory.getStackInSlot(index);
  26.  
  27.             if (stack != null)
  28.             {
  29.                 if(stack.getItem() == ModItems.urn)
  30.                 {
  31.                     if (((ItemUrn) stack.getItem()).getStoredSouls >= amount)
  32.                         return (ItemUrn) stack.getItem();
  33.                 }
  34.             }
  35.         }
  36.  
  37.         return null;
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement