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;
}
Aggregations