use of mezz.jei.api.ingredients.IIngredients in project BluePower by Qmunity.
the class AlloyFurnaceHandler method setIngredients.
@Override
public void setIngredients(StandardAlloyFurnaceRecipe recipe, IIngredients ingredients) {
List<List<ItemStack>> items = recipe.getRequiredItems().stream().map(ingredient -> Arrays.asList(ingredient.getItems())).collect(Collectors.toList());
for (int i = 0; i < items.size(); i++) {
for (ItemStack itemStack : items.get(i)) {
itemStack.setCount(recipe.getRequiredCount().get(i));
}
}
ingredients.setInputLists(VanillaTypes.ITEM, items);
ingredients.setOutput(VanillaTypes.ITEM, recipe.getResultItem());
}
use of mezz.jei.api.ingredients.IIngredients in project CraftTweaker by CraftTweaker.
the class ConflictCommand method gatherRecipes.
/**
* Collects all recipes, converts them to the own class and adds them to the List
*/
private void gatherRecipes() {
IRecipeRegistry reg = JEIAddonPlugin.recipeRegistry;
for (IRecipeCategory category : reg.getRecipeCategories()) {
if (category instanceof CraftingRecipeCategory) {
List wrappers = reg.getRecipeWrappers(category);
for (Object wrapper : wrappers) {
if (wrapper instanceof IRecipeWrapper && !(wrapper instanceof TippedArrowRecipeWrapper)) {
IRecipeWrapper wrap = ((IRecipeWrapper) wrapper);
IIngredients ing = new Ingredients();
wrap.getIngredients(ing);
List<List<ItemStack>> inputs = ing.getInputs(ItemStack.class);
List<List<ItemStack>> outputs = ing.getOutputs(ItemStack.class);
// checks for having no outputs or having a "null" output
ItemStack output = outputs.size() > 0 ? outputs.get(0) != null ? outputs.get(0).size() > 0 ? outputs.get(0).get(0) : null : null : null;
// prevent checking recipes with "null" output
if (output == null) {
continue;
}
// differs shaped an shapeless recipes
if (wrapper instanceof IShapedCraftingRecipeWrapper) {
craftingRecipeEntries.add(new CraftingRecipeEntry(inputs, output, ((IShapedCraftingRecipeWrapper) wrapper).getWidth(), ((IShapedCraftingRecipeWrapper) wrapper).getHeight(), "noname"));
} else {
craftingRecipeEntries.add(new CraftingRecipeEntry(inputs, output, "noname"));
}
}
}
}
}
}
use of mezz.jei.api.ingredients.IIngredients in project GregTech by GregTechCE.
the class GTRecipeWrapper method getIngredients.
@Override
public void getIngredients(IIngredients ingredients) {
if (!recipe.getInputs().isEmpty()) {
List<CountableIngredient> recipeInputs = recipe.getInputs();
List<List<ItemStack>> matchingInputs = new ArrayList<>(recipeInputs.size());
for (CountableIngredient ingredient : recipeInputs) {
List<ItemStack> ingredientValues = Arrays.stream(ingredient.getIngredient().getMatchingStacks()).map(ItemStack::copy).sorted(OreDictUnifier.getItemStackComparator()).collect(Collectors.toList());
ingredientValues.forEach(stack -> {
if (ingredient.getCount() == 0) {
notConsumedInput.add(stack);
stack.setCount(1);
} else
stack.setCount(ingredient.getCount());
});
matchingInputs.add(ingredientValues);
}
ingredients.setInputLists(VanillaTypes.ITEM, matchingInputs);
}
if (!recipe.getFluidInputs().isEmpty()) {
List<FluidStack> recipeInputs = recipe.getFluidInputs().stream().map(FluidStack::copy).collect(Collectors.toList());
recipeInputs.forEach(stack -> {
if (stack.amount == 0) {
notConsumedFluidInput.add(stack);
stack.amount = 1;
}
});
ingredients.setInputs(VanillaTypes.FLUID, recipeInputs);
}
if (!recipe.getOutputs().isEmpty() || !recipe.getChancedOutputs().isEmpty()) {
List<ItemStack> recipeOutputs = recipe.getOutputs().stream().map(ItemStack::copy).collect(Collectors.toList());
List<ChanceEntry> chancedOutputs = recipe.getChancedOutputs();
for (ChanceEntry chancedEntry : chancedOutputs) {
ItemStack chancedStack = chancedEntry.getItemStack();
chanceOutput.put(chancedStack, chancedEntry);
recipeOutputs.add(chancedStack);
}
recipeOutputs.sort(Comparator.comparingInt(stack -> {
ChanceEntry chanceEntry = chanceOutput.get(stack);
if (chanceEntry == null)
return 0;
return chanceEntry.getChance();
}));
ingredients.setOutputs(VanillaTypes.ITEM, recipeOutputs);
}
if (!recipe.getFluidOutputs().isEmpty()) {
List<FluidStack> recipeOutputs = recipe.getFluidOutputs().stream().map(FluidStack::copy).collect(Collectors.toList());
ingredients.setOutputs(VanillaTypes.FLUID, recipeOutputs);
}
}
Aggregations