package ru.dbotthepony.mc.otm.datagen.recipes

import net.minecraft.data.recipes.RecipeCategory
import net.minecraft.data.recipes.RecipeOutput
import net.minecraft.data.recipes.ShapelessRecipeBuilder
import net.minecraft.data.recipes.SimpleCookingRecipeBuilder
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.crafting.Ingredient
import net.neoforged.neoforge.common.Tags
import ru.dbotthepony.mc.otm.core.registryName
import ru.dbotthepony.mc.otm.datagen.modLocation
import ru.dbotthepony.mc.otm.registry.game.MItems

fun addSuspiciousRecipes(consumer: RecipeOutput) {
	for (item in MItems.SUSPICIOUS_FOODS.ITEMS) {
		if (item.defaultMaxStackSize == 1) {
			ShapelessRecipeBuilder.shapeless(RecipeCategory.FOOD, ItemStack(item))
				.requires(item.mimicking())
				.unlockedBy(MItems.PILL_NOT_NORMAL)
				.requires(MItems.PILL_NOT_NORMAL)
				.save(consumer)
		} else {
			ShapelessRecipeBuilder.shapeless(RecipeCategory.FOOD, ItemStack(item, 8))
				.requires(item.mimicking(), 8)
				.unlockedBy(MItems.PILL_NOT_NORMAL)
				.requires(MItems.PILL_NOT_NORMAL)
				.save(consumer)
		}
	}

	MatteryRecipe(MItems.SUSPICIOUS_FOODS.GOLDEN_CARROT, 8, RecipeCategory.FOOD)
		.row(MItems.SUSPICIOUS_FOODS.CARROT, MItems.SUSPICIOUS_FOODS.CARROT, MItems.SUSPICIOUS_FOODS.CARROT)
		.row(MItems.SUSPICIOUS_FOODS.CARROT, Tags.Items.NUGGETS_GOLD, MItems.SUSPICIOUS_FOODS.CARROT)
		.row(MItems.SUSPICIOUS_FOODS.CARROT, MItems.SUSPICIOUS_FOODS.CARROT, MItems.SUSPICIOUS_FOODS.CARROT)
		.unlockedBy(MItems.SUSPICIOUS_FOODS.CARROT)
		.build(consumer, "upgrade")

	val cooking = listOf(
		MItems.SUSPICIOUS_FOODS.POTATO to MItems.SUSPICIOUS_FOODS.BAKED_POTATO,
		MItems.SUSPICIOUS_FOODS.BEEF to MItems.SUSPICIOUS_FOODS.COOKED_BEEF,
		MItems.SUSPICIOUS_FOODS.CHICKEN to MItems.SUSPICIOUS_FOODS.COOKED_CHICKEN,
		MItems.SUSPICIOUS_FOODS.COD to MItems.SUSPICIOUS_FOODS.COOKED_COD,
		MItems.SUSPICIOUS_FOODS.MUTTON to MItems.SUSPICIOUS_FOODS.COOKED_MUTTON,
		MItems.SUSPICIOUS_FOODS.PORKCHOP to MItems.SUSPICIOUS_FOODS.COOKED_PORKCHOP,
		MItems.SUSPICIOUS_FOODS.RABBIT to MItems.SUSPICIOUS_FOODS.COOKED_RABBIT,
		MItems.SUSPICIOUS_FOODS.SALMON to MItems.SUSPICIOUS_FOODS.COOKED_SALMON,
	)

	for ((source, target) in cooking) {
		SimpleCookingRecipeBuilder.smelting(Ingredient.of(source), RecipeCategory.FOOD, target, 0.1f, 200).unlockedBy(source).save(consumer, modLocation("cooking_${source.registryName!!.path}"))
		SimpleCookingRecipeBuilder.smoking(Ingredient.of(source), RecipeCategory.FOOD, target, 0.1f, 100).unlockedBy(source).save(consumer, modLocation("smoking_${source.registryName!!.path}"))
		SimpleCookingRecipeBuilder.campfireCooking(Ingredient.of(source), RecipeCategory.FOOD, target, 0.1f, 600).unlockedBy(source).save(consumer, modLocation("campfire_cooking_${source.registryName!!.path}"))
	}
}
