Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. public static void removeItem(EntityPlayer player, ItemStack is, int amount) {
  2. if(is == null)
  3. return;
  4.  
  5. IInventory inv = player.inventory;
  6.  
  7. for(int i = 0; i < inv.getSizeInventory(); i++) {
  8. if(inv.getStackInSlot(i) != null) {
  9. ItemStack stack = (ItemStack) inv.getStackInSlot(i);
  10. if(is.stackSize == 0)
  11. break;
  12.  
  13. if(stack.stackSize == 0)
  14. inv.removeStackFromSlot(i);
  15.  
  16. int mod = Math.min(is.stackSize, stack.stackSize);
  17. is.stackSize -= mod;
  18. stack.stackSize -= mod;
  19. }
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement