use of net.tropicraft.core.common.drinks.MixerRecipe in project Tropicraft by Tropicraft.
the class DrinkMixerRegistry method getResult.
@Nonnull
public static ItemStack getResult(NonNullList<ItemStack> ingredients) {
for (MixerRecipe recipe : recipes) {
int validIngredientsFound = 0;
for (Ingredient recipeIngredient : recipe.getIngredients()) {
for (ItemStack mixerIngredient : ingredients) {
if (ItemStack.areItemStacksEqual(recipeIngredient.getIngredient(), mixerIngredient)) {
validIngredientsFound++;
break;
}
}
}
// Make sure to only count valid ingredients (non-empty) when getting size
if (validIngredientsFound == ingredients.stream().filter(i -> !i.isEmpty()).count()) {
return ItemCocktail.makeCocktail(recipe);
}
}
List<Ingredient> is = new ArrayList<Ingredient>();
for (ItemStack ingredientStack : ingredients) {
is.addAll(Ingredient.listIngredients(ingredientStack));
}
Collections.sort(is);
return ItemCocktail.makeCocktail(is.toArray(new Ingredient[is.size()]));
}
Aggregations