// Path: src/main/java/com/gmail/jannyboy11/customrecipes/impl/crafting/custom/ingredient/CountIngredient.java
// public class CountIngredient extends CombinedIngredient {
// 	
// 	private final RecipeItemStack basePredicate;
// 	private final int count;
// 
// 	public CountIngredient(RecipeItemStack basePredicate, int count) {
// 		super(basePredicate, itemStack -> itemStack.getCount() == count, Boolean::logicalAnd);
// 		this.basePredicate = basePredicate;
// 		this.count = count;
// 	}
// 	
// 	@Override
// 	public RecipeItemStack asNMSIngredient() {
// 		RecipeItemStack recipeItemStack = super.asNMSIngredient();
// 		ReflectionUtil.setFinalFieldValue(recipeItemStack, "choices", basePredicate.choices);
// 		return recipeItemStack;
// 	}
// 	
// 	public int getCount() {
// 		return count;
// 	}
// 
// }


import com.gmail.jannyboy11.customrecipes.impl.crafting.custom.ingredient.CountIngredient;
import net.minecraft.server.v1_12_R1.InventoryCrafting;
import net.minecraft.server.v1_12_R1.ItemStack;
import net.minecraft.server.v1_12_R1.NonNullList;
import net.minecraft.server.v1_12_R1.RecipeItemStack;
import net.minecraft.server.v1_12_R1.ShapedRecipes;
package com.gmail.jannyboy11.customrecipes.impl.crafting.custom.recipe;


public class CountRecipe extends ShapedRecipes {

	public CountRecipe(String group, int width, int heigth, NonNullList<RecipeItemStack> ingredients, ItemStack result) {
		super(group, width, heigth, makeCountSpecific(ingredients), result);
	}
	
	public static NonNullList<RecipeItemStack> makeCountSpecific(NonNullList<RecipeItemStack> ingredients) {
		NonNullList<RecipeItemStack> result = NonNullList.a(ingredients.size(), RecipeItemStack.a);
		for (int i = 0; i < ingredients.size(); i++) {
			RecipeItemStack ingr = ingredients.get(i);
			if (ingr == RecipeItemStack.a) {
				result.set(i, RecipeItemStack.a);
				continue;
			}
			
			ItemStack[] choices = ingr.choices;
			if (choices.length == 0) {
				continue;
			}
			
			ItemStack firstChoice = choices[0];
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/impl/crafting/custom/ingredient/CountIngredient.java
// public class CountIngredient extends CombinedIngredient {
// 	
// 	private final RecipeItemStack basePredicate;
// 	private final int count;
// 
// 	public CountIngredient(RecipeItemStack basePredicate, int count) {
// 		super(basePredicate, itemStack -> itemStack.getCount() == count, Boolean::logicalAnd);
// 		this.basePredicate = basePredicate;
// 		this.count = count;
// 	}
// 	
// 	@Override
// 	public RecipeItemStack asNMSIngredient() {
// 		RecipeItemStack recipeItemStack = super.asNMSIngredient();
// 		ReflectionUtil.setFinalFieldValue(recipeItemStack, "choices", basePredicate.choices);
// 		return recipeItemStack;
// 	}
// 	
// 	public int getCount() {
// 		return count;
// 	}
// 
// }


// Path: src/main/java/com/gmail/jannyboy11/customrecipes/impl/crafting/custom/recipe/CountRecipe.java
import com.gmail.jannyboy11.customrecipes.impl.crafting.custom.ingredient.CountIngredient;
import net.minecraft.server.v1_12_R1.InventoryCrafting;
import net.minecraft.server.v1_12_R1.ItemStack;
import net.minecraft.server.v1_12_R1.NonNullList;
import net.minecraft.server.v1_12_R1.RecipeItemStack;
import net.minecraft.server.v1_12_R1.ShapedRecipes;

package com.gmail.jannyboy11.customrecipes.impl.crafting.custom.recipe;


public class CountRecipe extends ShapedRecipes {

	public CountRecipe(String group, int width, int heigth, NonNullList<RecipeItemStack> ingredients, ItemStack result) {
		super(group, width, heigth, makeCountSpecific(ingredients), result);
	}
	
	public static NonNullList<RecipeItemStack> makeCountSpecific(NonNullList<RecipeItemStack> ingredients) {
		NonNullList<RecipeItemStack> result = NonNullList.a(ingredients.size(), RecipeItemStack.a);
		for (int i = 0; i < ingredients.size(); i++) {
			RecipeItemStack ingr = ingredients.get(i);
			if (ingr == RecipeItemStack.a) {
				result.set(i, RecipeItemStack.a);
				continue;
			}
			
			ItemStack[] choices = ingr.choices;
			if (choices.length == 0) {
				continue;
			}
			
			ItemStack firstChoice = choices[0];
			result.set(i, new CountIngredient(ingr, firstChoice.getCount()).asNMSIngredient());			