Search in sources :

Example 1 with ElectrolysisRecipe

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

the class ElectrolysisRecipeMapper method handleRecipe.

@Override
public boolean handleRecipe(IMappingCollector<NormalizedSimpleStack, Long> mapper, IRecipe<?> iRecipe, INSSFakeGroupManager groupManager) {
    if (!(iRecipe instanceof ElectrolysisRecipe)) {
        // Double check that we have a type of recipe we know how to handle
        return false;
    }
    boolean handled = false;
    ElectrolysisRecipe recipe = (ElectrolysisRecipe) iRecipe;
    FluidStackIngredient input = recipe.getInput();
    for (FluidStack representation : input.getRepresentations()) {
        Pair<@NonNull GasStack, @NonNull GasStack> output = recipe.getOutput(representation);
        GasStack leftOutput = output.getLeft();
        GasStack rightOutput = output.getRight();
        if (!leftOutput.isEmpty() && !rightOutput.isEmpty()) {
            NormalizedSimpleStack nssInput = NSSFluid.createFluid(representation);
            NormalizedSimpleStack nssLeftOutput = NSSGas.createGas(leftOutput);
            NormalizedSimpleStack nssRightOutput = NSSGas.createGas(rightOutput);
            // Add trying to calculate left output (using it as if we needed negative of right output)
            IngredientHelper ingredientHelper = new IngredientHelper(mapper);
            ingredientHelper.put(nssInput, representation.getAmount());
            ingredientHelper.put(nssRightOutput, -rightOutput.getAmount());
            if (ingredientHelper.addAsConversion(nssLeftOutput, leftOutput.getAmount())) {
                handled = true;
            }
            // Add trying to calculate right output (using it as if we needed negative of left output)
            ingredientHelper.resetHelper();
            ingredientHelper.put(nssInput, representation.getAmount());
            ingredientHelper.put(nssLeftOutput, -leftOutput.getAmount());
            if (ingredientHelper.addAsConversion(nssRightOutput, rightOutput.getAmount())) {
                handled = true;
            }
        }
    }
    return handled;
}
Also used : NormalizedSimpleStack(moze_intel.projecte.api.nss.NormalizedSimpleStack) FluidStackIngredient(mekanism.api.recipes.inputs.FluidStackIngredient) ElectrolysisRecipe(mekanism.api.recipes.ElectrolysisRecipe) FluidStack(net.minecraftforge.fluids.FluidStack) GasStack(mekanism.api.chemical.gas.GasStack) IngredientHelper(mekanism.common.integration.projecte.IngredientHelper)

Aggregations

GasStack (mekanism.api.chemical.gas.GasStack)1 ElectrolysisRecipe (mekanism.api.recipes.ElectrolysisRecipe)1 FluidStackIngredient (mekanism.api.recipes.inputs.FluidStackIngredient)1 IngredientHelper (mekanism.common.integration.projecte.IngredientHelper)1 NormalizedSimpleStack (moze_intel.projecte.api.nss.NormalizedSimpleStack)1 FluidStack (net.minecraftforge.fluids.FluidStack)1