Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Item_Eater extends Item {
- ItemStack SelfStack = new ItemStack(this);
- public void onUpdate(ItemStack stack, World world, Entity entity, int metadata, boolean bool)
- {
- if (SelfStack.getTagCompound() == null)
- {
- SelfStack.setTagCompound(new NBTTagCompound());
- }
- SelfStack.getTagCompound().setInteger("ConsumedAmount", 0);
- }
- @Override
- public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
- {
- if(playerIn.inventory.hasItemStack(SelfStack))
- {
- int invSize = playerIn.inventory.getSizeInventory();
- for(int i=0; i<invSize; i++)
- {
- int ConsumedAmountNBT = (SelfStack.getTagCompound().getInteger("ConsumedAmount"));
- if(playerIn.inventory.getStackInSlot(i).getItem() == Items.IRON_INGOT)
- {
- ItemStack IronIngotFound = playerIn.inventory.getStackInSlot(i);
- IronIngotFound.setCount(IronIngotFound.getCount()-1);
- SelfStack.getTagCompound().setInteger("ConsumedAmount", (ConsumedAmountNBT)+1);
- break;
- }
- }
- }
- return super.onItemRightClick(worldIn, playerIn, handIn);
- }
- @Override
- public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
- {
- int ConsumedAmountNBT = (SelfStack.getTagCompound().getInteger("ConsumedAmount"));
- par3List.add("\u00A77Hold right click to consume \u00A7fIron Ingots\u00A77.");
- par3List.add("");
- par3List.add("\u00A7eAmount consumed: \u00A76" + Integer.toString(ConsumedAmountNBT));
- }
Add Comment
Please, Sign In to add comment