Advertisement
PSquishyP

Untitled

Jul 12th, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 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. public ItemStack onItemRightClick(ItemStack itemstack, World par2World, EntityPlayer par3EntityPlayer)
  27. {
  28. if(itemstack.stackTagCompound.getInteger("enabled") == 1)
  29. {
  30. itemstack.stackTagCompound.setInteger("enabled", 0);
  31. System.out.println("Was Enabled, now Disabled");
  32. return itemstack;
  33. }
  34. else
  35. {
  36. itemstack.stackTagCompound.setInteger("enabled", 1);
  37. System.out.println("Was Disabled, now Enabled");
  38. return itemstack;
  39. }
  40. }
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48. EntityPlayer player = Minecraft.getMinecraft().thePlayer;
  49.  
  50.  
  51.  
  52. //use timer in ticks (24000)
  53. public ItemRegenerationStone() {
  54. setMaxStackSize(1);
  55. setMaxDamage(24000);
  56. setNoRepair();
  57. }
  58.  
  59.  
  60. @Override
  61. public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag)
  62. {
  63. //stuff to do when active
  64.  
  65. if(itemstack.stackTagCompound == null){
  66. itemstack.stackTagCompound = new NBTTagCompound();
  67. itemstack.stackTagCompound.setInteger("timer", 24000);
  68. itemstack.stackTagCompound.setInteger("enabled", 0);
  69. }
  70. EntityPlayer player = (EntityPlayer)entity;
  71.  
  72. if(itemstack.stackTagCompound.getInteger("active") == 1)
  73. {
  74.  
  75. itemstack.stackTagCompound.setInteger("timer", itemstack.getTagCompound().getInteger("timer") + -1);
  76. ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.regeneration.id, 20, 1));
  77. }
  78.  
  79.  
  80. if(itemstack.stackTagCompound.getInteger("timer") <= 0){player.inventory.consumeInventoryItem(AbilityStones.itemRegenerationStone);}
  81.  
  82.  
  83. }
  84.  
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement