I'm trying to create a generic repair recipe, to repair any item that is damaged but I'm not sure how to match on the required item types. I know for output I can use .modifyResult to decrease the Damage done, but I'm not sure how to match the item.
The script below kinda does what I want, but I don't want the recipe to be valid for items with no Damage, and I want it to work on any item that has Damage
event.custom({
"type": "create:filling",
"ingredients": [
{
"item": "minecraft:diamond_sword"
},
{
"fluid": "create_enchantment_industry:experience",
"amount": 10
}
],
"results": [
{
"item": "minecraft:diamond_sword"
}
]
}).modifyResult((inventory, itemstack) => {
item = inventory.find(Item.of('minecraft:diamond_sword').ignoreNBT())
if (item.nbt == null) return itemstack
nbt = item.nbt
nbt.Damage = nbt.Damage - 1;
return itemstack.withNBT(nbt)
})