package net.mcft.copy.betterstorage.api.crafting;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import net.mcft.copy.betterstorage.api.BetterStorageUtils;
import net.mcft.copy.betterstorage.utils.StackUtils;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;

public class RecipeInputItemStack implements IRecipeInput {
	
	public final ItemStack stack;
	
	public RecipeInputItemStack(ItemStack stack) {
		this.stack = stack;
	}
	
	@Override
	public int getAmount() { return stack.stackSize; }
	
	@Override
	public boolean matches(ItemStack stack) { return BetterStorageUtils.wildcardMatch(this.stack, stack); }
	
	@Override
	public ItemStack getSampleInput(Random rnd) {
		if ((stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) && (stack.getHasSubtypes())) {
			List<ItemStack> list = new ArrayList<ItemStack>();
			stack.getItem().getSubItems(stack.itemID, null, list);
			return StackUtils.copyStack(list.get(rnd.nextInt(list.size())), getAmount());
		} else return stack;
	}
	
}

@@ -270,16 +270,57 @@
 mStack;%0A
+import net.minecraft.nbt.NBTTagCompound;%0A
 import n
@@ -455,16 +455,566 @@
 stack;%0A%09
+public final boolean nbtSensitive;%0A%09%0A%09public RecipeInputItemStack(ItemStack stack, boolean nbtSensitive) %7B%0A%09%09this.stack = stack;%0A%09%09this.nbtSensitive = nbtSensitive;%0A%09%09// If input is NBT sensitive, make sure it has an NBT compound.%0A%09%09// Empty means it only matches items with no NBT data.%0A%09%09if (nbtSensitive) %7B%0A%09%09%09if (!stack.hasTagCompound())%0A%09%09%09%09stack.setTagCompound(new NBTTagCompound());%0A%09%09// Otherwise, always remove the NBT compound,%0A%09%09// because then it will match any item.%0A%09%09%7D else if (stack.hasTagCompound())%0A%09%09%09stack.setTagCompound(null);%0A%09%7D
 %0A%09public
@@ -1060,30 +1060,30 @@
 %7B%0A%09%09this
-.
+(
 stack
- = stack
+, false)
 ;%0A%09%7D%0A%09%0A%09

Allow RecipeInputItemStack to be nbt sensitive