Mention Repairs with Anvil
The documentation for MC 1.21.10 shows how to create a new material Guidite for armor. This is the code for the repair material mentioned in the guide:
public static final TagKey<Item> REPAIRS_GUIDITE_ARMOR = TagKey.of(Registries.ITEM.getKey(), Identifier.of(ExampleMod.MOD_ID, "repairs_guidite_armor"));
https://github.com/FabricMC/fabric-docs/blob/main/develop/items/custom-armor.md
but it doesn't show how to make the armor repariable in the anvil with the base material guidite_ingot.
I expect the dev would need to create a repairs_guidite_armor.json file somewhere and configure the base item to be used?
Yes, create an item tag under your mod namespace.
I created a file named repairs_golden_chain_armor.json under path src/main/resources/data/experiments_mod/tags/items/repairs_golden_chain_armor.json with this content:
// repairs_golden_chain_armor.json file
{
"values": [
"minecraft:gold_ingot"
]
}
but not sure why it's not working
// Constants.kt file
object Constants {
const val MOD_ID = "experiments_mod"
}
// CustomItemTags.kt file
val REPAIRS_GOLDEN_CHAIN_ARMOR: TagKey<Item> = of("repairs_golden_chain_armor")
fun of(name: String): TagKey<Item> {
return TagKey.of(RegistryKeys.ITEM, Identifier.of(MOD_ID, name))
}
// CustomEquipmentAssetKeys.kt file
val GOLDEN_CHAINMAIL = register("golden_chainmail")
fun register(name: String): RegistryKey<EquipmentAsset> {
return RegistryKey.of(EquipmentAssetKeys.REGISTRY_KEY, Identifier.of(
MOD_ID,
name
))
}
// CustomArmorMaterials.kt file
val GOLD_CHAIN = ArmorMaterial(
7,
createDefenseMap(1, 4, 5, 2, 4),
25,
SoundEvents.ITEM_ARMOR_EQUIP_CHAIN,
0.0f,
0.0f,
CustomItemTags.REPAIRS_GOLDEN_CHAIN_ARMOR,
CustomEquipmentAssetKeys.GOLDEN_CHAINMAIL,
)
// CustomItems.kt
val GOLDEN_CHAINMAIL_HELMET = register(
"golden_chainmail_helmet", Item.Settings()
.armor(CustomArmorMaterials.GOLD_CHAIN, EquipmentType.HELMET)
.maxDamage(EquipmentType.HELMET.getMaxDamage(CustomArmorMaterials.GOLD_CHAIN.durability))
)
val GOLDEN_CHAINMAIL_CHESTPLATE = register(
"golden_chainmail_chestplate", Item.Settings()
.armor(CustomArmorMaterials.GOLD_CHAIN, EquipmentType.CHESTPLATE)
.maxDamage(EquipmentType.CHESTPLATE.getMaxDamage(CustomArmorMaterials.GOLD_CHAIN.durability))
)
val GOLDEN_CHAINMAIL_LEGGINGS = register(
"golden_chainmail_leggings", Item.Settings()
.armor(CustomArmorMaterials.GOLD_CHAIN, EquipmentType.LEGGINGS)
.maxDamage(EquipmentType.LEGGINGS.getMaxDamage(CustomArmorMaterials.GOLD_CHAIN.durability))
)
val GOLDEN_CHAINMAIL_BOOTS = register(
"golden_chainmail_boots", Item.Settings()
.armor(CustomArmorMaterials.GOLD_CHAIN, EquipmentType.BOOTS)
.maxDamage(EquipmentType.BOOTS.getMaxDamage(CustomArmorMaterials.GOLD_CHAIN.durability))
)
Did I do anything wrong @dicedpixels ?
All the textures when in the inventory, held or worn are fine and the locale text, the crafting recipe and blasting worked. It's just the anvil repair not registered somehow. I put the armor item and a golden ingot in any order, there's no output and a red X indicating it can't be repaired (the item is damaged ofc)
- src/main/resources/data/experiments_mod/tags/items/repairs_golden_chain_armor.json
+ src/main/resources/data/experiments_mod/tags/item/repairs_golden_chain_armor.json
item not items.
@dicedpixels oof I always do some typos with these things. It works now thanks.
Should I maybe open a PR with this information (how to make the armour repairable) on the tutorial? It could help others to implement this
Feel free. Just mentioning a tag should be created is sufficient. You can also update the reference mod with a data generator to generate that tag similar to this.
I haven't tried the data generator approach yet, so I am not unfamiliar with it. I'll see if I can find some time to contribute with a PR mentioning the tag creation, then I'll close this issue