Advertisement
PSquishyP

Untitled

Jul 11th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 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(itemstack .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. private Object inventory;
  49.  
  50.  
  51.  
  52. //use timer in ticks (24000)
  53. public ItemRegenerationStone() {
  54. setMaxStackSize(1);
  55. setMaxDamage(24000);
  56. setNoRepair();
  57. }
  58.  
  59. public void onCreated(ItemStack itemStack, World world, EntityPlayer player) {
  60.  
  61. }
  62.  
  63.  
  64.  
  65. @Override
  66. public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag)
  67. {
  68. //stuff to do when active
  69.  
  70. if(itemstack.stackTagCompound == null){
  71. itemstack.stackTagCompound = new NBTTagCompound();
  72. itemstack.stackTagCompound.setInteger("timer", 24000);
  73. itemstack.stackTagCompound.setInteger("enabled", 0);
  74. }
  75. EntityPlayer player = (EntityPlayer)entity;
  76.  
  77. if(itemstack.stackTagCompound.getInteger("active") == 1)
  78. {
  79. itemstack.stackTagCompound.setInteger("timer", itemstack.getTagCompound().getInteger("timer") + -1);
  80. ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.regeneration.id, 20, 1));
  81. }
  82.  
  83. if(itemstack.stackTagCompound.getInteger("timer") <= 0){player.inventory.consumeInventoryItem(AbilityStones.itemRegenerationStone);}
  84.  
  85.  
  86.  
  87.  
  88.  
  89. }
  90.  
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement