Guest User

ItemProperties

a guest
Mar 30th, 2015
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.98 KB | None | 0 0
  1. package Ghost.TestMod;
  2.  
  3. import java.util.List;
  4.  
  5. import net.minecraft.entity.player.EntityPlayer;
  6. import net.minecraft.item.Item;
  7. import net.minecraft.item.ItemStack;
  8. import net.minecraft.nbt.NBTTagCompound;
  9. import net.minecraft.util.BlockPos;
  10. import net.minecraft.util.EnumChatFormatting;
  11. import net.minecraft.util.EnumFacing;
  12. import net.minecraft.world.World;
  13. import net.minecraftforge.fml.relauncher.Side;
  14. import net.minecraftforge.fml.relauncher.SideOnly;
  15.  
  16. public class ItemProperties extends Item{
  17.  
  18.     @Override
  19.     public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
  20.     {
  21.         if(!playerIn.isSneaking())
  22.         {
  23.             if(stack.getTagCompound() == null)
  24.             {
  25.                 stack.setTagCompound(new NBTTagCompound());
  26.             }
  27.                     NBTTagCompound nbt = new NBTTagCompound();
  28.                     nbt.getClass();
  29.                     stack.getTagCompound().setTag("Captured", nbt);
  30.                     stack.setStackDisplayName(EnumChatFormatting.AQUA + "PokeBall");
  31.         }
  32.     return false;
  33.     }
  34.    
  35.     @Override
  36.     public ItemStack onItemRightClick(ItemStack stack, World worldIn, EntityPlayer playerIn)
  37.    
  38.         {
  39.             if(playerIn.isSneaking())
  40.             {
  41.                 if(stack.getTagCompound() != null )
  42.                 {
  43.                     stack.getTagCompound().removeTag("Captured");
  44.                     stack.clearCustomName();
  45.                 }
  46.             }
  47.         return stack;
  48.     }
  49.    
  50.     @Override
  51.     @SideOnly(Side.CLIENT)
  52.     public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced)
  53.     {
  54.         if(stack.getTagCompound() != null)
  55.         {
  56.             if(stack.getTagCompound().hasKey("Captured"))
  57.             {
  58.                 NBTTagCompound nbt = (NBTTagCompound) stack.getTagCompound().getTag("Captured");
  59.                 Class<? extends NBTTagCompound> Captured = nbt.getClass();
  60.                 tooltip.add("Captured");
  61.             }
  62.         }
  63.     }
  64.  
  65.     @Override
  66.     @SideOnly(Side.CLIENT)
  67.     public boolean hasEffect(ItemStack stack)
  68.     {
  69.         if(stack.getTagCompound() != null)
  70.         {
  71.             return stack.getTagCompound().hasKey("Captured");
  72.         }
  73.         return false;
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment