From fb8401a6c1f5e83817fe6fed332f6d652e1a2a07 Mon Sep 17 00:00:00 2001 From: HoleFish <48403212+HoleFish@users.noreply.github.com> Date: Fri, 6 Sep 2024 04:22:57 +0800 Subject: Enhance GPL for several multis (#3071) Co-authored-by: Martin Robertz --- .../machines/multi/MTEAssemblyLine.java | 112 ++++++++++++++------- .../machines/multi/MTEIntegratedOreFactory.java | 3 + .../machines/multi/MTELargeChemicalReactor.java | 5 + .../machines/multi/MTEMultiFurnace.java | 6 +- .../tileentities/machines/multi/MTEOilCracker.java | 5 + 5 files changed, 90 insertions(+), 41 deletions(-) (limited to 'src/main/java/gregtech/common/tileentities') diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTEAssemblyLine.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTEAssemblyLine.java index 31456825ba..33e75b7e00 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTEAssemblyLine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTEAssemblyLine.java @@ -60,6 +60,8 @@ import gregtech.api.util.GTRecipe.RecipeAssemblyLine; import gregtech.api.util.GTUtility; import gregtech.api.util.IGTHatchAdder; import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.OverclockCalculator; +import gregtech.api.util.VoidProtectionHelper; public class MTEAssemblyLine extends MTEExtendedPowerMultiBlockBase implements ISurvivalConstructable { @@ -210,8 +212,8 @@ public class MTEAssemblyLine extends MTEExtendedPowerMultiBlockBase inputsFromME = getStoredInputsFromME(); Map fluidsFromME = getStoredFluidsFromME(); @@ -235,16 +237,21 @@ public class MTEAssemblyLine extends MTEExtendedPowerMultiBlockBase averageVoltage * 4) { + result = CheckRecipeResultRegistry.insufficientPower(tRecipe.mEUt); + continue; + } + + // Insufficient power check. + if (tRecipe.mEUt > maxAmp * averageVoltage) { + result = CheckRecipeResultRegistry.insufficientPower(tRecipe.mEUt); continue; } // So here we check against the recipe found on the data stick. // If we run into missing buses/hatches or bad inputs, we go to the next data stick. // This check only happens if we have a valid up-to-date data stick. - // first validate we have enough input busses and input hatches for this recipe if (mInputBusses.size() < tRecipe.mInputs.length || mInputHatches.size() < tRecipe.mFluidInputs.length) { if (GTValues.D1) { @@ -259,15 +266,48 @@ public class MTEAssemblyLine extends MTEExtendedPowerMultiBlockBase 0) { - maxParallel = (int) RecipeAssemblyLine - .maxParallelCalculatedByInputFluids(mInputHatches, maxParallel, tRecipe.mFluidInputs, fluidsFromME); - if (maxParallel <= 0) { + currentParallel = (int) RecipeAssemblyLine.maxParallelCalculatedByInputFluids( + mInputHatches, + currentParallel, + tRecipe.mFluidInputs, + fluidsFromME); + if (currentParallel <= 0) { result = CheckRecipeResultRegistry.NO_RECIPE; continue; } @@ -296,41 +339,29 @@ public class MTEAssemblyLine extends MTEExtendedPowerMultiBlockBase averageVoltage * 4) { - result = CheckRecipeResultRegistry.insufficientPower(tRecipe.mEUt); - continue; - } - - // Insufficient power check. - if (tRecipe.mEUt > maxAmp * averageVoltage) { - result = CheckRecipeResultRegistry.insufficientPower(tRecipe.mEUt); - continue; - } + int currentParallelBeforeBatchMode = Math.min(currentParallel, maxParallelBeforeBatchMode); - calculateOverclockedNessMultiInternal(tRecipe.mEUt, tRecipe.mDuration, (int) maxAmp, averageVoltage, false); - // In case recipe is too OP for that machine - if (lEUt == Long.MAX_VALUE) { - if (GTValues.D1) { - GT_FML_LOGGER.info("Recipe too OP"); - } - result = CheckRecipeResultRegistry.POWER_OVERFLOW; - continue; - } + calculator.setCurrentParallel(currentParallelBeforeBatchMode) + .calculate(); - if (mMaxProgresstime == Integer.MAX_VALUE) { - if (GTValues.D1) { - GT_FML_LOGGER.info("Recipe too OP"); - } - result = CheckRecipeResultRegistry.DURATION_OVERFLOW; - continue; + double batchMultiplierMax = 1; + // In case batch mode enabled + if (currentParallel > maxParallelBeforeBatchMode && calculator.getDuration() < getMaxBatchSize()) { + batchMultiplierMax = (double) getMaxBatchSize() / calculator.getDuration(); + batchMultiplierMax = Math + .min(batchMultiplierMax, (double) currentParallel / maxParallelBeforeBatchMode); } + int finalParallel = (int) (batchMultiplierMax * maxParallelBeforeBatchMode); + lEUt = calculator.getConsumption(); + mMaxProgresstime = (int) (calculator.getDuration() * batchMultiplierMax); + maxParallel = finalParallel; if (GTValues.D1) { GT_FML_LOGGER.info("Find available recipe"); } result = CheckRecipeResultRegistry.SUCCESSFUL; - mOutputItems = new ItemStack[] { tRecipe.mOutput }; + mOutputItems = new ItemStack[] { tRecipe.mOutput.copy() }; + mOutputItems[0].stackSize *= maxParallelBeforeBatchMode * batchMultiplierMax; break; } @@ -472,6 +503,11 @@ public class MTEAssemblyLine extends MTEExtendedPowerMultiBlockBase { DataAccess; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTEIntegratedOreFactory.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTEIntegratedOreFactory.java index 25a54021fa..7de3fb8dbe 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTEIntegratedOreFactory.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTEIntegratedOreFactory.java @@ -322,6 +322,9 @@ public class MTEIntegratedOreFactory extends MTEExtendedPowerMultiBlockBase im ArrayList tInputList = getAllStoredInputs(); if (tInputList.isEmpty()) return CheckRecipeResultRegistry.NO_RECIPE; - long inputVoltage = getMaxInputVoltage(); - int fakeOriginalMaxParallel = 1; - OverclockCalculator calculator = new OverclockCalculator().setEUt(inputVoltage) + OverclockCalculator calculator = new OverclockCalculator().setEUt(getAverageInputVoltage()) + .setAmperage(getMaxInputAmps()) .setRecipeEUt(RECIPE_EUT) .setDuration(RECIPE_DURATION) + .setAmperageOC(mEnergyHatches.size() != 1) .setParallel(fakeOriginalMaxParallel); int maxParallel = this.mLevel; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTEOilCracker.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTEOilCracker.java index 2aac2b5a2e..71c00cc9aa 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTEOilCracker.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTEOilCracker.java @@ -391,6 +391,11 @@ public class MTEOilCracker extends MTEEnhancedMultiBlockBase impl return true; } + @Override + public boolean supportsBatchMode() { + return true; + } + @Override protected void startRecipeProcessing() { for (MTEHatchInput hatch : filterValidMTEs(mMiddleInputHatches)) { -- cgit