Advertisement
Guest User

Untitled

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