Guest User

I'm the biggest idiot. The biggest one.

a guest
Apr 2nd, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.39 KB | None | 0 0
  1.     @Override
  2.     public ItemStack onItemRightClick(ItemStack stack, World worldIn, EntityPlayer p)
  3.     {
  4.         NBTTagCompound nbt;
  5.         if(stack.hasTagCompound())
  6.         {
  7.             nbt = stack.getTagCompound();
  8.         }
  9.         else
  10.         {
  11.             nbt = new NBTTagCompound();
  12.         }
  13.        
  14.         if(nbt.hasKey("Amount"))
  15.         {
  16.             int invSize = p.inventory.getSizeInventory();
  17.             for(int i=0; i<invSize; i++)
  18.             {
  19.                 int nbtAmount = nbt.getInteger("ConsumedAmount");
  20.                
  21.                 if(p.inventory.getStackInSlot(i).getItem() == Items.IRON_INGOT)
  22.                 {
  23.                     ItemStack IronIngotFound = p.inventory.getStackInSlot(i);
  24.                    
  25.                     IronIngotFound.setCount(IronIngotFound.getCount()-1);
  26.                    
  27.                     nbt.setInteger("ConsumedAmount", nbtAmount+1);
  28.                 }
  29.             }
  30.         }
  31.         else
  32.         {
  33.             nbt.setInteger("Amount", 0);
  34.         }
  35.         stack.setTagCompound(nbt);
  36.        
  37.         return stack;
  38.     }
  39.    
  40.     @Override
  41.     public void addInformation(ItemStack stack, EntityPlayer p, List lore, boolean unused_bool)
  42.     {
  43.         lore.add("\u00A77Hold right click to consume \u00A7fIron Ingots\u00A77, and gain buffs.");
  44.         lore.add("");
  45.         if(stack.hasTagCompound() && stack.getTagCompound().hasKey("Amount"))
  46.         {
  47.             String nbtAmountStr = Integer.toString( stack.getTagCompound().getInteger("ConsumedAmount") );
  48.             lore.add("\u00A7eAmount consumed: \u00A76" + nbtAmountStr);
  49.         }
  50.         else
  51.         {
  52.             lore.add("\u00A7eAmount consumed: \u00A7c0");
  53.         }
  54.     }
Add Comment
Please, Sign In to add comment