Last active
August 29, 2015 14:01
-
-
Save mattmess1221/1156a396207c6b1feeb7 to your computer and use it in GitHub Desktop.
Method to consume item with damage in Minecraft.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void eatItemWithDamage(InventoryPlayer inventory, Item item, int damage){ | |
for(int i = 0;i<inventory.getSizeInventory(); i++){ | |
ItemStack itemstack = inventory.mainInventory[i]; | |
if(itemstack == null) | |
continue; | |
if(itemstack.getItem() == item && itemstack.getItemDamage() == damage){ | |
itemstack.stackSize--; | |
if(itemstack.stackSize <=0) | |
inventory.setInventorySlotContents(i, null); | |
return; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment