Advertisement
PSquishyP

Untitled

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