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