Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. @Override
  2. public void onUpdate(ItemStack itemStack, World world, Entity entity, int i, boolean flag) {
  3. super.onUpdate(itemStack, world, entity, i, flag);
  4.  
  5. if (!world.isRemote) {
  6. NBTTagCompound nbtDataCompund = itemStack.getSubCompound("coolDown", true);
  7.  
  8. int coolDown = nbtDataCompund.getInteger("coolDown");
  9. if (coolDown > 0) {
  10. --coolDown;
  11. nbtDataCompund.setInteger("coolDown", coolDown);
  12. }
  13. }
  14. }
  15.  
  16. @Override
  17. public boolean itemInteractionForEntity(ItemStack itemStack, EntityPlayer entityPlayer, EntityLivingBase entity, EnumHand hand) {
  18. NBTTagCompound nbtDataCompund = itemStack.getSubCompound("coolDown", true);
  19. if (nbtDataCompund != null) {
  20. int coolDown = nbtDataCompund.getInteger("coolDown");
  21.  
  22. if (coolDown > 0) {
  23. return false;
  24. }
  25.  
  26. if (coolDown == 0) {
  27. if (entity instanceof EntityMob) {
  28. if (itemStack.getItemDamage() > 0) {
  29. entity.setHealth(0.0F);
  30. nbtDataCompund.setInteger("coolDown", ItemConfig.magicStoneCooldown);
  31. if (!entity.worldObj.isRemote) {
  32. entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "Soul Absurbed!"));
  33. }
  34. itemStack.damageItem(-1, entityPlayer);
  35. return true;
  36. } else {
  37. if (!entity.worldObj.isRemote) {
  38. entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "The Magical Stone seems to be full?"));
  39. entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "It seems to be useless now."));
  40. entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "I wonder whats inside?"));
  41. }
  42. return true;
  43. }
  44. } else if (!entity.worldObj.isRemote) {
  45. entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "Why has this stoped working?"));
  46. }
  47. } else {
  48. entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "Why has this stoped working?"));
  49. }
  50. }
  51. return false;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement