Advertisement
Guest User

Untitled

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