Advertisement
Guest User

ItemImmortalityChalice

a guest
Feb 6th, 2015
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.86 KB | None | 0 0
  1. package lumien.randomthings.item;
  2.  
  3. import java.util.Iterator;
  4. import java.util.List;
  5.  
  6. import lumien.randomthings.lib.PlayerAbilitiesProperty;
  7.  
  8. import net.minecraft.entity.player.EntityPlayer;
  9. import net.minecraft.init.Items;
  10. import net.minecraft.item.EnumAction;
  11. import net.minecraft.item.EnumRarity;
  12. import net.minecraft.item.Item;
  13. import net.minecraft.item.ItemStack;
  14. import net.minecraft.potion.PotionEffect;
  15. import net.minecraft.stats.StatList;
  16. import net.minecraft.world.World;
  17.  
  18. public class ItemImmortalityChalice extends ItemBase
  19. {
  20.     public ItemImmortalityChalice()
  21.     {
  22.         super("chaliceOfImmortality");
  23.        
  24.         this.setMaxStackSize(1);
  25.     }
  26.  
  27.     public EnumRarity getRarity(ItemStack stack)
  28.     {
  29.         return EnumRarity.EPIC;
  30.     }
  31.  
  32.     public int getMaxItemUseDuration(ItemStack stack)
  33.     {
  34.         return 60;
  35.     }
  36.  
  37.     public EnumAction getItemUseAction(ItemStack stack)
  38.     {
  39.         return EnumAction.DRINK;
  40.     }
  41.  
  42.     public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
  43.     {
  44.         playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
  45.  
  46.         return itemStackIn;
  47.     }
  48.    
  49.     public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityPlayer playerIn)
  50.     {
  51.         if (!playerIn.capabilities.isCreativeMode)
  52.         {
  53.             --stack.stackSize;
  54.         }
  55.  
  56.         if (!worldIn.isRemote)
  57.         {
  58.             PlayerAbilitiesProperty abilities = (PlayerAbilitiesProperty) playerIn.getExtendedProperties(PlayerAbilitiesProperty.KEY);
  59.             abilities.setImmortal(true);
  60.         }
  61.  
  62.         if (!playerIn.capabilities.isCreativeMode)
  63.         {
  64.             if (stack.stackSize <= 0)
  65.             {
  66.                 return new ItemStack(Items.glass_bottle);
  67.             }
  68.  
  69.             playerIn.inventory.addItemStackToInventory(new ItemStack(Items.glass_bottle));
  70.         }
  71.  
  72.         return stack;
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement