Search in sources :

Example 1 with PigmentMixingRecipe

use of mekanism.api.recipes.PigmentMixingRecipe in project Mekanism by mekanism.

the class PigmentMixerRecipeMapper method handleRecipe.

@Override
public boolean handleRecipe(IMappingCollector<NormalizedSimpleStack, Long> mapper, IRecipe<?> iRecipe, INSSFakeGroupManager groupManager) {
    if (!(iRecipe instanceof PigmentMixingRecipe)) {
        // Double check that we have a type of recipe we know how to handle
        return false;
    }
    boolean handled = false;
    PigmentMixingRecipe recipe = (PigmentMixingRecipe) iRecipe;
    List<@NonNull PigmentStack> leftInputRepresentations = recipe.getLeftInput().getRepresentations();
    List<@NonNull PigmentStack> rightInputRepresentations = recipe.getRightInput().getRepresentations();
    for (PigmentStack leftRepresentation : leftInputRepresentations) {
        NormalizedSimpleStack nssLeft = NSSPigment.createPigment(leftRepresentation);
        for (PigmentStack rightRepresentation : rightInputRepresentations) {
            PigmentStack output = recipe.getOutput(leftRepresentation, rightRepresentation);
            if (!output.isEmpty()) {
                IngredientHelper ingredientHelper = new IngredientHelper(mapper);
                ingredientHelper.put(nssLeft, leftRepresentation.getAmount());
                ingredientHelper.put(rightRepresentation);
                if (ingredientHelper.addAsConversion(output)) {
                    handled = true;
                }
            }
        }
    }
    return handled;
}
Also used : NormalizedSimpleStack(moze_intel.projecte.api.nss.NormalizedSimpleStack) PigmentStack(mekanism.api.chemical.pigment.PigmentStack) IngredientHelper(mekanism.common.integration.projecte.IngredientHelper) PigmentMixingRecipe(mekanism.api.recipes.PigmentMixingRecipe)

Aggregations

PigmentStack (mekanism.api.chemical.pigment.PigmentStack)1 PigmentMixingRecipe (mekanism.api.recipes.PigmentMixingRecipe)1 IngredientHelper (mekanism.common.integration.projecte.IngredientHelper)1 NormalizedSimpleStack (moze_intel.projecte.api.nss.NormalizedSimpleStack)1