Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public ItemStack onItemRightClick(ItemStack stack, World worldIn, EntityPlayer p)
- {
- NBTTagCompound nbt;
- if(stack.hasTagCompound())
- {
- nbt = stack.getTagCompound();
- }
- else
- {
- nbt = new NBTTagCompound();
- }
- if(nbt.hasKey("Amount"))
- {
- int invSize = p.inventory.getSizeInventory();
- for(int i=0; i<invSize; i++)
- {
- int nbtAmount = nbt.getInteger("ConsumedAmount");
- if(p.inventory.getStackInSlot(i).getItem() == Items.IRON_INGOT)
- {
- ItemStack IronIngotFound = p.inventory.getStackInSlot(i);
- IronIngotFound.setCount(IronIngotFound.getCount()-1);
- nbt.setInteger("ConsumedAmount", nbtAmount+1);
- }
- }
- }
- else
- {
- nbt.setInteger("Amount", 0);
- }
- stack.setTagCompound(nbt);
- return stack;
- }
- @Override
- public void addInformation(ItemStack stack, EntityPlayer p, List lore, boolean unused_bool)
- {
- lore.add("\u00A77Hold right click to consume \u00A7fIron Ingots\u00A77, and gain buffs.");
- lore.add("");
- if(stack.hasTagCompound() && stack.getTagCompound().hasKey("Amount"))
- {
- String nbtAmountStr = Integer.toString( stack.getTagCompound().getInteger("ConsumedAmount") );
- lore.add("\u00A7eAmount consumed: \u00A76" + nbtAmountStr);
- }
- else
- {
- lore.add("\u00A7eAmount consumed: \u00A7c0");
- }
- }
Add Comment
Please, Sign In to add comment