Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ItemHearthStone extends Item
- {
- ItemHearthStone()
- {
- super();
- this.setCreativeTab(CruxCraft.cruxTab);
- this.setMaxStackSize(1);
- this.setUnlocalizedName("hearthstone");
- this.setRegistryName("hearthstone");
- this.setMaxDamage(200);
- }
- @Override
- public void onUpdate (ItemStack itemStackIn, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)
- {
- if (itemStackIn.getItemDamage() < itemStackIn.getMaxDamage())
- {
- itemStackIn.setItemDamage(itemStackIn.getItemDamage() - 1);
- }
- }
- public EnumAction getItemUseAction(ItemStack stack)
- {
- return EnumAction.DRINK;
- }
- public void onCreated(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
- {
- itemStackIn.damageItem(itemStackIn.getMaxDamage()-1, playerIn);
- }
- public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
- {
- BlockPos pxyz = worldIn.getSpawnPoint();
- int px = pxyz.getX();
- int py = pxyz.getY();
- int pz = pxyz.getZ();
- if (itemStackIn.getItemDamage() == 0)
- {
- //playerIn.getCapability(IBaseManaCapability)
- playerIn.setPositionAndUpdate(px, py, pz);
- worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, soundRegister.astralrecall, SoundCategory.PLAYERS, 1.0F, 1.0F);
- worldIn.spawnParticle(EnumParticleTypes.REDSTONE, playerIn.posX + 1, playerIn.posY, playerIn.posZ, 0.0D, 0.0D, 0.0D);
- itemStackIn.damageItem(itemStackIn.getMaxDamage()-1, playerIn);
- }else {
- worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, soundRegister.naturecast, SoundCategory.PLAYERS, 1.0F, 1.0F);
- }
- return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment