package techreborn.compat.jei;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.annotation.Nonnull;

import mezz.jei.api.recipe.BlankRecipeWrapper;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import techreborn.api.recipe.BaseRecipe;

public abstract class BaseRecipeWrapper<T extends BaseRecipe> extends BlankRecipeWrapper {
	protected final T baseRecipe;
	@Nonnull
	private final List<List<ItemStack>> inputs;

	public BaseRecipeWrapper(T baseRecipe) {
		this.baseRecipe = baseRecipe;

		inputs = new ArrayList<>();
		for (ItemStack input : baseRecipe.getInputs()) {
			if (baseRecipe.useOreDic()) {
				List<ItemStack> oreDictInputs = expandOreDict(input);
				inputs.add(oreDictInputs);
			} else {
				inputs.add(Collections.singletonList(input));
			}
		}
	}

	private static List<ItemStack> expandOreDict(ItemStack itemStack) {
		int[] oreIds = OreDictionary.getOreIDs(itemStack);
		if (oreIds.length == 0) {
			return Collections.singletonList(itemStack);
		}

		Set<ItemStack> itemStackSet = new HashSet<>();
		for (int oreId : oreIds) {
			String oreName = OreDictionary.getOreName(oreId);
			List<ItemStack> ores = OreDictionary.getOres(oreName);
			itemStackSet.addAll(ores);
		}
		return new ArrayList<>(itemStackSet);
	}

	@Nonnull
	@Override
	public List<List<ItemStack>> getInputs() {
		return inputs;
	}

	@Nonnull
	@Override
	public List<ItemStack> getOutputs() {
		return baseRecipe.getOutputs();
	}
}

@@ -1334,16 +1334,232 @@
 e);%0D%0A%09%09%09
+for (ItemStack ore : ores) %7B%0D%0A%09%09%09%09if (ore.stackSize != itemStack.stackSize) %7B%0D%0A%09%09%09%09%09ItemStack oreCopy = ore.copy();%0D%0A%09%09%09%09%09oreCopy.stackSize = itemStack.stackSize;%0D%0A%09%09%09%09%09itemStackSet.add(oreCopy);%0D%0A%09%09%09%09%7D else %7B%0D%0A%09%09%09%09%09
 itemStac
@@ -1570,20 +1570,29 @@
 .add
-All
 (ore
-s
 );%0D%0A
+%09%09%09%09%7D%0D%0A%09%09%09%7D%0D%0A
 %09%09%7D%0D

Fix #359 JEI Alloy Smelter is not showing stack amount required