SHARE
TWEET

dis class

a guest Oct 7th, 2014 17 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.ilan321.transmutation.items;
  2.  
  3. import net.minecraft.entity.player.EntityPlayer;
  4. import net.minecraft.inventory.IInventory;
  5. import net.minecraft.item.ItemStack;
  6. import net.minecraft.nbt.NBTTagCompound;
  7. import net.minecraft.util.EnumChatFormatting;
  8. import net.minecraft.world.World;
  9.  
  10. import java.util.List;
  11.  
  12. /**
  13.  * Created by Ilan on 9/30/14.
  14.  */
  15. public class BasicTransmutationStone extends CommonItem {
  16.     public BasicTransmutationStone()
  17.     {
  18.         super();
  19.         this.maxStackSize = 1;
  20.         this.setUnlocalizedName("basicStone");
  21.     }
  22.     @Override
  23.     public boolean doesContainerItemLeaveCraftingGrid(ItemStack stack)
  24.     {
  25.         return false;
  26.     }
  27.     @Override
  28.     public void addInformation(ItemStack stack, EntityPlayer player,
  29.                                List list, boolean par4)
  30.     {
  31.         if (stack.stackTagCompound != null)
  32.         {
  33.             String owner = stack.stackTagCompound.getString("owner");
  34.             Integer uses = stack.stackTagCompound.getInteger("uses");
  35.             list.add("Owner: " + owner);
  36.             if (uses > 95)
  37.             {
  38.                 list.add("Uses: " + EnumChatFormatting.GREEN + uses);
  39.             }
  40.             if ((uses > 63) && (uses < 96))
  41.             {
  42.                 list.add("Uses: " + EnumChatFormatting.YELLOW + uses);
  43.             }
  44.             if ((uses < 64) && (uses > 2))
  45.             {
  46.                 list.add("Uses: " + EnumChatFormatting.RED + uses);
  47.             }
  48.             if (uses.equals(1))
  49.             {
  50.                 list.add("Uses: " + EnumChatFormatting.DARK_RED + uses);
  51.             }
  52.         }
  53.     }
  54.     public void removeItem(EntityPlayer ep, ItemStack item)
  55.     {
  56.         IInventory inv = ep.inventory;
  57.         for (int i = 0; i < inv.getSizeInventory(); i++)
  58.         {
  59.             if (inv.getStackInSlot(i) != null)
  60.             {
  61.                 ItemStack j = inv.getStackInSlot(i);
  62.                 if (j.getItem() != null && j.getItem() == item.getItem())
  63.                 {
  64.                     inv.setInventorySlotContents(i, null);
  65.                     return;
  66.                 }
  67.             }
  68.         }
  69.     }
  70.     @Override
  71.     public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
  72.     {
  73.         if (stack.stackTagCompound != null)
  74.         {
  75.             stack.stackTagCompound.setInteger("uses", stack.stackTagCompound.getInteger("uses") - 1);
  76.             if (stack.stackTagCompound.getInteger("uses") < 1)
  77.             {
  78.                 removeItem(player, stack);
  79.             }
  80.             return true;
  81.         }
  82.         return false;
  83.     }
  84. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top