// priority: 0

global.metalForm = (metal, tag, form, qty) => {
    if (qty == undefined) {
        qty = 1;
    }
    let itemType = AlmostUnified.getPreferredItemForTag(`forge:${tag}/${metal}`);
    if (itemType.id == 'minecraft:air') {
        console.log(`metals: ${metal} ${form} has unknown tag forge:${tag}/${metal}?`)
        let ret = Item.of(`alltheores:${metal}_${form}`);
        if (ret.id == "minecraft:air") {
            return Item.of(`thermal:${metal}_${form}`);
        }
        return ret;
    }
    console.log(`metals: forge:${tag}/${metal} found`);
    return itemType;
}

global.dustItem = (material, qty) => {
    return global.metalForm(material, 'dusts', 'dust', qty);
}

global.ingotItem = (material, qty) => {
    return global.metalForm(material, 'ingots', 'ingot', qty);
}

global.gearItem = (material, qty) => {
    return global.metalForm(material, 'gears', 'gear', qty);
}

global.nuggetItem = (material, qty) => {
    return global.metalForm(material, 'nuggets', 'nugget', qty);
}

global.replaceInputs = (evt, filter, replaceMap) => {
    replaceMap.forEach(mapped => {
        evt.replaceInput(
            filter,
            mapped[0],
            mapped[1]
        );
    })
}