From c2a1ae3eaa4ccbe32ccedc550e2df9b5da71db98 Mon Sep 17 00:00:00 2001 From: Gregor0410 <34042398+gregor0410@users.noreply.github.com> Date: Thu, 16 Jan 2025 19:39:51 +0000 Subject: [PATCH] fix rotary hearth furnace not taking energy discount into account when calculating max parallel --- .../gtceu/common/data/GTRecipeModifiers.java | 43 ++++++++++++++----- .../common/data/machines/GCYMMachines.java | 4 +- 2 files changed, 34 insertions(+), 13 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 4f9ea2c2f9..f3738485e0 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeModifiers.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeModifiers.java @@ -149,29 +149,50 @@ public class GTRecipeModifiers { * @return A {@link ModifierFunction} for the given Blast Furnace */ public static @NotNull ModifierFunction ebfOverclock(@NotNull MetaMachine machine, @NotNull GTRecipe recipe) { + var oc = ebfOverclockOnly(machine,recipe); + var discount = ebfDiscount(machine,recipe); + return oc.compose(discount); + } + + private static boolean ebfRecipeRequirementsMet(@NotNull GTRecipe recipe, int blastFurnaceTemperature,CoilWorkableElectricMultiblockMachine coilMachine){ + int recipeTemp = recipe.data.getInt("ebf_temp"); + return (recipe.data.contains("ebf_temp") + && recipeTemp <= blastFurnaceTemperature + && RecipeHelper.getRecipeEUtTier(recipe) <= coilMachine.getTier()); + } + private static int getBlastFurnaceTemperature(CoilWorkableElectricMultiblockMachine coilMachine){ + return coilMachine.getCoilType().getCoilTemperature() + + (100 * Math.max(0, coilMachine.getTier() - GTValues.MV)); + } + + public static @NotNull ModifierFunction ebfOverclockOnly(@NotNull MetaMachine machine, @NotNull GTRecipe recipe) { if (!(machine instanceof CoilWorkableElectricMultiblockMachine coilMachine)) { return RecipeModifier.nullWrongType(CoilWorkableElectricMultiblockMachine.class, machine); } - - int blastFurnaceTemperature = coilMachine.getCoilType().getCoilTemperature() + - (100 * Math.max(0, coilMachine.getTier() - GTValues.MV)); + int blastFurnaceTemperature = getBlastFurnaceTemperature(coilMachine); int recipeTemp = recipe.data.getInt("ebf_temp"); - if (!recipe.data.contains("ebf_temp") || recipeTemp > blastFurnaceTemperature) { + if (!ebfRecipeRequirementsMet(recipe,blastFurnaceTemperature,coilMachine)){ return ModifierFunction.NULL; } - if (RecipeHelper.getRecipeEUtTier(recipe) > coilMachine.getTier()) { + OverclockingLogic logic = (p, v) -> OverclockingLogic.heatingCoilOC(p, v, recipeTemp, blastFurnaceTemperature); + + return logic.getModifier(machine, recipe, coilMachine.getOverclockVoltage()); + } + + public static @NotNull ModifierFunction ebfDiscount(@NotNull MetaMachine machine, @NotNull GTRecipe recipe) { + if (!(machine instanceof CoilWorkableElectricMultiblockMachine coilMachine)) { + return RecipeModifier.nullWrongType(CoilWorkableElectricMultiblockMachine.class, machine); + } + int blastFurnaceTemperature = getBlastFurnaceTemperature(coilMachine); + int recipeTemp = recipe.data.getInt("ebf_temp"); + if (!ebfRecipeRequirementsMet(recipe,blastFurnaceTemperature,coilMachine)){ return ModifierFunction.NULL; } - var discount = ModifierFunction.builder() + return ModifierFunction.builder() .eutMultiplier(getCoilEUtDiscount(recipeTemp, blastFurnaceTemperature)) .build(); - - OverclockingLogic logic = (p, v) -> OverclockingLogic.heatingCoilOC(p, v, recipeTemp, blastFurnaceTemperature); - var oc = logic.getModifier(machine, recipe, coilMachine.getOverclockVoltage()); - - return oc.compose(discount); } /** diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/machines/GCYMMachines.java b/src/main/java/com/gregtechceu/gtceu/common/data/machines/GCYMMachines.java index 2e25302fc5..2cb4fc5d62 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/machines/GCYMMachines.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/machines/GCYMMachines.java @@ -833,8 +833,8 @@ public static void init() {} Component.translatable("gtceu.machine.electric_blast_furnace.tooltip.2")) .rotationState(RotationState.ALL) .recipeType(BLAST_RECIPES) - .recipeModifiers(GTRecipeModifiers.PARALLEL_HATCH, - GTRecipeModifiers::ebfOverclock) + .recipeModifiers(GTRecipeModifiers::ebfDiscount, + GTRecipeModifiers.PARALLEL_HATCH, GTRecipeModifiers::ebfOverclockOnly) .appearanceBlock(CASING_HIGH_TEMPERATURE_SMELTING) .pattern(definition -> { TraceabilityPredicate casing = blocks(CASING_HIGH_TEMPERATURE_SMELTING.get()).setMinGlobalLimited(360);