// priority: 0

ServerEvents.recipes(e => {
	const vanillaMats = ["leather", "chainmail", "iron", "golden", "diamond"]

	function convertMat(mat) {
		let craftMat

		switch (mat) {
			case "chainmail":
				craftMat = MC("chain");
				break;
			case "iron":
				craftMat = F(`#ingots/${mat}`);
				break;
			case "golden":
				craftMat = F(`#ingots/gold`);
				break;
			default:
				craftMat = MC(mat);
				break;
		}
		return craftMat
	}

	for (let i = 1; i < vanillaMats.length; i++) {
		let currMat = vanillaMats[i]
		let prevMat = vanillaMats[i - 1]

		armorPieces.vanilla.forEach(piece => {
			removeRecipeByOutput(e, [
				MC(`${currMat}_${piece}`)
			])
		})

		//helmet
		e.shaped(MC(`${currMat}_helmet`), [
			'AAA',
			'ABA'
		], {
			A: convertMat(currMat),
			B: MC(`${prevMat}_helmet`),
		})

		//chestplate
		e.shaped(MC(`${currMat}_chestplate`), [
			'ABA',
			'AAA',
			'AAA'
		], {
			A: convertMat(currMat),
			B: MC(`${prevMat}_chestplate`),
		})

		//leggings
		e.shaped(MC(`${currMat}_leggings`), [
			'AAA',
			'ABA',
			'A A'
		], {
			A: convertMat(currMat),
			B: MC(`${prevMat}_leggings`),
		})

		//boots
		e.shaped(MC(`${currMat}_boots`), [
			'ABA',
			'A A'
		], {
			A: convertMat(currMat),
			B: MC(`${prevMat}_boots`),
		})
	}
})