I created an item "Copper Ingot" whose tag is "forge:ingots/copper". I made a constant which contains that tag.
public final class ForgeItemTags
{
public static final Tag<Item> COPPER_INGOT = ItemTags.getCollection().getOrCreate(new ResourceLocation("forge", "ingots/copper"));
private ForgeItemTags() {}
}
And I used Ingredient.fromTag() method to set all copper ingots, including my copper ingot, to be repair materials of copper tools.
public enum BiomeOreItemTier implements IItemTier
{
COPPER(2, 223, 5.7F, 2.0F, 15, Ingredient.fromTag(ForgeItemTags.COPPER_INGOT));
private final int harvestLevel;
private final int maxUses;
private final float efficiency;
private final float attackDamage;
private final int enchantability;
private final Ingredient repairMaterial;
BiomeOreItemTier(int harvestLevel, int maxUses, float efficiency, float attackDamage, int enchantability, Ingredient repairMaterial)
{
this.harvestLevel = harvestLevel;
this.maxUses = maxUses;
this.efficiency = efficiency;
this.attackDamage = attackDamage;
this.enchantability = enchantability;
this.repairMaterial = repairMaterial;
}
/...
}
Then I used the COPPER ItemTier to make my copper sword.
public static final Item COPPER_SWORD = register("copper_sword", new SwordItem(BiomeOreItemTier.COPPER, 3, -2.4F, new Item.Properties().group(BiomeOreItemGroup.BIOME_ORE_TOOL)));
But in the game, I cannot repair my sword using my copper ingot. I can't figure out what is wrong with my codes. When I printed the item tag of my copper ingot using onItemRightClick() method in Item class the ingot had the tag "forge:ingots/copper". But it cannot repair my copper tools. How can I fix it?