Advertisement
PSquishyP

Untitled

Jul 12th, 2015
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 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. //use timer in ticks (24000)
  22. public ItemRegenerationStone() {
  23. setMaxStackSize(1);
  24. setMaxDamage(24000);
  25. setNoRepair();
  26. setUnlocalizedName("ItemRegenerationStone");
  27. setTextureName("abilstones:itemRegenerationStone");
  28. }
  29.  
  30. public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
  31. {
  32. par3List.add("Minutes Remaining: " + (((par1ItemStack.getTagCompound().getInteger("timer"))/20)/60+1));
  33. }
  34.  
  35. public ItemStack onItemRightClick(ItemStack itemstack, World par2World, EntityPlayer par3EntityPlayer)
  36. {
  37. if(itemstack.stackTagCompound.getInteger("enabled") == 1 && itemstack.stackTagCompound.getInteger("cooldown") == 0)
  38. {
  39. itemstack.stackTagCompound.setInteger("enabled", 0);
  40. itemstack.stackTagCompound.setInteger("cooldown", 20);
  41. System.out.println("Was Enabled, now Disabled");
  42. return itemstack;
  43. }
  44. else if(itemstack.stackTagCompound.getInteger("enabled") == 0 && itemstack.stackTagCompound.getInteger("cooldown") == 0)
  45. {
  46. itemstack.stackTagCompound.setInteger("enabled", 1);
  47. itemstack.stackTagCompound.setInteger("cooldown", 20);
  48. System.out.println("Was Disabled, now Enabled");
  49. return itemstack;
  50. }
  51. else
  52. {
  53. System.out.println("Warning! For some reason the " + this + " is not enabled nor disabled. Please report this to the mod author!");
  54. return itemstack;
  55. }
  56. }
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64. EntityPlayer player = Minecraft.getMinecraft().thePlayer;
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71. @Override
  72. public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag)
  73. {
  74. //stuff to do when active
  75.  
  76. if(itemstack.stackTagCompound == null){
  77. itemstack.stackTagCompound = new NBTTagCompound();
  78. itemstack.stackTagCompound.setInteger("timer", 23999);
  79. itemstack.stackTagCompound.setInteger("enabled", 0);
  80. itemstack.stackTagCompound.setInteger("cooldown", 0);
  81. }
  82. EntityPlayer player = (EntityPlayer)entity;
  83.  
  84. if(itemstack.stackTagCompound.getInteger("enabled") == 1)
  85. {
  86.  
  87. itemstack.stackTagCompound.setInteger("timer", itemstack.getTagCompound().getInteger("timer") + -1);
  88. ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.regeneration.id, 20, 1));
  89. }
  90.  
  91.  
  92. if(itemstack.stackTagCompound.getInteger("timer") <= 0){player.inventory.consumeInventoryItem(AbilityStones.ItemRegenerationStone);}
  93.  
  94. if(itemstack.stackTagCompound.getInteger("cooldown") > 0)
  95. {
  96. itemstack.stackTagCompound.setInteger("cooldown", itemstack.getTagCompound().getInteger("cooldown") + -1);
  97. System.out.println("minus one tick");
  98. }
  99.  
  100. }
  101.  
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement