2014-07-07 17:22:21 +02:00
|
|
|
package com.pahimar.ee3.api.recipe;
|
2014-06-14 21:40:45 +02:00
|
|
|
|
|
|
|
import com.google.common.collect.HashMultimap;
|
|
|
|
import com.google.common.collect.Multimap;
|
2014-07-07 17:22:21 +02:00
|
|
|
import com.pahimar.ee3.api.core.WrappedStack;
|
|
|
|
import com.pahimar.ee3.recipe.RecipesFluidContainers;
|
|
|
|
import com.pahimar.ee3.recipe.RecipesPotions;
|
|
|
|
import com.pahimar.ee3.recipe.RecipesVanilla;
|
2014-06-14 21:40:45 +02:00
|
|
|
import com.pahimar.ee3.util.LogHelper;
|
|
|
|
|
2014-06-19 20:39:46 +02:00
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.SortedSet;
|
|
|
|
import java.util.TreeSet;
|
2014-06-14 21:40:45 +02:00
|
|
|
|
|
|
|
public class RecipeRegistry
|
|
|
|
{
|
|
|
|
private static RecipeRegistry recipeRegistry = null;
|
|
|
|
|
|
|
|
private Multimap<WrappedStack, List<WrappedStack>> recipeMap;
|
|
|
|
|
|
|
|
private RecipeRegistry()
|
|
|
|
{
|
|
|
|
recipeMap = HashMultimap.create();
|
|
|
|
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void init()
|
|
|
|
{
|
|
|
|
// Add recipes in the vanilla crafting manager
|
|
|
|
for (WrappedStack outputStack : RecipesVanilla.getVanillaRecipes().keySet())
|
|
|
|
{
|
|
|
|
for (List<WrappedStack> inputStacks : RecipesVanilla.getVanillaRecipes().get(outputStack))
|
|
|
|
{
|
|
|
|
if (!recipeMap.get(outputStack).contains(inputStacks))
|
|
|
|
{
|
|
|
|
recipeMap.put(outputStack, inputStacks);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add fluid container recipes
|
|
|
|
for (WrappedStack outputStack : RecipesFluidContainers.getFluidContainerRecipes().keySet())
|
|
|
|
{
|
|
|
|
for (List<WrappedStack> inputStacks : RecipesFluidContainers.getFluidContainerRecipes().get(outputStack))
|
|
|
|
{
|
|
|
|
if (!recipeMap.get(outputStack).contains(inputStacks))
|
|
|
|
{
|
|
|
|
recipeMap.put(outputStack, inputStacks);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add potion recipes
|
|
|
|
for (WrappedStack outputStack : RecipesPotions.getPotionRecipes().keySet())
|
|
|
|
{
|
|
|
|
for (List<WrappedStack> inputStacks : RecipesPotions.getPotionRecipes().get(outputStack))
|
|
|
|
{
|
|
|
|
if (!recipeMap.get(outputStack).contains(inputStacks))
|
|
|
|
{
|
|
|
|
recipeMap.put(outputStack, inputStacks);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add Aludel recipes
|
2014-07-06 18:14:45 +02:00
|
|
|
for (RecipeAludel recipeAludel : RecipesAludel.getInstance().getRecipes())
|
|
|
|
{
|
|
|
|
WrappedStack recipeOutput = new WrappedStack(recipeAludel.getRecipeOutput());
|
|
|
|
List<WrappedStack> recipeInputs = recipeAludel.getRecipeInputsAsWrappedStacks();
|
|
|
|
|
|
|
|
if (!recipeMap.get(recipeOutput).contains(recipeInputs))
|
|
|
|
{
|
|
|
|
recipeMap.put(recipeOutput, recipeInputs);
|
|
|
|
}
|
|
|
|
}
|
2014-06-14 21:40:45 +02:00
|
|
|
}
|
|
|
|
|
2014-07-07 17:22:21 +02:00
|
|
|
public static RecipeRegistry getInstance()
|
|
|
|
{
|
|
|
|
if (recipeRegistry == null)
|
|
|
|
{
|
|
|
|
recipeRegistry = new RecipeRegistry();
|
|
|
|
}
|
|
|
|
|
|
|
|
return recipeRegistry;
|
|
|
|
}
|
|
|
|
|
2014-06-14 21:40:45 +02:00
|
|
|
public Multimap<WrappedStack, List<WrappedStack>> getRecipeMappings()
|
|
|
|
{
|
|
|
|
return recipeRegistry.recipeMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void dumpRegistry()
|
|
|
|
{
|
|
|
|
// Sort the keys for output to console
|
|
|
|
SortedSet<WrappedStack> set = new TreeSet<WrappedStack>();
|
|
|
|
set.addAll(recipeMap.keySet());
|
|
|
|
|
|
|
|
for (WrappedStack key : set)
|
|
|
|
{
|
|
|
|
Collection<List<WrappedStack>> recipeMappings = recipeMap.get(key);
|
|
|
|
|
|
|
|
for (List<WrappedStack> recipeList : recipeMappings)
|
|
|
|
{
|
|
|
|
LogHelper.info(String.format("Recipe Output: %s, Recipe Input: %s", key.toString(), recipeList.toString()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|