Advertisement
PSquishyP

Untitled

Jul 11th, 2015
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. package noahc3.AbilityStones;
  2.  
  3. import java.util.List;
  4.  
  5. import net.minecraft.client.Minecraft;
  6. import net.minecraft.entity.Entity;
  7. import net.minecraft.entity.EntityLivingBase;
  8. import net.minecraft.entity.player.EntityPlayer;
  9. import net.minecraft.item.Item;
  10. import net.minecraft.item.ItemStack;
  11. import net.minecraft.nbt.NBTTagCompound;
  12. import net.minecraft.potion.Potion;
  13. import net.minecraft.potion.PotionEffect;
  14. import net.minecraft.world.World;
  15.  
  16.  
  17.  
  18. public class ItemRegenerationStone extends Item
  19. {
  20.  
  21. public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
  22. {
  23. par3List.add("Minutes Remaining: " + (((par1ItemStack.getTagCompound().getInteger("timer"))/20)/60+1));
  24. }
  25.  
  26. if(onRightClick == true)
  27.  
  28. {
  29.  
  30. if(par1itemStack .stackTagCompound.getInteger("enabled") == 1)
  31. {
  32. itemstack.stackTagCompound.setInteger("enabled", 0);
  33. }
  34. else
  35. {
  36. itemstack.stackTagCompound.setInteger("enabled", 1);
  37. }
  38.  
  39. }
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47. EntityPlayer player = Minecraft.getMinecraft().thePlayer;
  48.  
  49.  
  50.  
  51. //use timer in ticks (24000)
  52. public ItemRegenerationStone() {
  53. setMaxStackSize(1);
  54. setMaxDamage(24000);
  55. setNoRepair();
  56. }
  57.  
  58.  
  59. @Override
  60. public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag)
  61. {
  62. //stuff to do when active
  63.  
  64. if(itemstack.stackTagCompound == null){
  65. itemstack.stackTagCompound = new NBTTagCompound();
  66. itemstack.stackTagCompound.setInteger("timer", 24000);
  67. itemstack.stackTagCompound.setInteger("enabled", 0);
  68. }
  69. EntityPlayer player = (EntityPlayer)entity;
  70.  
  71. if(itemstack.stackTagCompound.getInteger("active") == 1)
  72. {
  73.  
  74. itemstack.stackTagCompound.setInteger("timer", itemstack.getTagCompound().getInteger("timer") + -1);
  75. ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.regeneration.id, 20, 1));
  76. }
  77.  
  78.  
  79. if(itemstack.stackTagCompound.getInteger("timer") <= 0){player.inventory.consumeInventoryItem(AbilityStones.itemRegenerationStone);}
  80.  
  81.  
  82. }
  83.  
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement