Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 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.  
  19. if (!entity.worldObj.isRemote) {
  20. NBTTagCompound nbtDataCompund = itemStack.getSubCompound("coolDown", true);
  21. if (nbtDataCompund != null) {
  22. int coolDown = nbtDataCompund.getInteger("coolDown");
  23.  
  24. if (coolDown > 0) {
  25. return false;
  26. }
  27.  
  28. if (coolDown == 0) {
  29. if (entity instanceof EntityMob) {
  30. if (itemStack.getItemDamage() > 0) {
  31. entity.setHealth(0.0F);
  32. nbtDataCompund.setInteger("coolDown", ItemConfig.magicStoneCooldown);
  33. if (!entity.worldObj.isRemote) {
  34. entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "Soul Absurbed!"));
  35. }
  36. itemStack.damageItem(-1, entityPlayer);
  37. return true;
  38. } else {
  39. if (!entity.worldObj.isRemote) {
  40. entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "The Magical Stone seems to be full?"));
  41. entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "It seems to be useless now."));
  42. entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "I wonder whats inside?"));
  43. }
  44. return true;
  45. }
  46. } else if (!entity.worldObj.isRemote) {
  47. entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "Why has this stoped working?"));
  48. }
  49. } else {
  50. entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "Why has this stoped working?"));
  51. }
  52. }
  53. }
  54. return false;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement