Hello everyone, I have a small problem my item is working properly, but does not lose durability while I withdraw from it
I watched a lot of English subjects without finding the answer.
Here is my code:
public ItemEffect(String name, int maxDamage, int stackSize, int coolDown, PotionEffect effect)
{
super(name);
this.setMaxDamage(maxDamage);
this.setMaxStackSize(stackSize);
this.setFull3D();
this.effect = effect;
this.coolDown = coolDown;
}
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
ItemStack itemStack = playerIn.getHeldItemMainhand();
if(worldIn.isRemote)
{
return new ActionResult<>(EnumActionResult.FAIL, itemStack);
}
if (!playerIn.inventory.hasItemStack(itemStack))
{
return new ActionResult<>(EnumActionResult.FAIL, itemStack);
}
if (itemStack.getItemDamage() > itemStack.getMaxDamage()) {
return new ActionResult<>(EnumActionResult.FAIL, itemStack);
}
playerIn.addPotionEffect(new PotionEffect(effect.getPotion(), effect.getDuration(), effect.getAmplifier(), effect.getIsAmbient(), effect.doesShowParticles()));
playerIn.getCooldownTracker().setCooldown(this, coolDown);
itemStack.damageItem(1, playerIn);
itemStack.shrink(1);
return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
}
Thank you in advance to the person who will help me.