Guest User

I'm an even bigger idiot

a guest
Apr 2nd, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.61 KB | None | 0 0
  1. public class Item_Eater extends Item {
  2.     ItemStack SelfStack = new ItemStack(this);
  3.    
  4.     public void onUpdate(ItemStack stack, World world, Entity entity, int metadata, boolean bool)
  5.     {
  6.             if (SelfStack.getTagCompound() == null)
  7.             {
  8.                 SelfStack.setTagCompound(new NBTTagCompound());
  9.             }
  10.             SelfStack.getTagCompound().setInteger("ConsumedAmount", 0);
  11.     }
  12.    
  13.    
  14.     @Override
  15.     public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
  16.     {
  17.         if(playerIn.inventory.hasItemStack(SelfStack))
  18.         {
  19.             int invSize = playerIn.inventory.getSizeInventory();
  20.             for(int i=0; i<invSize; i++)
  21.             {
  22.                 int ConsumedAmountNBT = (SelfStack.getTagCompound().getInteger("ConsumedAmount"));
  23.                
  24.                 if(playerIn.inventory.getStackInSlot(i).getItem() == Items.IRON_INGOT)
  25.                 {
  26.                     ItemStack IronIngotFound = playerIn.inventory.getStackInSlot(i);
  27.                    
  28.                     IronIngotFound.setCount(IronIngotFound.getCount()-1);
  29.                    
  30.                     SelfStack.getTagCompound().setInteger("ConsumedAmount", (ConsumedAmountNBT)+1);
  31.                     break;
  32.                 }
  33.                
  34.             }
  35.         }
  36.         return super.onItemRightClick(worldIn, playerIn, handIn);
  37.     }
  38.    
  39.     @Override
  40.     public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
  41.     {
  42.         int ConsumedAmountNBT = (SelfStack.getTagCompound().getInteger("ConsumedAmount"));
  43.        
  44.         par3List.add("\u00A77Hold right click to consume \u00A7fIron Ingots\u00A77.");
  45.         par3List.add("");
  46.         par3List.add("\u00A7eAmount consumed: \u00A76" + Integer.toString(ConsumedAmountNBT));
  47.     }
Add Comment
Please, Sign In to add comment