Hi all. I have an item in the mod with durability, from which another item is crafted. Can I somehow transfer durability to a new item?
here is the item class code:
package com.zombier.slimesing.items;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
public class NeedlepItem extends Item {
public NeedlepItem(){
super(new Properties()
.tab(CreativeModeTab.TAB_TOOLS)
.stacksTo(1) .defaultDurability(128)
.setNoRepair() );
}
@Override public boolean hasContainerItem(ItemStack stack){ return true; }
@Override public ItemStack getContainerItem(ItemStack itemStack) {
ItemStack stack = itemStack.copy();
stack.setDamageValue(itemStack.getDamageValue() + 1);
return stack;
}
}
If I'm returning the item, don't mind it, I'll fix it. The main thing is to understand how to transfer strength to a new item. It must be damaged by the same number of units as the previous one. The idea is that I have a needle that has durability, and I have a needle with thread that should take on the same durability after crafting.