Search in sources :

Example 1 with ChemicalInputCache

use of mekanism.common.recipe.lookup.cache.type.ChemicalInputCache in project Mekanism by mekanism.

the class ChemicalCrystallizerInputRecipeCache method findFirstRecipe.

@Nullable
private <CHEMICAL extends Chemical<CHEMICAL>, STACK extends ChemicalStack<CHEMICAL>> ChemicalCrystallizerRecipe findFirstRecipe(ChemicalType type, STACK stack) {
    Predicate<ChemicalCrystallizerRecipe> matchPredicate = recipe -> ((IChemicalStackIngredient<CHEMICAL, STACK>) recipe.getInput()).test(stack);
    ChemicalInputCache<CHEMICAL, STACK, ChemicalCrystallizerRecipe> cache = (ChemicalInputCache<CHEMICAL, STACK, ChemicalCrystallizerRecipe>) typeBasedCache.get(type);
    ChemicalCrystallizerRecipe recipe = cache.findFirstRecipe(stack, matchPredicate);
    return recipe == null ? findFirstRecipe(typeBasedComplexRecipes.get(type), matchPredicate) : recipe;
}
Also used : EnumUtils(mekanism.common.util.EnumUtils) MekanismRecipeType(mekanism.common.recipe.MekanismRecipeType) EnumMap(java.util.EnumMap) ChemicalStack(mekanism.api.chemical.ChemicalStack) Predicate(java.util.function.Predicate) World(net.minecraft.world.World) Set(java.util.Set) ChemicalCrystallizerRecipe(mekanism.api.recipes.ChemicalCrystallizerRecipe) ChemicalInputCache(mekanism.common.recipe.lookup.cache.type.ChemicalInputCache) ChemicalType(mekanism.api.chemical.ChemicalType) HashSet(java.util.HashSet) List(java.util.List) Chemical(mekanism.api.chemical.Chemical) Map(java.util.Map) Nullable(javax.annotation.Nullable) IChemicalStackIngredient(mekanism.api.recipes.inputs.chemical.IChemicalStackIngredient) BoxedChemicalStack(mekanism.api.chemical.merged.BoxedChemicalStack) IChemicalStackIngredient(mekanism.api.recipes.inputs.chemical.IChemicalStackIngredient) ChemicalInputCache(mekanism.common.recipe.lookup.cache.type.ChemicalInputCache) ChemicalCrystallizerRecipe(mekanism.api.recipes.ChemicalCrystallizerRecipe) Nullable(javax.annotation.Nullable)

Aggregations

EnumMap (java.util.EnumMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Predicate (java.util.function.Predicate)1 Nullable (javax.annotation.Nullable)1 Chemical (mekanism.api.chemical.Chemical)1 ChemicalStack (mekanism.api.chemical.ChemicalStack)1 ChemicalType (mekanism.api.chemical.ChemicalType)1 BoxedChemicalStack (mekanism.api.chemical.merged.BoxedChemicalStack)1 ChemicalCrystallizerRecipe (mekanism.api.recipes.ChemicalCrystallizerRecipe)1 IChemicalStackIngredient (mekanism.api.recipes.inputs.chemical.IChemicalStackIngredient)1 MekanismRecipeType (mekanism.common.recipe.MekanismRecipeType)1 ChemicalInputCache (mekanism.common.recipe.lookup.cache.type.ChemicalInputCache)1 EnumUtils (mekanism.common.util.EnumUtils)1 World (net.minecraft.world.World)1