package xyz.brassgoggledcoders.steamagerevolution.utils;

import java.util.ArrayList;
import java.util.HashMap;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import xyz.brassgoggledcoders.steamagerevolution.SteamAgeRevolution;

public class RecipeRegistry {
	private static HashMap<SARMachineRecipe, String> recipeMasterlist = Maps.newHashMap();

	public static void addRecipe(String crafter, ItemStack[] itemInputs, FluidStack[] fluidInputs, int ticksToProcess,
			int steamUsePerCraft, ItemStack[] itemOutputs, FluidStack[] fluidOutputs) {
		SARMachineRecipe recipe = new SARMachineRecipe(crafter, itemInputs, fluidInputs, ticksToProcess,
				steamUsePerCraft, itemOutputs, fluidOutputs);
		if(recipeMasterlist.putIfAbsent(recipe, crafter) != null) {
			SteamAgeRevolution.instance.getLogger().devError("Attempted to add duplicate recipe");
		}
	}

	public static HashMap<SARMachineRecipe, String> getRecipeMasterlist() {
		return recipeMasterlist;
	}

	public static ArrayList<SARMachineRecipe> getRecipesForMachine(String machineType) {
		ArrayList<SARMachineRecipe> recipeList = Lists.newArrayList();
		// Goodness gracious a wild stream appeared TODO Do this at runtime
		recipeMasterlist.entrySet().parallelStream().filter(entry -> entry.getValue().equals(machineType))
				.forEach(entry -> recipeList.add(entry.getKey()));
		return recipeList;
	}

}

@@ -384,32 +384,50 @@
  static HashMap%3C
+String, ArrayList%3C
 SARMachineRecipe
@@ -426,24 +426,17 @@
 neRecipe
-, String
+%3E
 %3E recipe
@@ -817,16 +817,17 @@
 );%0A%09%09if(
+!
 recipeMa
@@ -839,44 +839,308 @@
 ist.
-putIfAbsent(recipe, crafter) != null
+containsKey(crafter)) %7B%0A%09%09%09SteamAgeRevolution.instance.getLogger().devInfo(%22Recipe machine %22 + crafter + %22 did not exist, creating%22);%0A%09%09%09recipeMasterlist.put(crafter, Lists.newArrayList());%0A%09%09%7D%0A%09%09ArrayList%3CSARMachineRecipe%3E recipeList = recipeMasterlist.get(crafter);%0A%09%09if(recipeList.contains(recipe)
 ) %7B%0A
@@ -1233,16 +1233,56 @@
 %22);%0A%09%09%7D%0A
+%09%09else %7B%0A%09%09%09recipeList.add(recipe);%0A%09%09%7D%0A
 %09%7D%0A%0A%09pub
@@ -1300,16 +1300,34 @@
 HashMap%3C
+String, ArrayList%3C
 SARMachi
@@ -1338,16 +1338,9 @@
 cipe
-, String
+%3E
 %3E ge
@@ -1484,316 +1484,48 @@
 %7B%0A%09%09
-ArrayList%3CSARMachineRecipe%3E recipeList = Lists.newArrayList();%0A%09%09// Goodness gracious a wild stream appeared TODO Do this at runtime%0A%09%09recipeMasterlist.entrySet().parallelStream().filter(entry -%3E entry.getValue().equals(machineType))%0A%09%09%09%09.forEach(entry -%3E recipeList.add(entry.getKey()));%0A%09%09return recipeList
+return recipeMasterlist.get(machineType)
 ;%0A%09%7D

Use per machine recipe lists instead of masterlist