Search in sources :

Example 1 with ItemStackGasToItemStackRecipe

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

the class ItemStackGasToItemStackRecipeMapper method handleRecipe.

@Override
public boolean handleRecipe(IMappingCollector<NormalizedSimpleStack, Long> mapper, IRecipe<?> iRecipe, INSSFakeGroupManager groupManager) {
    if (!(iRecipe instanceof ItemStackGasToItemStackRecipe)) {
        // Double check that we have a type of recipe we know how to handle
        return false;
    }
    boolean handled = false;
    ItemStackGasToItemStackRecipe recipe = (ItemStackGasToItemStackRecipe) iRecipe;
    List<@NonNull ItemStack> itemRepresentations = recipe.getItemInput().getRepresentations();
    List<@NonNull GasStack> gasRepresentations = recipe.getChemicalInput().getRepresentations();
    for (GasStack gasRepresentation : gasRepresentations) {
        NSSGas nssGas = NSSGas.createGas(gasRepresentation);
        long gasAmount = gasRepresentation.getAmount() * TileEntityAdvancedElectricMachine.BASE_TICKS_REQUIRED;
        for (ItemStack itemRepresentation : itemRepresentations) {
            ItemStack output = recipe.getOutput(itemRepresentation, gasRepresentation);
            if (!output.isEmpty()) {
                IngredientHelper ingredientHelper = new IngredientHelper(mapper);
                ingredientHelper.put(itemRepresentation);
                ingredientHelper.put(nssGas, gasAmount);
                if (ingredientHelper.addAsConversion(output)) {
                    handled = true;
                }
            }
        }
    }
    return handled;
}
Also used : ItemStackGasToItemStackRecipe(mekanism.api.recipes.ItemStackGasToItemStackRecipe) NSSGas(mekanism.common.integration.projecte.NSSGas) GasStack(mekanism.api.chemical.gas.GasStack) ItemStack(net.minecraft.item.ItemStack) IngredientHelper(mekanism.common.integration.projecte.IngredientHelper)

Aggregations

GasStack (mekanism.api.chemical.gas.GasStack)1 ItemStackGasToItemStackRecipe (mekanism.api.recipes.ItemStackGasToItemStackRecipe)1 IngredientHelper (mekanism.common.integration.projecte.IngredientHelper)1 NSSGas (mekanism.common.integration.projecte.NSSGas)1 ItemStack (net.minecraft.item.ItemStack)1