ListNBT enchantmentList = ItemStack1.getEnchantmentTagList();
for (int i = 0; i < enchantmentList.size(); i++){
short id = enchantmentList.getCompound(i).getShort("id");
short lvl = enchantmentList.getCompound(i).getShort("lvl");
ItemStack2.addEnchantment(Objects.requireNonNull(Enchantment.getEnchantmentByID(id)), lvl);
}
I tried to kinda copy the enchnments from itemStack1 to itemStack2 in this code, the problem is that every enchantment in itemStack1 become protection in itemStack2.
The other stuff works fine, the levels and the number of enchantments is good.
Thanks😀