Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.techmage.magetech.handler;
- import com.techmage.magetech.init.MageTechItems;
- import com.techmage.magetech.item.ItemShardSouls;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.ItemStack;
- public class SoulsHandler
- {
- public static ItemStack findShardWithSouls(EntityPlayer player, int amount)
- {
- for (int index = 0; index < player.inventory.getSizeInventory(); index ++)
- {
- ItemStack stack = player.inventory.getStackInSlot(index);
- if (stack != null && stack.getItem() == MageTechItems.shardSouls)
- {
- if (((ItemShardSouls) stack.getItem()).getStoredSouls(stack) >= amount)
- return stack;
- }
- }
- return null;
- }
- public static boolean hasEnoughSouls(EntityPlayer player, int amount)
- {
- return findShardWithSouls(player, amount) != null;
- }
- public static void useSouls(EntityPlayer player, int amount)
- {
- if (hasEnoughSouls(player, amount))
- ((ItemShardSouls) findShardWithSouls(player, amount).getItem()).useSouls(findShardWithSouls(player, amount), amount);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment