Guest User

Untitled

a guest
May 26th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. public class ItemHearthStone extends Item
  2. {
  3. ItemHearthStone()
  4. {
  5. super();
  6. this.setCreativeTab(CruxCraft.cruxTab);
  7. this.setMaxStackSize(1);
  8. this.setUnlocalizedName("hearthstone");
  9. this.setRegistryName("hearthstone");
  10. this.setMaxDamage(200);
  11. }
  12. @Override
  13. public void onUpdate (ItemStack itemStackIn, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)
  14. {
  15. if (itemStackIn.getItemDamage() < itemStackIn.getMaxDamage())
  16. {
  17. itemStackIn.setItemDamage(itemStackIn.getItemDamage() - 1);
  18. }
  19.  
  20. }
  21.  
  22. public EnumAction getItemUseAction(ItemStack stack)
  23. {
  24. return EnumAction.DRINK;
  25. }
  26.  
  27. public void onCreated(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
  28. {
  29. itemStackIn.damageItem(itemStackIn.getMaxDamage()-1, playerIn);
  30. }
  31.  
  32. public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
  33. {
  34. BlockPos pxyz = worldIn.getSpawnPoint();
  35. int px = pxyz.getX();
  36. int py = pxyz.getY();
  37. int pz = pxyz.getZ();
  38.  
  39. if (itemStackIn.getItemDamage() == 0)
  40. {
  41. //playerIn.getCapability(IBaseManaCapability)
  42. playerIn.setPositionAndUpdate(px, py, pz);
  43. worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, soundRegister.astralrecall, SoundCategory.PLAYERS, 1.0F, 1.0F);
  44. worldIn.spawnParticle(EnumParticleTypes.REDSTONE, playerIn.posX + 1, playerIn.posY, playerIn.posZ, 0.0D, 0.0D, 0.0D);
  45. itemStackIn.damageItem(itemStackIn.getMaxDamage()-1, playerIn);
  46.  
  47. }else {
  48.  
  49.  
  50. worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, soundRegister.naturecast, SoundCategory.PLAYERS, 1.0F, 1.0F);
  51.  
  52. }
  53. return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
  54. }
  55.  
  56.  
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment