From b147de9c94e33be3d142da870bb422b9f56436dd Mon Sep 17 00:00:00 2001 From: YoungOnion <39562198+YoungOnionMC@users.noreply.github.com> Date: Mon, 23 Sep 2024 17:02:16 -0600 Subject: [PATCH] Fix Multi smelter not overclocking (#2008) --- .../gtceu/common/data/GTRecipeModifiers.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeModifiers.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeModifiers.java index dbfa858207..03bb1057e1 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeModifiers.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeModifiers.java @@ -2,6 +2,7 @@ import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.capability.IParallelHatch; +import com.gregtechceu.gtceu.api.capability.recipe.EURecipeCapability; import com.gregtechceu.gtceu.api.capability.recipe.IRecipeCapabilityHolder; import com.gregtechceu.gtceu.api.data.medicalcondition.MedicalCondition; import com.gregtechceu.gtceu.api.machine.MetaMachine; @@ -12,6 +13,8 @@ import com.gregtechceu.gtceu.api.recipe.GTRecipe; import com.gregtechceu.gtceu.api.recipe.OverclockingLogic; import com.gregtechceu.gtceu.api.recipe.RecipeHelper; +import com.gregtechceu.gtceu.api.recipe.chance.logic.ChanceLogic; +import com.gregtechceu.gtceu.api.recipe.content.Content; import com.gregtechceu.gtceu.api.recipe.content.ContentModifier; import com.gregtechceu.gtceu.api.recipe.logic.OCParams; import com.gregtechceu.gtceu.api.recipe.logic.OCResult; @@ -30,6 +33,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.List; import java.util.Optional; import java.util.function.BiFunction; import java.util.function.Function; @@ -243,17 +247,22 @@ public static GTRecipe multiSmelterParallel(MetaMachine machine, @NotNull GTReci var maxParallel = 32 * coilMachine.getCoilType().getLevel(); final int FURNACE_DURATION = 128; var parallel = GTRecipeModifiers.accurateParallel(machine, recipe, maxParallel, false); - // double durationForParallel = Math.max(1.0, FURNACE_DURATION * 2 * parallel.getSecond() / Math.max(1, - // maxParallel * 1.0)); int parallelValue = parallel.getSecond(); - long eut = 4 * (parallelValue / 8) / coilMachine.getCoilType().getEnergyDiscount(); - result.init(eut, Math.max(1, 256 * parallelValue / maxParallel), parallelValue, params.getOcAmount()); - /* - * recipe.duration = Math.max(1, 256 * parallelValue / maxParallel); - * recipe.tickInputs.put(EURecipeCapability.CAP, List.of(new Content(eut, - * ChanceLogic.getMaxChancedValue(), ChanceLogic.getMaxChancedValue(), 0, null, null))); - */ + long eut = 4 * Math.max(1, (parallelValue / 8) / coilMachine.getCoilType().getEnergyDiscount()); + int duration = (int) Math.max(1, FURNACE_DURATION * 2 * parallelValue / Math.max(1, maxParallel * 1.0)); + + recipe.duration = duration; + recipe.tickInputs.put(EURecipeCapability.CAP, List.of(new Content(eut, + ChanceLogic.getMaxChancedValue(), ChanceLogic.getMaxChancedValue(), + 0, null, null))); + + var re = RecipeHelper.applyOverclock(new OverclockingLogic((p, r, maxVoltage) -> { + OverclockingLogic.NON_PERFECT_OVERCLOCK.getLogic() + .runOverclockingLogic(params, result, maxVoltage); + }), recipe, coilMachine.getOverclockVoltage(), params, result); + recipe = recipe.copy(ContentModifier.multiplier(parallelValue), false); + return recipe; } return null;