ServerEvents.recipes(event => {
    const metals = {
        tin: {
            tfc: 'tin',
            tier: 1
        },
        copper: {
            tfc: 'copper',
            tier: 1
        },
        gold: {
            tfc: 'gold',
            tier: 2
        },
        silver: {
            tfc: 'silver',
            tier: 2
        },
        bronze: {
            tfc: 'bronze',
            tier: 2
        },

        iron: {
            tfc: 'wrought_iron',
            tier: 3
        },

        steel: {
            tfc: 'steel',
            tier: 4
        }
    }
    
    const forbiddenMetals = [
        'stone',
        'diamond'
    ]
    
    const packs = [
        'antiquelegacy',
        'magistuarmory',
        'magistuarmoryaddon',
        'slavicarmory'
    ]
    
    const oneHandedSword = [
        'gladius',
        'republic_gladius',
        'gladiator_sword',
        'antique_dagger',
        'antique_sword',
        'celtic_sword',
        'single_edged_sword',
        'xiphos',
        'kopis',
        'sica',
        'early_spatha',
        'spatha',
        'stylet',
        'rus_sword',
        'bollock_dagger',
        'dagger',
        'parrying_dagger',
        'rondel_dagger',
        'sickle',
        'cavalry_sabre',
        'falchion',
        'maciejowski_messer',
        'rapier',
        'sidesword',
        'arming_sword_type_xiii',
        'arming_sword_type_xiv',
        'arming_sword_type_xv',
        'sabre',
        'saxon_sword',
        'short_seax',
        'swordbreaker',
        'short_sword',
        'katzbalger'
    ]

    const twoHandedSword = [
        'rhomphaia',
        'executioners_sword',
        'german_greatsword',
        'two_handed_messer',
        'cutlass',
        'feder',
        'grand_falchion',
        'king_sword',
        'longsword',
        'long_seax',
        'messer_sword',
        'scimitar',
        'bastardsword',
        'estoc',
        'claymore',
        'zweihander'
    ]
    
    const spear = [
        'rogatina',
        'winged_rogatina',
        'antique_spear',
        'doru',
        'retiarius',
        'sarissa',
        'triarii_spear',
        'lance',
        'billhook',
        'boar_spear',
        'glaive',
        'goedendag',
        'military_fork',
        'partisan',
        'short_spear',
        'welsh_guisarme',
        'pike',
        'ranseur',
        'ahlspiess',
        'chivalrylance',
        'guisarme'
    ]

    const axe = [
        'rhomphaia',
        'bardiche',
        'rus_axe',
        'battleaxe',
        'francisca_axe',
        'war_axe',
        'english_poleaxe',
        'french_halberd',
        'italian_poleaxe',
        'swiss_halberd',
        'broadaxe',
        'daneaxe',
        'gallowglass_axe',
        'fauchard',
        'voulge',
        'lochaberaxe',
        'concavehalberd'
    ]

    const mace = [
        'bar_mace',
        'crow_beak',
        'round_mace',
        'war_hammer',
        'hammer_spear',
        'two_handed_evening_star',
        'heavymace',
        'heavywarhammer',
        'lucernhammer',
        'morgenstern',
        'chainmorgenstern'
    ]

    const scythe = [
        'scythe'
    ]

    const shield = [
        'target',
        'buckler'
    ]

    const heavyShield = [
        'rondache',
        'hoplon'
    ]

    const woodShield = [
        'heatershield',
        'tartsche',
        'ellipticalshield',
        'roundshield',
        'pavese',
        'kiteshield'
    ]

    packs.forEach(pack => {
        forbiddenMetals.forEach(metal => {
            oneHandedSword.forEach(weapon => {
                const id = `${pack}:${metal}_${weapon}`;
                if (Item.exists(id)) {
                event.remove({ output: id });
                }
            })
            twoHandedSword.forEach(weapon => {
                const id = `${pack}:${metal}_${weapon}`;
                if (Item.exists(id)) {
                event.remove({ output: id });
                }
            })
            spear.forEach(weapon => {
                const id = `${pack}:${metal}_${weapon}`;
                if (Item.exists(id)) {
                event.remove({ output: id });
                }
            })
            mace.forEach(weapon => {
                const id = `${pack}:${metal}_${weapon}`;
                if (Item.exists(id)) {
                event.remove({ output: id });
                }
            })
            axe.forEach(weapon => {
                const id = `${pack}:${metal}_${weapon}`;
                if (Item.exists(id)) {
                event.remove({ output: id });
                }
            })
            shield.forEach(weapon => {
                const id = `${pack}:${metal}_${weapon}`;
                if (Item.exists(id)) {
                event.remove({ output: id });
                }
            })
            heavyShield.forEach(weapon => {
                const id = `${pack}:${metal}_${weapon}`;
                if (Item.exists(id)) {
                event.remove({ output: id });
                }
            })
            woodShield.forEach(weapon => {
                const id = `${pack}:${metal}_${weapon}`;
                if (Item.exists(id)) {
                event.remove({ output: id });
                }
            })
        })
    })

    packs.forEach(pack => {
            oneHandedSword.forEach(weapon => {
                const id = `${pack}:wood_${weapon}`;
                if (Item.exists(id)) {
                event.remove({ output: id });
                }
            })
            twoHandedSword.forEach(weapon => {
                const id = `${pack}:wood_${weapon}`;
                if (Item.exists(id)) {
                event.remove({ output: id });
                }
            })
            spear.forEach(weapon => {
                const id = `${pack}:wood_${weapon}`;
                if (Item.exists(id)) {
                event.remove({ output: id });
                }
            })
            mace.forEach(weapon => {
                const id = `${pack}:wood_${weapon}`;
                if (Item.exists(id)) {
                event.remove({ output: id });
                }
            })
            axe.forEach(weapon => {
                const id = `${pack}:wood_${weapon}`;
                if (Item.exists(id)) {
                event.remove({ output: id });
                }
            })
    })

    Object.entries(metals).forEach(([metal, info]) => {

        oneHandedSword.forEach(weapon => {
        packs.forEach(pack => {
            const id = `${pack}:${metal}_${weapon}`;
            
            // Validation Check: Only run if the item actually exists in the modpack
            if (Item.exists(id)) {
                event.remove({ output: id });
                event.custom({
                    type: 'tfc:anvil',
                    apply_bonus: true,
                    ingredient: {
                        tag: `c:double_ingots/${info.tfc}`
                    },
                    result: {
                        id: id,
                        count: 1
                    },
                    rules: [
                        'hit_last',
                        'bend_second_last',
                        'bend_third_last'
                    ],
                    tier: info.tier
                });
            }
        });
        });
        twoHandedSword.forEach(weapon => {
        packs.forEach(pack => {
            const id = `${pack}:${metal}_${weapon}`;
            
            // Validation Check
            if (Item.exists(id)) {
                event.remove({ output: id });
                event.custom({
                    type: 'tfc:anvil',
                    apply_bonus: true,
                    ingredient: {
                        tag: `c:double_sheets/${info.tfc}`
                    },
                    result: {
                        id: id,
                        count: 1
                    },
                    rules: [
                        'hit_last',
                        'bend_second_last',
                        'bend_third_last'
                    ],
                    tier: info.tier
                });
            }
        });
        });
        spear.forEach(weapon => {
        packs.forEach(pack => {
            const id = `${pack}:${metal}_${weapon}`;
            
            // Validation Check
            if (Item.exists(id)) {
                event.remove({ output: id });
                event.custom({
                    type: 'tfc:anvil',
                    apply_bonus: true,
                    ingredient: {
                        tag: `c:double_ingots/${info.tfc}`
                    },
                    result: {
                        id: id,
                        count: 1
                    },
                    rules: [
                        'hit_last',
                        'hit_second_last',
                        'draw_third_last'
                    ],
                    tier: info.tier
                });
            }
        });
        });
        axe.forEach(weapon => {
        packs.forEach(pack => {
            const id = `${pack}:${metal}_${weapon}`;
            
            // Validation Check
            if (Item.exists(id)) {
                event.remove({ output: id });
                event.custom({
                    type: 'tfc:anvil',
                    apply_bonus: true,
                    ingredient: {
                        tag: `c:double_sheets/${info.tfc}`
                    },
                    result: {
                        id: id,
                        count: 1
                    },
                    rules: [
                        'punch_last',
                        'hit_second_last',
                        'upset_third_last'
                    ],
                    tier: info.tier
                });
            }
        });
        });
        mace.forEach(weapon => {
        packs.forEach(pack => {
            const id = `${pack}:${metal}_${weapon}`;
            
            // Validation Check
            if (Item.exists(id)) {
                event.remove({ output: id });
                event.custom({
                    type: 'tfc:anvil',
                    apply_bonus: true,
                    ingredient: {
                        tag: `c:double_sheets/${info.tfc}`
                    },
                    result: {
                        id: id,
                        count: 1
                    },
                    rules: [
                        'hit_last',
                        'bend_not_last',
                        'shrink_not_last'
                    ],
                    tier: info.tier
                });
            }
        });
        });
        // 6. SCYTHES
    scythe.forEach(weapon => {
        packs.forEach(pack => {
            const id = `${pack}:${metal}_${weapon}`;
            
            // Validation Check
            if (Item.exists(id)) {
                event.remove({ output: id });
                event.custom({
                    type: 'tfc:anvil',
                    apply_bonus: true,
                    ingredient: {
                        tag: `c:double_sheets/${info.tfc}`
                    },
                    result: {
                        id: id,
                        count: 1
                    },
                    rules: [
                        'hit_last',
                        'draw_second_last',
                        'bend_third_last'
                    ],
                    tier: info.tier
                });
            }
        });
        });
    shield.forEach(weapon => {
        packs.forEach(pack => {
            const id = `${pack}:${metal}_${weapon}`;
            
            // Validation Check
            if (Item.exists(id)) {
                event.remove({ output: id });
                event.custom({
                    type: 'tfc:anvil',
                    apply_bonus: true,
                    ingredient: {
                        tag: `c:sheets/${info.tfc}`
                    },
                    result: {
                        id: id,
                        count: 1
                    },
                    rules: [
                        'hit_last',
                        'hit_second_last',
                        'bend_third_last'
                    ],
                    tier: info.tier
                });
            }
        });
        });
    heavyShield.forEach(weapon => {
        packs.forEach(pack => {
            const id = `${pack}:${metal}_${weapon}`;
            
            // Validation Check
            if (Item.exists(id)) {
                event.remove({ output: id });
                event.custom({
                    type: 'tfc:anvil',
                    apply_bonus: true,
                    ingredient: {
                        tag: `c:double_sheets/${info.tfc}`
                    },
                    result: {
                        id: id,
                        count: 1
                    },
                    rules: [
                        'hit_last',
                        'hit_second_last',
                        'bend_third_last'
                    ],
                    tier: info.tier
                });
            }
        });
        });
    })

})

//armor recipes
ServerEvents.recipes(event => {
    const armorHeavySteel = [
        'magistuarmory:armet',
        'magistuarmory:knight_chestplate',
        'magistuarmory:knight_leggings',
        'magistuarmory:knight_boots',
        'magistuarmory:stechhelm',
        'magistuarmory:jousting_chestplate',
        'magistuarmory:jousting_leggings',
        'magistuarmory:jousting_boots',
        'magistuarmory:sallet',
        'magistuarmory:gothic_chestplate',
        'magistuarmory:gothic_leggings',
        'magistuarmory:gothic_boots',
        'magistuarmory:greathelm',
        'magistuarmory:bascinet',
        'magistuarmory:kastenbrust_chestplate',
        'magistuarmory:kastenbrust_leggings',
        'magistuarmory:kastenbrust_boots',
        'magistuarmoryaddon:steel_puff_and_slash_chestplate',
        'magistuarmoryaddon:steel_puff_and_slash_boots',
        'magistuarmoryaddon:english_knight_chestplate',
        'magistuarmoryaddon:english_knight_boots',
        'magistuarmoryaddon:greenwich_armet',
        'magistuarmoryaddon:greenwich_chestplate',
        'magistuarmoryaddon:greenwich_boots',
        'magistuarmoryaddon:sugarloaf_helmet',
        'magistuarmoryaddon:patrician_tuher_helmet',
        'magistuarmoryaddon:close_helmet',
        'magistuarmoryaddon:heavy_brigandine_boots',
        'magistuarmoryaddon:engraved_close_helmet',
        'magistuarmoryaddon:engraved_chestplate',
        'magistuarmoryaddon:grilled_helmet',
        'magistuarmoryaddon:opened_sallet',
        'magistuarmoryaddon:alla_tedesca_chestplate',
        'magistuarmoryaddon:alla_tedesca_boots',
        'magistuarmoryaddon:peascod_chestplate',
        'magistuarmoryaddon:two_eye_slits_sallet',
        'magistuarmoryaddon:sallet_without_visor',
        'magistuarmoryaddon:german_bascinet',
        'magistuarmoryaddon:savoyard_helmet',
        'magistuarmoryaddon:pikeman_chestplate',
        'magistuarmoryaddon:milanese_armet',
        'magistuarmoryaddon:british_armet',
        'magistuarmoryaddon:avant_chestplate',
        'magistuarmoryaddon:avant_leggings',
        'magistuarmoryaddon:avant_boots',
        'magistuarmoryaddon:bicoque',
        'magistuarmoryaddon:sallet_without_neck_protection',
        'magistuarmoryaddon:cuman_captain_helmet',
        'magistuarmoryaddon:mirror_chestplate',
        'magistuarmoryaddon:early_greathelm',
        'magistuarmoryaddon:klappvisor_bascinet',
        'magistuarmoryaddon:late_bascinet',
        'magistuarmoryaddon:lobster_tailed_helmet',
        'magistuarmoryaddon:late_greathelm',
        'magistuarmoryaddon:closed_burgonet',
        'magistuarmoryaddon:heavy_cuirassier_chestplate',
        'magistuarmoryaddon:heavy_cuirassier_boots',
        'magistuarmoryaddon:late_burgonet',
        'magistuarmoryaddon:late_sallet',
        'magistuarmory:xivcenturyknight_boots',
        'magistuarmory:grand_bascinet',
        'magistuarmoryaddon:embosed_parade_burgonet',
        'magistuarmoryaddon:articulated_chestplate',
        'magistuarmoryaddon:embosed_parade_chestplate',
        'magistuarmoryaddon:embosed_parade_boots'
    ]
    const armorMediumSteel = [
        'magistuarmory:kettlehat',
        'magistuarmory:barbute',
        'magistuarmory:halfarmor_chestplate',
        'magistuarmory:norman_helmet',
        'magistuarmory:shishak',
        'magistuarmory:cuirassier_helmet',
        'magistuarmory:cuirassier_chestplate',
        'magistuarmory:face_helmet',
        'magistuarmoryaddon:sturmhaube',
        'magistuarmoryaddon:late_kettlehat',
        'magistuarmoryaddon:cabasset',
        'magistuarmoryaddon:early_cabasset',
        'magistuarmoryaddon:cuman_helmet',
        'magistuarmoryaddon:mamluk_helmet',
        'magistuarmoryaddon:light_cuman_helmet',
        'magistuarmoryaddon:morion',
        'magistuarmoryaddon:visored_kettlehat',
        'magistuarmoryaddon:cervelliere',
        'magistuarmoryaddon:closed_barbute',
        'magistuarmoryaddon:kulah_khud',
        'magistuarmoryaddon:chapel',
        'magistuarmoryaddon:tablet_helmet',
        'magistuarmoryaddon:burgundian_kettlehat',
        'magistuarmoryaddon:light_burgonet',
        'slavicarmory:erikhonka',
        'slavicarmory:late_phrygian_helmet',
        'slavicarmory:varangian_guard_helmet',
        'slavicarmory:shater_helmet',
        'slavicarmory:raikovec_helmet',
        'slavicarmory:nikolskoe_helmet',
        'slavicarmory:andreevski_helmet',
        'slavicarmory:varangian_helmet',
        'slavicarmory:eastern_kettlehat',
        'slavicarmory:gnezdovo_helmet',
        'slavicarmory:ozernoe_helmet',
        'slavicarmory:tagancha_helmet',
        'slavicarmory:bulgar_helmet'
    ]
    const armorIron = [
        'antiquelegacy:gallea',
        'antiquelegacy:iron_ridge_helmet',
        'antiquelegacy:iron_intercisa',
        'antiquelegacy:iron_melos',
        'antiquelegacy:iron_niederbieber_helmet',
        'antiquelegacy:iron_pilos',
        'antiquelegacy:musculata',
        'antiquelegacy:segmentata',
        'antiquelegacy:iron_roman_greaves',
        'antiquelegacy:agen_port_helmet',
        'antiquelegacy:sava_helmet',
        'antiquelegacy:heddernheim_helmet',
        'antiquelegacy:iron_thorax'
    ]
    const armorBronze = [
        'antiquelegacy:attic_helmet',
        'antiquelegacy:bell_cuirass',
        'antiquelegacy:beotian_helmet',
        'antiquelegacy:bronze_ridge_helmet',
        'antiquelegacy:bronze_intercisa',
        'antiquelegacy:bronze_melos',
        'antiquelegacy:bronze_muscle_cuirass',
        'antiquelegacy:bronze_niederbieber_helmet',
        'antiquelegacy:bronze_phrygian_helmet',
        'antiquelegacy:bronze_pilos_closet',
        'antiquelegacy:bronze_pilos',
        'antiquelegacy:roman_parade_helmet',
        'antiquelegacy:bronze_apulo_corinthian_helmet',
        'antiquelegacy:chalcidian_helmet',
        'antiquelegacy:corinthian_helmet',
        'antiquelegacy:greek_greaves',
        'antiquelegacy:illirian_helmet',
        'antiquelegacy:murmillo_helmet',
        'antiquelegacy:open_attic_helmet',
        'antiquelegacy:provocator_helmet',
        'antiquelegacy:secutor_helmet',
        'antiquelegacy:thracian_helmet',
        'antiquelegacy:cardiophylax',
        'antiquelegacy:bronze_roman_greaves',
        'antiquelegacy:celtic_montefortino_helmet',
        'antiquelegacy:la_gorge_meillet',
        'antiquelegacy:waterloo_helmet',
        'antiquelegacy:scythian_attic_helmet',
        'antiquelegacy:kuban_helmet'
    ]
    const armorGold = [
        'magistuarmory:crown_decoration',
        'magistuarmory:minicrown_decoration',
        'antiquelegacy:golden_ridge_helmet'
    ]
    event.remove({ output: 'armorSteel' })
    event.remove({ output: 'magistuarmory:brigandine_chestplate' })

    armorHeavySteel.forEach(id => {
        //const id = `${armorHeavySteel}`;
            
        // Validation Check
        if (Item.exists(id)) {
            event.remove({ output: id });
            event.custom({
                type: 'tfc:anvil',
                apply_bonus: true,
                ingredient: {
                    tag: `c:heavy_sheets/steel`
                },
                result: {
                    id: id,
                    count: 1
                },
                rules: [
                    'hit_last',
                    'bend_not_last',
                    'shrink_not_last'
                ],
                tier: 4
            });
        }
    });
    armorMediumSteel.forEach(id => {
        //const id = `${armorHeavySteel}`;
            
        // Validation Check
        if (Item.exists(id)) {
            event.remove({ output: id });
            event.custom({
                type: 'tfc:anvil',
                apply_bonus: true,
                ingredient: {
                    tag: `c:double_sheets/steel`
                },
                result: {
                    id: id,
                    count: 1
                },
                rules: [
                    'hit_last',
                    'bend_not_last',
                    'shrink_not_last'
                ],
                tier: 4
            });
        }
    });
    armorBronze.forEach(id => {
        //const id = `${armorHeavySteel}`;
            
        // Validation Check
        if (Item.exists(id)) {
            event.remove({ output: id });
            event.custom({
                type: 'tfc:anvil',
                apply_bonus: true,
                ingredient: {
                    tag: `tfc:double_sheets/any_bronze`
                },
                result: {
                    id: id,
                    count: 1
                },
                rules: [
                    'hit_last',
                    'bend_not_last',
                    'shrink_not_last'
                ],
                tier: 2
            });
        }
    });
    armorGold.forEach(id => {
        //const id = `${armorHeavySteel}`;
            
        // Validation Check
        if (Item.exists(id)) {
            event.remove({ output: id });
            event.custom({
                type: 'tfc:anvil',
                apply_bonus: true,
                ingredient: {
                    tag: `c:double_sheets/gold`
                },
                result: {
                    id: id,
                    count: 1
                },
                rules: [
                    'hit_last',
                    'bend_not_last',
                    'shrink_not_last'
                ],
                tier: 2
            });
        }
    });
    armorIron.forEach(id => {
        //const id = `${armorHeavySteel}`;
            
        // Validation Check
        if (Item.exists(id)) {
            event.remove({ output: id });
            event.custom({
                type: 'tfc:anvil',
                apply_bonus: true,
                ingredient: {
                    tag: `c:double_sheets/wrought_iron`
                },
                result: {
                    id: id,
                    count: 1
                },
                rules: [
                    'hit_last',
                    'bend_not_last',
                    'shrink_not_last'
                ],
                tier: 3
            });
        }
    });

    event.shaped(
        Item.of('magistuarmory:brigandine_chestplate', 1), // arg 1: output
        [
        'B B',
        'BAB', // arg 2: the shape (array of strings)
        'BBB'
        ],
        {
        A: 'magistuarmory:halfarmor_chestplate',
        B: 'minecraft:leather'
        }
    )
})

ServerEvents.recipes(event => {
    event.remove({ output: 'antiquelegacy:eagle_standard' })
    event.remove({ output: 'magistuarmory:blacksmith_hammer' })
    event.remove({ output: 'magistuarmory:barbedclub' })
    event.remove({ output: 'magistuarmory:pitchfork' })
    event.remove({ output: 'magistuarmory:messer_sword' })
    event.remove({ output: 'magistuarmory:longbow' })
    event.remove({ output: 'magistuarmory:heavy_crossbow' })
    event.remove({ output: 'antiquelegacy:iron_chainmail' })
    event.remove({ output: 'magistuarmory:steel_chainmail' })
    event.remove({ output: 'magistuarmoryaddon:golden_necklace_decoration' })
    event.remove({ output: 'magistuarmoryaddon:golden_cross_necklace_decoration' })
    event.remove({ output: 'magistuarmoryaddon:silver_necklace_decoration' })
    event.remove({ output: 'magistuarmoryaddon:silver_cross_necklace_decoration' })
    event.remove({ output: 'slavicarmory:rus_chainmail_hood_decoration' })
    event.remove({ output: 'magistuarmoryaddon:chainmail_hood_decoration' })
    event.remove({ output: 'magistuarmoryaddon:heavy_brigandine_chestplate' })
    event.remove({ output: 'magistuarmoryaddon:splint_chestplate' })
    event.remove({ output: 'magistuarmoryaddon:heavy_brigandine_leggings' })
    event.remove({ output: 'magistuarmoryaddon:lion_helmet' })
    event.remove({ output: 'magistuarmory:xivcenturyknight_chestplate' })
    event.remove({ output: 'magistuarmory:xivcenturyknight_leggings' })
    event.remove({ output: 'magistuarmory:wingedhussar_chestplate' })
    event.remove({ output: 'magistuarmoryaddon:xiii_century_knight_chestplate' })
    event.remove({ output: 'antiquelegacy:scale_thorax' })
    event.remove({ output: 'antiquelegacy:hamata_optio' })
    event.remove({ output: 'antiquelegacy:hamata' })
    event.remove({ output: 'magistuarmoryaddon:mirror_boots' })
    event.remove({ output: 'magistuarmory:darkening_template' })
    event.remove({ output: 'magistuarmory:gilding_template' })
    event.remove({ output: 'magistuarmoryaddon:fully_gilding_template' })
    
    event.remove({ output: 'magistuarmory:steel_ingot' })
    event.remove({ output: 'magistuarmory:steel_ring' })
    event.remove({ output: 'magistuarmory:steel_plate' })
    event.remove({ output: 'magistuarmory:steel_chain' })
    event.remove({ output: 'antiquelegacy:bronze_plate' })
    event.remove({ output: 'antiquelegacy:bronze_ingot' })
    event.remove({ output: 'antiquelegacy:tin_nugget' })
    event.remove({ output: 'antiquelegacy:tin_ingot' })
    event.remove({ output: 'antiquelegacy:bronze_mixture' })
    event.remove({ output: 'antiquelegacy:copper_nugget' })
    event.remove({ id: 'antiquelegacy:copper_ingot' })
    event.replaceInput({}, 'antiquelegacy:bronze_plate', '#tfc:sheets/any_bronze')
    event.replaceInput({}, 'antiquelegacy:iron_plate', '#c:sheets/wrought_iron')
    event.replaceInput({}, 'magistuarmory:steel_plate', '#c:sheets/steel')
})

ServerEvents.recipes(event => {
    event.recipes.tfc.anvil(
        'magistuarmory:blacksmith_hammer',
        { tag: 'c:double_ingots/steel'},
        [
            'hit_last',
            'bend_not_last',
            'shrink_not_last'
        ]
    )
    .tier(4)
    .applyBonus()
})

ServerEvents.recipes(event => {
    event.recipes.tfc.anvil(
        'magistuarmory:pitchfork',
        { tag: 'c:double_ingots/steel'},
        [
            'hit_last',
            'hit_second_last',
            'draw_third_last'
        ]
    )
    .tier(4)
    .applyBonus()
})

ServerEvents.recipes(event => {
    event.recipes.tfc.anvil(
        'magistuarmory:messer_sword',
        { tag: 'c:double_ingots/wrought_iron'},
        [
            'hit_last',
            'bend_second_last',
            'bend_third_last'
        ]
    )
    .tier(3)
    .applyBonus()
})

ServerEvents.recipes(event => {
    event.recipes.tfc.anvil(
        'antiquelegacy:eagle_standard',
        { tag: 'c:double_ingots/bronze'},
        [
            'hit_last',
            'bend_second_last',
            'bend_third_last'
        ]
    )
    .tier(2)
    .applyBonus()
})

ServerEvents.recipes(event => {

    event.shaped(
        Item.of('magistuarmory:longbow', 1), // arg 1: output
        [
        'A B',
        ' CD', // arg 2: the shape (array of strings)
        'BD '
        ],
        {
        A: {tag: 'c:string'},
        B: 'magistuarmory:hilt',  //arg 3: the mapping object
        C: 'tfc_items:bowlimb',
        D: 'tfc_items:bowchord'
        }
    )
    event.shaped(
        Item.of('magistuarmory:heavy_crossbow', 1), // arg 1: output
        [
        'AEB',
        'ECD', // arg 2: the shape (array of strings)
        'BDE'
        ],
        {
        A: {tag: 'c:rings'},
        B: 'tfc_items:leather_strap',  //arg 3: the mapping object
        C: 'tfc_items:bowlimb',
        D: 'tfc_items:bowchord',
        E: 'tfc:metal/rod/steel'
        }
    )

    event.custom({
        type: 'tfc:anvil',
        apply_bonus: false,

        ingredient: {
            tag: 'c:sheets/bronze'
        },

        result: {
            id: 'antiquelegacy:small_bronze_plate',
            count: 16
        },

        rules: [
            'hit_last',
            'hit_second_last',
            'hit_third_last'
        ],

        tier: 2
    })
    event.custom({
        type: 'tfc:anvil',
        apply_bonus: false,

        ingredient: {
            tag: 'c:sheets/wrought_iron'
        },

        result: {
            id: 'antiquelegacy:small_iron_plate',
            count: 16
        },

        rules: [
            'hit_last',
            'hit_second_last',
            'hit_third_last'
        ],

        tier: 3
    })
    event.custom({
        type: 'tfc:anvil',
        apply_bonus: false,

        ingredient: {
            tag: 'c:sheets/steel'
        },

        result: {
            id: 'magistuarmory:small_steel_plate',
            count: 16
        },

        rules: [
            'hit_last',
            'hit_second_last',
            'hit_third_last'
        ],

        tier: 4
    })
    event.shaped(
        Item.of('magistuarmory:xivcenturyknight_chestplate', 1), // arg 1: output
        [
        'A A',
        'ABA', // arg 2: the shape (array of strings)
        'AAA'
        ],
        {
        A: 'magistuarmory:steel_chainmail',
        B: 'magistuarmory:halfarmor_chestplate'
        }
    )
    event.shaped(
        Item.of('magistuarmory:xivcenturyknight_leggings', 1), // arg 1: output
        [
        ' B ',
        'A A', // arg 2: the shape (array of strings)
        '   '
        ],
        {
        A: 'tfc:metal/sheet/steel',
        B: 'magistuarmory:chainmail_leggings'
        }
    )
    event.shaped(
        Item.of('magistuarmoryaddon:heavy_brigandine_chestplate', 1), // arg 1: output
        [
        '   ',
        'ABA', // arg 2: the shape (array of strings)
        'AAA'
        ],
        {
        A: 'tfc:metal/sheet/steel',
        B: 'magistuarmory:brigandine_chestplate'
        }
    )
    event.shaped(
        Item.of('magistuarmoryaddon:splint_chestplate', 1), // arg 1: output
        [
        'A A',
        'DBD', // arg 2: the shape (array of strings)
        'CDC'
        ],
        {
        A: 'tfc:metal/sheet/steel',
        B: 'magistuarmory:brigandine_chestplate',
        C: 'magistuarmory:small_steel_plate',
        D: 'minecraft:leather'
        }
    )
    event.shaped(
        Item.of('magistuarmoryaddon:heavy_brigandine_leggings', 1), // arg 1: output
        [
        'BBB',
        'A A', // arg 2: the shape (array of strings)
        'A A'
        ],
        {
        A: 'tfc:metal/sheet/steel',
        B: 'minecraft:leather'
        }
    )
    event.shaped(
        Item.of('magistuarmoryaddon:lion_helmet', 1), // arg 1: output
        [
        '   ',
        'ABA', // arg 2: the shape (array of strings)
        'C C'
        ],
        {
        A: 'tfc:metal/ingot/gold',
        B: 'magistuarmory:barbute',
        C: 'tfc:metal/sheet/steel'
        }
    )
    event.shaped(
        Item.of('magistuarmory:wingedhussar_chestplate', 1), // arg 1: output
        [
        'A A',
        'ABA', // arg 2: the shape (array of strings)
        'A A'
        ],
        {
        A: '#c:feathers',
        B: 'magistuarmory:halfarmor_chestplate'
        }
    )
    event.smithing(
        'slavicarmory:gilded_erikhonka',                     // arg 1: output
        'magistuarmory:gilding_template', // arg 2: the smithing template
        'slavicarmory:erikhonka',                          // arg 3: the item to be upgraded
        '#c:ingots/gold'                            // arg 4: the upgrade item
    )
    event.smithing(
        'slavicarmory:gilded_late_phrygian_helmet',                     // arg 1: output
        'magistuarmory:gilding_template', // arg 2: the smithing template
        'slavicarmory:late_phrygian_helmet',                          // arg 3: the item to be upgraded
        '#c:ingots/gold'                            // arg 4: the upgrade item
    )
    event.smithing(
        'slavicarmory:gilded_byzantine_lamellar_chestplate',                     // arg 1: output
        'magistuarmory:gilding_template', // arg 2: the smithing template
        'slavicarmory:byzantine_lamellar_chestplate',                          // arg 3: the item to be upgraded
        '#c:ingots/gold'                            // arg 4: the upgrade item
    )
    event.smithing(
        'slavicarmory:gilded_byzantine_scale_chestplate',                     // arg 1: output
        'magistuarmory:gilding_template', // arg 2: the smithing template
        'slavicarmory:byzantine_scale_chestplate',                          // arg 3: the item to be upgraded
        '#c:ingots/gold'                            // arg 4: the upgrade item
    )
    event.smithing(
        'slavicarmory:gilded_yushman_chestplate',                     // arg 1: output
        'magistuarmory:gilding_template', // arg 2: the smithing template
        'slavicarmory:yushman_chestplate',                          // arg 3: the item to be upgraded
        '#c:ingots/gold'                            // arg 4: the upgrade item
    )
    event.smithing(
        'slavicarmory:gilded_shater_helmet',                     // arg 1: output
        'magistuarmory:gilding_template', // arg 2: the smithing template
        'slavicarmory:shater_helmet',                          // arg 3: the item to be upgraded
        '#c:ingots/gold'                            // arg 4: the upgrade item
    )
    event.smithing(
        'slavicarmory:gilded_raikovec_helmet',                     // arg 1: output
        'magistuarmory:gilding_template', // arg 2: the smithing template
        'slavicarmory:raikovec_helmet',                          // arg 3: the item to be upgraded
        '#c:ingots/gold'                            // arg 4: the upgrade item
    )
    event.smithing(
        'slavicarmory:gilded_nikolskoe_helmet',                     // arg 1: output
        'magistuarmory:gilding_template', // arg 2: the smithing template
        'slavicarmory:nikolskoe_helmet',                          // arg 3: the item to be upgraded
        '#c:ingots/gold'                            // arg 4: the upgrade item
    )
    event.smithing(
        'slavicarmory:gilded_andreevski_helmet',                     // arg 1: output
        'magistuarmory:gilding_template', // arg 2: the smithing template
        'slavicarmory:andreevski_helmet',                          // arg 3: the item to be upgraded
        '#c:ingots/gold'                            // arg 4: the upgrade item
    )
    event.smithing(
        'slavicarmory:gilded_eastern_kettlehat',                     // arg 1: output
        'magistuarmory:gilding_template', // arg 2: the smithing template
        'slavicarmory:eastern_kettlehat',                          // arg 3: the item to be upgraded
        '#c:ingots/gold'                            // arg 4: the upgrade item
    )
    event.smithing(
        'slavicarmory:gilded_gnezdovo_helmet',                     // arg 1: output
        'magistuarmory:gilding_template', // arg 2: the smithing template
        'slavicarmory:gnezdovo_helmet',                          // arg 3: the item to be upgraded
        '#c:ingots/gold'                            // arg 4: the upgrade item
    )
    event.smithing(
        'slavicarmory:gilded_tagancha_helmet',                     // arg 1: output
        'magistuarmory:gilding_template', // arg 2: the smithing template
        'slavicarmory:tagancha_helmet',                          // arg 3: the item to be upgraded
        '#c:ingots/gold'                            // arg 4: the upgrade item
    )
    event.smithing(
        'slavicarmory:gilded_bahteretz_chestplate',                     // arg 1: output
        'magistuarmory:gilding_template', // arg 2: the smithing template
        'slavicarmory:bahteretz_chestplate',                          // arg 3: the item to be upgraded
        '#c:ingots/gold'                            // arg 4: the upgrade item
    )
    event.smithing(
        'slavicarmory:gilded_lamellar_mail_chestplate',                     // arg 1: output
        'magistuarmory:gilding_template', // arg 2: the smithing template
        'slavicarmory:lamellar_mail_chestplate',                          // arg 3: the item to be upgraded
        '#c:ingots/gold'                            // arg 4: the upgrade item
    )
    event.smithing(
        'slavicarmory:gilded_rus_scale_chestplate',                     // arg 1: output
        'magistuarmory:gilding_template', // arg 2: the smithing template
        'slavicarmory:rus_scale_chestplate',                          // arg 3: the item to be upgraded
        '#c:ingots/gold'                            // arg 4: the upgrade item
    )
    event.smithing(
        'slavicarmory:gilded_rus_scale_boots',                     // arg 1: output
        'magistuarmory:gilding_template', // arg 2: the smithing template
        'slavicarmory:rus_scale_boots',                          // arg 3: the item to be upgraded
        '#c:ingots/gold'                            // arg 4: the upgrade item
    )
    event.smithing(
        'slavicarmory:gilded_rus_heavy_lamellar_chestplate',                     // arg 1: output
        'magistuarmory:gilding_template', // arg 2: the smithing template
        'slavicarmory:rus_heavy_lamellar_chestplate',                          // arg 3: the item to be upgraded
        '#c:ingots/gold'                            // arg 4: the upgrade item
    )
    event.smithing(
        'slavicarmory:gilded_rus_heavy_lamellar_boots',                     // arg 1: output
        'magistuarmory:gilding_template', // arg 2: the smithing template
        'slavicarmory:rus_heavy_lamellar_boots',                          // arg 3: the item to be upgraded
        '#c:ingots/gold'                            // arg 4: the upgrade item
    )
    event.shaped(
        Item.of('slavicarmory:byzantine_lamellar_chestplate', 1), // arg 1: output
        [
        'A A',
        'AAA', // arg 2: the shape (array of strings)
        'BAB'
        ],
        {
        A: 'magistuarmory:lamellar_rows',
        B: 'magistuarmory:woolen_fabric'
        }
    )
    event.shaped(
        Item.of('slavicarmory:byzantine_scale_chestplate', 1), // arg 1: output
        [
        'A A',
        'BAB', // arg 2: the shape (array of strings)
        'BAB'
        ],
        {
        A: 'magistuarmory:lamellar_rows',
        B: 'magistuarmory:woolen_fabric'
        }
    )
    event.shaped(
        Item.of('slavicarmory:yushman_chestplate', 1), // arg 1: output
        [
        'B B',
        'BAB', // arg 2: the shape (array of strings)
        'BBB'
        ],
        {
        A: 'magistuarmory:chainmail_chestplate',
        B: 'magistuarmory:woolen_fabric'
        }
    )
    event.shaped(
        Item.of('slavicarmory:rus_chainmail_coif', 1), // arg 1: output
        [
        'AAA',
        'A A', // arg 2: the shape (array of strings)
        '   '
        ],
        {
        A: 'magistuarmory:steel_chainmail'
        }
    )
    event.shaped(
        Item.of('slavicarmory:rus_chainmail_chestplate', 1), // arg 1: output
        [
        'A A',
        'AAA', // arg 2: the shape (array of strings)
        'AAA'
        ],
        {
        A: 'magistuarmory:steel_chainmail'
        }
    )
    event.shaped(
        Item.of('slavicarmory:rus_chainmail_leggings', 1), // arg 1: output
        [
        'AAA',
        'A A', // arg 2: the shape (array of strings)
        'A A'
        ],
        {
        A: 'magistuarmory:steel_chainmail'
        }
    )
    event.shaped(
        Item.of('slavicarmory:rus_chainmail_boots', 1), // arg 1: output
        [
        '   ',
        'A A', // arg 2: the shape (array of strings)
        'B B'
        ],
        {
        A: 'magistuarmory:steel_chainmail',
        B: 'minecraft:leather'
        }
    )
    event.shaped(
        Item.of('slavicarmory:bahteretz_boots', 1), // arg 1: output
        [
        '   ',
        'A A', // arg 2: the shape (array of strings)
        'B B'
        ],
        {
        A: 'magistuarmory:steel_chainmail',
        B: 'minecraft:leather'
        }
    )
    event.shaped(
        Item.of('slavicarmory:bahteretz_chestplate', 1), // arg 1: output
        [
        'A A',
        'BBB', // arg 2: the shape (array of strings)
        'BBB'
        ],
        {
        A: 'magistuarmory:steel_chainmail',
        B: 'magistuarmory:lamellar_rows'
        }
    )
    event.shaped(
        Item.of('slavicarmory:kuyak_chestplate', 1), // arg 1: output
        [
        'A A',
        'BBB', // arg 2: the shape (array of strings)
        'BBB'
        ],
        {
        A: 'magistuarmory:steel_chainmail',
        B: 'magistuarmory:lamellar_rows'
        }
    )
    event.shaped(
        Item.of('slavicarmory:lamellar_mail_chestplate', 1), // arg 1: output
        [
        'A A',
        'BBB', // arg 2: the shape (array of strings)
        'BBB'
        ],
        {
        A: 'magistuarmory:steel_chainmail',
        B: 'magistuarmory:lamellar_rows'
        }
    )
    event.shaped(
        Item.of('slavicarmory:kuyak_breastplate', 1), // arg 1: output
        [
        'A A',
        'AAA', // arg 2: the shape (array of strings)
        '   '
        ],
        {
        A: 'magistuarmory:lamellar_rows'
        }
    )
    event.shaped(
        Item.of('slavicarmory:lamellar_mail_boots', 1), // arg 1: output
        [
        'A A',
        'B B', // arg 2: the shape (array of strings)
        '   '
        ],
        {
        A: 'magistuarmory:lamellar_rows',
        B: 'minecraft:leather'
        }
    )
    event.shaped(
        Item.of('slavicarmory:rus_scale_chestplate', 1), // arg 1: output
        [
        'A A',
        'AAA', // arg 2: the shape (array of strings)
        'AAA'
        ],
        {
        A: 'magistuarmory:lamellar_rows'
        }
    )
    event.shaped(
        Item.of('slavicarmory:rus_heavy_lamellar_chestplate', 1), // arg 1: output
        [
        'A A',
        'AAA', // arg 2: the shape (array of strings)
        'AAA'
        ],
        {
        A: 'magistuarmory:lamellar_rows'
        }
    )
    event.shaped(
        Item.of('slavicarmory:rus_scale_boots', 1), // arg 1: output
        [
        'A A',
        'B B', // arg 2: the shape (array of strings)
        '   '
        ],
        {
        A: 'magistuarmory:lamellar_rows',
        B: 'minecraft:leather'
        }
    )
    event.shaped(
        Item.of('slavicarmory:rus_heavy_lamellar_boots', 1), // arg 1: output
        [
        'A A',
        'A A', // arg 2: the shape (array of strings)
        'B B'
        ],
        {
        A: 'magistuarmory:lamellar_rows',
        B: 'minecraft:leather'
        }
    )
    event.shaped(
        Item.of('antiquelegacy:hamata', 1), // arg 1: output
        [
        'B B',
        'AAA', // arg 2: the shape (array of strings)
        'CCC'
        ],
        {
        A: 'antiquelegacy:iron_chainmail',
        B: 'minecraft:leather',
        C: 'antiquelegacy:small_bronze_plate'
        }
    )
    event.shaped(
        Item.of('antiquelegacy:hamata_optio', 1), // arg 1: output
        [
        'B B',
        'AAA', // arg 2: the shape (array of strings)
        'CCC'
        ],
        {
        A: 'antiquelegacy:iron_chainmail',
        B: 'magistuarmory:woolen_fabric',
        C: 'antiquelegacy:small_bronze_plate'
        }
    )
    event.shaped(
        Item.of('antiquelegacy:scale_thorax', 1), // arg 1: output
        [
        'B B',
        'AAA', // arg 2: the shape (array of strings)
        'CCC'
        ],
        {
        A: 'antiquelegacy:bronze_lamellar_rows',
        B: 'antiquelegacy:small_bronze_plate',
        C: 'minecraft:leather'
        }
    )
    event.shaped(
        Item.of('magistuarmoryaddon:xiii_century_knight_chestplate', 1), // arg 1: output
        [
        '   ',
        'BAB', // arg 2: the shape (array of strings)
        '   '
        ],
        {
        A: 'magistuarmory:chainmail_chestplate',
        B: 'tfc:metal/sheet/steel'
        }
    )
    event.shaped(
        Item.of('magistuarmoryaddon:mirror_boots', 1), // arg 1: output
        [
        'C C',
        'B B', // arg 2: the shape (array of strings)
        'A A'
        ],
        {
        A: 'minecraft:leather',
        B: 'tfc:metal/sheet/steel',
        C: 'magistuarmory:lamellar_rows'
        }
    )
    event.shaped(
        Item.of('magistuarmoryaddon:straw_hat', 1), // arg 1: output
        [
        '   ',
        ' A ', // arg 2: the shape (array of strings)
        'AAA'
        ],
        {
        A: 'tfc:straw'
        }
    )
    event.shaped(
        Item.of('slavicarmory:kaftan', 1), // arg 1: output
        [
        'A A',
        'AAA', // arg 2: the shape (array of strings)
        'AAA'
        ],
        {
        A: 'magistuarmory:woolen_fabric'
        }
    )
    event.shaped(
        Item.of('slavicarmory:rus_gambeson', 1), // arg 1: output
        [
        'A A',
        'AAA', // arg 2: the shape (array of strings)
        'AAA'
        ],
        {
        A: 'magistuarmory:woolen_fabric'
        }
    )
    event.shaped(
        Item.of('slavicarmory:shapka', 1), // arg 1: output
        [
        '   ',
        'AAA', // arg 2: the shape (array of strings)
        'AAA'
        ],
        {
        A: 'magistuarmory:woolen_fabric'
        }
    )
    event.shaped(
        Item.of('slavicarmory:kaftan_boots', 1), // arg 1: output
        [
        '   ',
        'A A', // arg 2: the shape (array of strings)
        'B B'
        ],
        {
        A: 'magistuarmory:woolen_fabric',
        B: 'minecraft:leather'
        }
    )
    event.shaped(
        Item.of('slavicarmory:rus_gambeson_boots', 1), // arg 1: output
        [
        '   ',
        'A A', // arg 2: the shape (array of strings)
        'B B'
        ],
        {
        A: 'magistuarmory:woolen_fabric',
        B: 'minecraft:leather'
        }
    )


    event.recipes.tfc.welding(
        'magistuarmory:darkening_template',
        'magistuarmory:small_steel_plate',
        '#c:dyes/black'
    )
    event.recipes.tfc.welding(
        'magistuarmory:gilding_template',
        'magistuarmory:small_steel_plate',
        '#c:ingots/gold'
    )
    event.recipes.tfc.welding(
        'magistuarmoryaddon:fully_gilding_template',
        'magistuarmory:gilding_template',
        '#c:sheets/gold'
    )
    event.shaped(
        Item.of('antiquelegacy:iron_chainmail', 1), // arg 1: output
        [
        'AAA',
        'AAA', // arg 2: the shape (array of strings)
        'AAA'
        ],
        {
        A: {tag: 'c:rings/cast_iron'}
        }
    )
    event.shaped(
        Item.of('antiquelegacy:iron_chainmail', 1), // arg 1: output
        [
        'AAA',
        'AAA', // arg 2: the shape (array of strings)
        'AAA'
        ],
        {
        A: {tag: 'c:rings/wrought_iron'}
        }
    )
    event.shaped(
        Item.of('magistuarmory:steel_chainmail', 1), // arg 1: output
        [
        'AAA',
        'AAA', // arg 2: the shape (array of strings)
        'AAA'
        ],
        {
        A: {tag: 'c:rings/steel'}
        }
    )
    /*
    event.shaped(
        Item.of('magistuarmory:barding', 1), // arg 1: output
        [
        '   ',
        'ABA', // arg 2: the shape (array of strings)
        'CCC'
        ],
        {
        A: 'tfc:jute_fiber',
        B: 'minecraft:leather_horse_armor',
        C: 'tfc:metal/sheet/steel'
        }
    )
        */
    event.shaped(
        Item.of('magistuarmory:chainmail_horse_armor', 1), // arg 1: output
        [
        '   ',
        'ABA', // arg 2: the shape (array of strings)
        'CCC'
        ],
        {
        A: 'tfc:jute_fiber',
        B: 'minecraft:leather_horse_armor',
        C: 'magistuarmory:steel_chainmail'
        }
    )
    event.shapeless(
      Item.of('magistuarmoryaddon:golden_necklace_decoration', 1), // arg 1: output
        [
        'tfc_items:gold_wire'
        ]
    )
    event.shapeless(
      Item.of('magistuarmoryaddon:golden_cross_necklace_decoration', 1), // arg 1: output
        [
        'magistuarmoryaddon:golden_necklace_decoration',
        '2x tfc:metal/rod/gold'
        ]
    )
    event.shapeless(
      Item.of('magistuarmoryaddon:silver_necklace_decoration', 1), // arg 1: output
        [
        'tfc_items:silver_wire'
        ]
    )
    event.shapeless(
      Item.of('magistuarmoryaddon:silver_cross_necklace_decoration', 1), // arg 1: output
        [
        'magistuarmoryaddon:silver_necklace_decoration',
        '2x tfc:metal/rod/silver'
        ]
    )
    event.custom({
        type: 'tfc:anvil',
        apply_bonus: false,

        ingredient: {
            tag: 'c:sheets/gold'
        },

        result: {
            id: 'magistuarmory:crown_decoration',
            count: 1
        },

        rules: [
            'hit_last',
            'hit_second_last',
            'draw_third_last'
        ],

        tier: 2
    })
    event.custom({
        type: 'tfc:anvil',
        apply_bonus: false,

        ingredient: {
            tag: 'c:sheets/gold'
        },

        result: {
            id: 'magistuarmory:minicrown_decoration',
            count: 1
        },

        rules: [
            'hit_last',
            'hit_second_last',
            'draw_third_last'
        ],

        tier: 2
    })
    event.shaped(
        Item.of('magistuarmory:flowercrown_decoration', 1), // arg 1: output
        [
        ' A ',
        'A A', // arg 2: the shape (array of strings)
        ' A '
        ],
        {
        A: {tag: 'tfc:plants'}
        }
    )
    event.shaped(
        Item.of('antiquelegacy:laurel_wreath_decoration', 1), // arg 1: output
        [
        '   ',
        'A A', // arg 2: the shape (array of strings)
        ' A '
        ],
        {
        A: {tag: 'tfc:plants'}
        }
    )
    event.shaped(
        Item.of('antiquelegacy:laurel_wreath_decoration', 1), // arg 1: output
        [
        '   ',
        'A A', // arg 2: the shape (array of strings)
        ' A '
        ],
        {
        A: {tag: 'c:flowers'}
        }
    )
    event.shaped(
        Item.of('slavicarmory:varangian_bra_decoration', 1), // arg 1: output
        [
        'A A',
        'ABA', // arg 2: the shape (array of strings)
        '   '
        ],
        {
        A: {tag: 'magistuarmory:woolen_fabrics'},
        B: {tag: 'c:dyes/red'}
        }
    )
    event.shaped(
        Item.of('slavicarmory:belt_decoration', 1), // arg 1: output
        [
        '   ',
        'ABA', // arg 2: the shape (array of strings)
        '   '
        ],
        {
        A: {tag: 'magistuarmory:woolen_fabrics'},
        B: {tag: 'c:dyes/red'}
        }
    )
    event.shapeless(
      Item.of('magistuarmory:lily_decoration', 1), // arg 1: output
        [
        'minecraft:lily_of_the_valley'
        ]
    )
    event.shapeless(
      Item.of('magistuarmory:lily_decoration', 1), // arg 1: output
        [
        'tfc:plant/lily_of_the_valley'
        ]
    )
    event.shapeless(
      Item.of('slavicarmory:rus_chainmail_hood_decoration', 1), // arg 1: output
        [
        'slavicarmory:rus_chainmail_coif'
        ]
    )
    event.shapeless(
      Item.of('magistuarmoryaddon:chainmail_hood_decoration', 1), // arg 1: output
        [
        'magistuarmory:chainmail_helmet'
        ]
    )
    const smallSteel = [
    'magistuarmory:ecranche_decoration',
    'magistuarmory:rondel_decoration',
    'magistuarmoryaddon:shoulder_pads_decoration',
    'magistuarmoryaddon:heavy_shoulder_pad_decoration',
    'magistuarmoryaddon:rivited_gauntlets_decoration',
    'magistuarmoryaddon:square_besagews_decoration',
    'magistuarmoryaddon:codpiece_decoration',
    'magistuarmoryaddon:gorget_decoration'
    ];

    smallSteel.forEach(id => {
    
        if (Item.exists(id)) {
        event.remove({ output: id });
            event.custom({
                type: 'tfc:anvil',
                apply_bonus: true,
                ingredient: {
                    tag: 'magistuarmory:small_plates/steel'
                },
                result: {
                    id: id,
                    count: 1
                },
                rules: [
                    'hit_last',
                    'hit_second_last',
                    'draw_third_last'
                ],
                tier: 4
            });
        }
    });
    const sheetsSteel = [
    'magistuarmoryaddon:steel_skirt_decoration',
    'magistuarmoryaddon:plackart_decoration',
    'magistuarmoryaddon:articulated_shoulder_defenses_decoration',
    'magistuarmoryaddon:articulated_pauldrons_decoration',
    'magistuarmoryaddon:dragon_shoulder_pads_decoration'
    ];

    sheetsSteel.forEach(id => {
    
        if (Item.exists(id)) {
        event.remove({ output: id });
            event.custom({
                type: 'tfc:anvil',
                apply_bonus: true,
                ingredient: {
                    tag: 'c:sheets/steel'
                },
                result: {
                    id: id,
                    count: 1
                },
                rules: [
                    'hit_last',
                    'hit_second_last',
                    'draw_third_last'
                ],
                tier: 4
            });
        }
    });
    const smallBronze = [
    'antiquelegacy:bronze_horns_decoration',
    'antiquelegacy:bronze_small_wings_decoration',
    'antiquelegacy:left_gladiator_shoulder_pad_decoration',
    'antiquelegacy:right_gladiator_shoulder_pad_decoration',
    'antiquelegacy:bronze_left_hand_manika_decoration',
    'antiquelegacy:bronze_right_hand_manika_decoration'
    ];

    smallBronze.forEach(id => {
    
        if (Item.exists(id)) {
        event.remove({ output: id });
            event.custom({
                type: 'tfc:anvil',
                apply_bonus: true,
                ingredient: {
                    item: 'antiquelegacy:small_bronze_plate'
                },
                result: {
                    id: id,
                    count: 1
                },
                rules: [
                    'hit_last',
                    'hit_second_last',
                    'draw_third_last'
                ],
                tier: 2
            });
        }
    });
    const smallGold = [
    'magistuarmoryaddon:golden_pince_nez_decoration',
    'magistuarmoryaddon:golden_ball_decoration',
    'antiquelegacy:golden_laurel_wreath_decoration'
    ];

    smallGold.forEach(id => {
    
        if (Item.exists(id)) {
        event.remove({ output: id });
            event.custom({
                type: 'tfc:anvil',
                apply_bonus: true,
                ingredient: {
                    tag: 'c:ingots/gold'
                },
                result: {
                    id: id,
                    count: 1
                },
                rules: [
                    'hit_last',
                    'hit_second_last',
                    'draw_third_last'
                ],
                tier: 2
            });
        }
    });
    const sheetsIron = [
    'antiquelegacy:iron_right_hand_manika_decoration',
    'antiquelegacy:iron_left_hand_manika_decoration'
    ];

    sheetsIron.forEach(id => {
    
        if (Item.exists(id)) {
        event.remove({ output: id });
            event.custom({
                type: 'tfc:anvil',
                apply_bonus: true,
                ingredient: {
                    tag: 'c:sheets/wrought_iron'
                },
                result: {
                    id: id,
                    count: 1
                },
                rules: [
                    'hit_last',
                    'hit_second_last',
                    'draw_third_last'
                ],
                tier: 3
            });
        }
    });
    // Pattern sewing
    event.recipes.tfc.sewing(
        'magistuarmory:apostolic_cross_pattern',
        [
            '    #### ',
            '#########',
            '#########',
            '    #### ',
            '    ##   '
        ],
        [
            'BBBBWBWB',
            'WWWWWWWW',
            'BBBBWBWB',
            'BBBBWBBB'
        ]
    )
    // 1. Bowl Pattern
    event.recipes.tfc.sewing(
        'magistuarmory:bowl_pattern',
        [
            '         ',
            ' #     # ', // Top edge of fabric row 2 (sides of bowl)
            ' #     # ', // Middle edge of fabric row 2/3
            '  #####  ', // Bottom edge of bowl
            '         '
        ],
        [
            'BBBBBBBB',
            'BWWWWWWB',
            'BWWWWWWB',
            'BBBBBBBB'
        ]
    )

    // 2. Bull Pattern
    event.recipes.tfc.sewing(
        'magistuarmory:bull_pattern',
        [
            ' #     # ', // Horns
            ' ####### ', // Top of head
            '   ###   ', // Snout
            '         ',
            '         '
        ],
        [
            'BWWWWWWB',
            'BWWWWWWB',
            'BBWWWBBB',
            'BBBBBBBB'
        ]
    )

    // 3. Chess Pattern
    event.recipes.tfc.sewing(
        'magistuarmory:chess_pattern',
        [
            ' # # # # ',
            '  # # #  ',
            ' # # # # ',
            '  # # #  ',
            '         '
        ],
        [
            'BWBWBWBB',
            'BBWBWBlist', 
            'BWBWBWBB',
            'BBBBBBBB'
        ].map(s => s.replace('list', 'BB'))
    )

    // 4. Crusader Cross Pattern
    event.recipes.tfc.sewing(
        'magistuarmory:crusader_cross_pattern',
        [
            '   ##    ', // Top stem edge
            '#########', // Cross bar top edge
            '#########', // Cross bar bottom edge
            '   ##    ', // Bottom stem edge
            '         '
        ],
        [
            'BBBWBBBB',
            'WWWWWWWW',
            'WWWWWWWW',
            'BBBWBBBB'
        ]
    )

    // 5. Dragon Pattern (Fixed slope layout matching Image 2)
    event.recipes.tfc.sewing(
        'magistuarmory:dragon_pattern',
        [
            '   ####  ',
            '  #####  ',
            ' ######  ',
            '         ',
            '         '
        ],
        [
            'BBBWWWWb', 
            'BBWWWWBB',
            'BWWWWBBB',
            'BBBBBBBB'
        ].map(s => s.replace('b', 'B'))
    )

    // 6. Eagle Pattern (REWRITTEN to perfectly match your in-game screenshot)
    event.recipes.tfc.sewing(
        'magistuarmory:eagle_pattern',
        [
            ' ####### ', // Top line of stitches in your screenshot
            '  #####  ', // Second line of stitches
            '   ###   ', // Third line of stitches
            '         ',
            '         '
        ],
        [
            'BWWWWWWW',
            'BBWWWWWB',
            'BBBWWWBB',
            'BBBBBBBB'
        ]
    )

    // 7. Horse Pattern
    event.recipes.tfc.sewing(
        'magistuarmory:horse_pattern',
        [
            '  ####   ',
            ' ####### ',
            ' #     # ',
            '         ',
            '         '
        ],
        [
            'BBWWWWBB',
            'BWWWWWWW',
            'BWWWWWWB',
            'BBBBBBBB'
        ]
    )

    // 8. Lily Pattern
    event.recipes.tfc.sewing(
        'magistuarmory:lily_pattern',
        [
            '   #     ',
            ' # # #   ',
            '  ###    ',
            '         ',
            '         '
        ],
        [
            'BBBWBBBB',
            'BWWWWWBB',
            'BBWWWBBB',
            'BBBBBBBB'
        ]
    )

    // 9. Lion 1 Pattern
    event.recipes.tfc.sewing(
        'magistuarmory:lion1_pattern',
        [
            '   ####  ',
            '  ####   ',
            ' ######  ',
            '         ',
            '         '
        ],
        [
            'BBBWWWWb',
            'BBWWWWBB',
            'BWWWWWWB',
            'BBBBBBBB'
        ].map(s => s.replace('b', 'B'))
    )

    // 10. Lion 2 Pattern
    event.recipes.tfc.sewing(
        'magistuarmory:lion2_pattern',
        [
            ' ######  ',
            '  ####   ',
            ' ######  ',
            '         ',
            '         '
        ],
        [
            'BWWWWWWB',
            'BBWWWWBB',
            'BWWWWWWB',
            'BBBBBBBB'
        ]
    )

    // 11. Orthodox Cross Pattern
    event.recipes.tfc.sewing(
        'magistuarmory:orthodox_cross_pattern',
        [
            '  #####  ',
            '   ###   ',
            ' ####### ',
            '         ',
            '         '
        ],
        [
            'BBWWWWWB',
            'BBBWWWBB',
            'BWWWWWWW',
            'BBBBBBBB'
        ]
    )

    // 12. Snake Pattern
    event.recipes.tfc.sewing(
        'magistuarmory:snake_pattern',
        [
            '  ####   ',
            ' #    #  ',
            '  ####   ',
            '         ',
            '         '
        ],
        [
            'BBWWWWBB',
            'BWWWWWWW',
            'BBWWWWBB',
            'BBBBBBBB'
        ]
    )

    // 13. Sun Pattern
    event.recipes.tfc.sewing(
        'magistuarmory:sun_pattern',
        [
            '  # #    ',
            ' ####### ',
            '  # #    ',
            '         ',
            '         '
        ],
        [
            'BBBWBBBB',
            'BWWWWWWW',
            'BBBWBBBB',
            'BBBBBBBB'
        ]
    )

    // 14. Swords Pattern
    event.recipes.tfc.sewing(
        'magistuarmory:swords_pattern',
        [
            ' #     # ',
            '  #   #  ',
            '   ###   ',
            '         ',
            '         '
        ],
        [
            'BWWWWWWB',
            'BBWWWWBB',
            'BBBWWWBB',
            'BBBBBBBB'
        ]
    )

    // 15. Tower Pattern
    event.recipes.tfc.sewing(
        'magistuarmory:tower_pattern',
        [
            ' # # #   ',
            ' #####   ',
            ' #####   ',
            '         ',
            '         '
        ],
        [
            'BWWWWWBB',
            'BWWWWWBB',
            'BWWWWWBB',
            'BBBBBBBB'
        ]
    )

    // 16. Tree Pattern
    event.recipes.tfc.sewing(
        'magistuarmory:tree_pattern',
        [
            '  #####  ',
            '  #####  ',
            '   ###   ',
            '         ',
            '         '
        ],
        [
            'BBWWWWWB',
            'BBWWWWWB',
            'BBBWWWBB',
            'BBBBBBBB'
        ]
    )

})