Search in sources :

Example 1 with OreDictUnifier

use of gregtech.api.unification.OreDictUnifier in project GregTech by GregTechCE.

the class RecyclingRecipes method registerArcRecyclingRecipe.

public static void registerArcRecyclingRecipe(Consumer<RecipeBuilder<?>> inputSupplier, List<MaterialStack> components, boolean ignoreArcSmelting) {
    List<MaterialStack> dustMaterials = components.stream().filter(stack -> stack.material instanceof DustMaterial).filter(// do only materials which have at least one nugget
    stack -> stack.amount >= M / 9).collect(Collectors.toList());
    if (dustMaterials.isEmpty())
        return;
    MaterialStack firstStack = dustMaterials.get(0);
    DustMaterial dustMaterial = (DustMaterial) firstStack.material;
    int voltageMultiplier = 1;
    if (dustMaterial instanceof IngotMaterial) {
        int blastFurnaceTemperature = ((IngotMaterial) dustMaterial).blastFurnaceTemperature;
        voltageMultiplier = blastFurnaceTemperature == 0 ? 1 : blastFurnaceTemperature > 2000 ? 16 : 4;
    } else {
        // do not apply arc smelting for gems, solid materials and dust materials
        // only generate recipes for ingot materials
        ignoreArcSmelting = true;
    }
    RecipeBuilder<?> maceratorRecipeBuilder = RecipeMaps.MACERATOR_RECIPES.recipeBuilder().outputs(dustMaterials.stream().map(OreDictUnifier::getDust).collect(Collectors.toList())).duration((int) Math.max(1L, firstStack.amount * 30 / M)).EUt(8 * voltageMultiplier);
    inputSupplier.accept(maceratorRecipeBuilder);
    maceratorRecipeBuilder.buildAndRegister();
    if (dustMaterial.shouldGenerateFluid()) {
        RecipeBuilder<?> fluidExtractorRecipeBuilder = RecipeMaps.FLUID_EXTRACTION_RECIPES.recipeBuilder().fluidOutputs(dustMaterial.getFluid((int) (firstStack.amount * L / M))).duration((int) Math.max(1L, firstStack.amount * 80 / M)).EUt(32 * voltageMultiplier);
        inputSupplier.accept(fluidExtractorRecipeBuilder);
        fluidExtractorRecipeBuilder.buildAndRegister();
    }
    if (!ignoreArcSmelting) {
        List<ItemStack> resultList = dustMaterials.stream().map(RecyclingRecipes::getArcSmeltingResult).collect(Collectors.toList());
        resultList.removeIf(ItemStack::isEmpty);
        if (resultList.isEmpty())
            return;
        RecipeBuilder<?> arcFurnaceRecipeBuilder = RecipeMaps.ARC_FURNACE_RECIPES.recipeBuilder().outputs(resultList).duration((int) Math.max(1L, firstStack.amount * 60 / M)).EUt(30 * voltageMultiplier);
        inputSupplier.accept(arcFurnaceRecipeBuilder);
        arcFurnaceRecipeBuilder.buildAndRegister();
    }
}
Also used : OreDictUnifier(gregtech.api.unification.OreDictUnifier) M(gregtech.api.GTValues.M) L(gregtech.api.GTValues.L) GemMaterial(gregtech.api.unification.material.type.GemMaterial) IngotMaterial(gregtech.api.unification.material.type.IngotMaterial) Materials(gregtech.api.unification.material.Materials) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) ItemMaterialInfo(gregtech.api.unification.stack.ItemMaterialInfo) ItemStack(net.minecraft.item.ItemStack) MaterialStack(gregtech.api.unification.stack.MaterialStack) List(java.util.List) RecipeBuilder(gregtech.api.recipes.RecipeBuilder) MatFlags(gregtech.api.unification.material.type.Material.MatFlags) Entry(java.util.Map.Entry) RecipeMaps(gregtech.api.recipes.RecipeMaps) DustMaterial(gregtech.api.unification.material.type.DustMaterial) IngotMaterial(gregtech.api.unification.material.type.IngotMaterial) OreDictUnifier(gregtech.api.unification.OreDictUnifier) MaterialStack(gregtech.api.unification.stack.MaterialStack) DustMaterial(gregtech.api.unification.material.type.DustMaterial) ItemStack(net.minecraft.item.ItemStack)

Aggregations

L (gregtech.api.GTValues.L)1 M (gregtech.api.GTValues.M)1 RecipeBuilder (gregtech.api.recipes.RecipeBuilder)1 RecipeMaps (gregtech.api.recipes.RecipeMaps)1 OreDictUnifier (gregtech.api.unification.OreDictUnifier)1 Materials (gregtech.api.unification.material.Materials)1 DustMaterial (gregtech.api.unification.material.type.DustMaterial)1 GemMaterial (gregtech.api.unification.material.type.GemMaterial)1 IngotMaterial (gregtech.api.unification.material.type.IngotMaterial)1 MatFlags (gregtech.api.unification.material.type.Material.MatFlags)1 ItemMaterialInfo (gregtech.api.unification.stack.ItemMaterialInfo)1 MaterialStack (gregtech.api.unification.stack.MaterialStack)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Entry (java.util.Map.Entry)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 ItemStack (net.minecraft.item.ItemStack)1