I'm trying to implement durability on an item which transports the player to another dimension on right click. I want the durability to decrease every time it is used, but I do not want the item to disappear once the durability is 0. Here is the current code I have:
public class TeleportationStickItem extends Item {
public TeleportationStickItem(Properties properties) {
super(properties);
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
if (!world.isRemote) {
player.changeDimension(world.dimension.getType() == DimensionType.byName(WoAiNiMod.DRUG_DIM_TYPE) ? DimensionType.OVERWORLD : DimensionType.byName(WoAiNiMod.DRUG_DIM_TYPE), new VoidTeleporter((ServerWorld) player.getEntityWorld()));
}
return super.onItemRightClick(world, player, hand);
}
}
Please let me know if there is anything that can help!