diff options
| author | BlueWeabo <76872108+BlueWeabo@users.noreply.github.com> | 2023-01-23 22:23:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-23 21:23:01 +0100 |
| commit | 7366deae4a0e4404799ab17dfde0a7ba7d4cb54f (patch) | |
| tree | af5fe5b69b75b0ab554603f75d2e9005b4fd3549 /src/main/java/gtPlusPlus/xmod/gregtech/common | |
| parent | 4c31639896b6360056af7fa8810a581d17cc97b1 (diff) | |
| download | GT5-Unofficial-7366deae4a0e4404799ab17dfde0a7ba7d4cb54f.tar.gz GT5-Unofficial-7366deae4a0e4404799ab17dfde0a7ba7d4cb54f.tar.bz2 GT5-Unofficial-7366deae4a0e4404799ab17dfde0a7ba7d4cb54f.zip | |
Use GT_ParallelHelper for GT++ (#511)
* everything
* remove more useless code
* spotless
* fix missed multis
* actually put efficiency oop
* late night coding
* missed one
* last one
* fix tgs
* remove useless code, which was used for debugging
* spotless
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/common')
17 files changed, 423 insertions, 2053 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java index 9c064c3973..bf9e9f3d94 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java @@ -5,7 +5,6 @@ import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElement import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.GT_HatchElement.*; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -29,10 +28,8 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import java.util.ArrayList; -import java.util.List; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.ArrayUtils; public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase<GMTE_AmazonPackager> implements ISurvivalConstructable { @@ -239,191 +236,6 @@ public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase<GMTE_Amazon return false; } - @Override - public boolean checkRecipeGeneric( - ItemStack[] aItemInputs, - FluidStack[] aFluidInputs, - int aMaxParallelRecipes, - long aEUPercent, - int aSpeedBonusPercent, - int aOutputChanceRoll, - GT_Recipe aRecipe) { - // Based on the Processing Array. A bit overkill, but very flexible. - - // Reset outputs and progress stats - this.lEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - log("Running checkRecipeGeneric(0)"); - - GT_Recipe tRecipe = findRecipe( - getBaseMetaTileEntity(), - mLastRecipe, - false, - false, - gregtech.api.enums.GT_Values.V[tTier], - aFluidInputs, - aItemInputs); - - log("Running checkRecipeGeneric(1)"); - this.mLastRecipe = tRecipe; - - if (tRecipe == null) { - log("BAD RETURN - 1"); - return false; - } - - aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); - if (aMaxParallelRecipes == 0) { - log("BAD RETURN - 2"); - return false; - } - - // EU discount - float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; - float tTotalEUt = 0.0f; - - int parallelRecipes = 0; - - log("parallelRecipes: " + parallelRecipes); - log("aMaxParallelRecipes: " + aMaxParallelRecipes); - log("tTotalEUt: " + tTotalEUt); - log("tVoltage: " + tVoltage); - log("tRecipeEUt: " + tRecipeEUt); - // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { - if (!tRecipe.isRecipeInputEqual(true, sNoFluids, aItemInputs)) { - log("Broke at " + parallelRecipes + "."); - break; - } - log("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); - tTotalEUt += tRecipeEUt; - } - - if (parallelRecipes == 0) { - log("BAD RETURN - 3"); - return false; - } - - if (mUseMultiparallelMode) { - int extraParallelRecipes = 0; - for (; - extraParallelRecipes + parallelRecipes < aMaxParallelRecipes * MAX_BATCH_SIZE; - extraParallelRecipes++) { - if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { - break; - } - } - batchMultiplier = 1.0f + (float) extraParallelRecipes / aMaxParallelRecipes; - parallelRecipes += extraParallelRecipes; - } - - // -- Try not to fail after this point - inputs have already been consumed! -- - - // Convert speed bonus to duration multiplier - // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. - aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); - float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); - - this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor); - this.lEUt = (long) Math.ceil(tTotalEUt); - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - // Overclock - if (this.lEUt <= 16) { - this.lEUt = (this.lEUt * (1L << tTier - 1) * (1L << tTier - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); - } else { - while (this.lEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.lEUt *= 4; - if (this.hasPerfectOverclock()) this.mMaxProgresstime /= 4; - else this.mMaxProgresstime /= 2; - } - } - - if (this.lEUt > 0) { - this.lEUt = (-this.lEUt); - } - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - if (mUseMultiparallelMode) { - mMaxProgresstime = (int) Math.ceil(mMaxProgresstime * batchMultiplier); - } - - // Collect fluid outputs - FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; - for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { - if (tRecipe.getFluidOutput(h) != null) { - tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); - tOutputFluids[h].amount *= parallelRecipes; - } - } - - // Collect output item types - ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; - for (int h = 0; h < tRecipe.mOutputs.length; h++) { - if (tRecipe.getOutput(h) != null) { - tOutputItems[h] = tRecipe.getOutput(h).copy(); - tOutputItems[h].stackSize = 0; - } - } - - // Set output item stack sizes (taking output chance into account) - for (int f = 0; f < tOutputItems.length; f++) { - if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { - for (int g = 0; g < parallelRecipes; g++) { - if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) - tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - - tOutputItems = removeNulls(tOutputItems); - - // Sanitize item stack size, splitting any stacks greater than max stack size - List<ItemStack> splitStacks = new ArrayList<ItemStack>(); - for (ItemStack tItem : tOutputItems) { - while (tItem.getMaxStackSize() < tItem.stackSize) { - ItemStack tmp = tItem.copy(); - tmp.stackSize = tmp.getMaxStackSize(); - tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); - splitStacks.add(tmp); - } - } - - if (splitStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[splitStacks.size()]; - tmp = splitStacks.toArray(tmp); - tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); - } - - // Strip empty stacks - List<ItemStack> tSList = new ArrayList<ItemStack>(); - for (ItemStack tS : tOutputItems) { - if (tS.stackSize > 0) tSList.add(tS); - } - tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); - - // Commit outputs - this.mOutputItems = tOutputItems; - this.mOutputFluids = tOutputFluids; - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - - log("GOOD RETURN - 1"); - return true; - } - public boolean allowPutStack(final ItemStack aStack, ItemStack schematicStack) { // If Schematic Static is not 1x1, 2x2, 3x3 if (!ItemList.Schematic_1by1.isStackEqual((Object) schematicStack) diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialAlloySmelter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialAlloySmelter.java index 9144c3e0eb..0dc2303a0e 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialAlloySmelter.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialAlloySmelter.java @@ -6,7 +6,6 @@ import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose import static gregtech.api.enums.GT_HatchElement.*; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; import static gregtech.api.util.GT_StructureUtility.ofCoil; -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -20,6 +19,8 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_OverclockCalculator; +import gregtech.api.util.GT_ParallelHelper; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; @@ -27,10 +28,8 @@ import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import java.util.ArrayList; -import java.util.List; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.ArrayUtils; public class GregtechMetaTileEntity_IndustrialAlloySmelter extends GregtechMeta_MultiBlockBase<GregtechMetaTileEntity_IndustrialAlloySmelter> @@ -229,7 +228,6 @@ public class GregtechMetaTileEntity_IndustrialAlloySmelter long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); long tEnergy = getMaxInputEnergy(); - Logger.WARNING("Running checkRecipeGeneric(0)"); GT_Recipe tRecipe = this.getRecipeMap() .findRecipe( @@ -240,7 +238,6 @@ public class GregtechMetaTileEntity_IndustrialAlloySmelter aFluidInputs, aItemInputs); - Logger.WARNING("Running checkRecipeGeneric(1)"); // Remember last recipe - an optimization for findRecipe() this.mLastRecipe = tRecipe; @@ -249,127 +246,53 @@ public class GregtechMetaTileEntity_IndustrialAlloySmelter return false; } - aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); - if (aMaxParallelRecipes == 0) { - Logger.WARNING("BAD RETURN - 2"); - return false; + GT_ParallelHelper helper = new GT_ParallelHelper() + .setRecipe(tRecipe) + .setItemInputs(aItemInputs) + .setFluidInputs(aFluidInputs) + .setAvailableEUt(tEnergy) + .setMaxParallel(aMaxParallelRecipes) + .enableConsumption() + .enableOutputCalculation(); + if (!mVoidExcess) { + helper.enableVoidProtection(this); } - // EU discount - float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; - int tHeatCapacityDivTiers = (int) mHeatingCapacity.getHeat() / 900; - float tTotalEUt = 0.0f; - - int parallelRecipes = 0; - // Count recipes to do in parallel, consuming input items and fluids and - // considering input voltage limits - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { - if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { - Logger.WARNING("Broke at " + parallelRecipes + "."); - break; - } - Logger.WARNING("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); - tTotalEUt += tRecipeEUt; + if (mUseMultiparallelMode) { + helper.enableBatchMode(128); } - if (parallelRecipes == 0) { - Logger.WARNING("BAD RETURN - 3"); + helper.build(); + + if (helper.getCurrentParallel() == 0) { return false; } - // -- Try not to fail after this point - inputs have already been consumed! -- - - // Convert speed bonus to duration multiplier - // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. - aSpeedBonusPercent = mLevel * 5; - float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); - this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor); - int rInt = 2; - - this.lEUt = (long) Math.max(Math.ceil(tTotalEUt), 1); - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; - // Overclock - if (this.lEUt <= 16) { - this.lEUt = (this.lEUt * (1L << tTier - 1) * (1L << tTier - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); - } else { - while (this.lEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.lEUt *= 4; - this.mMaxProgresstime /= (tHeatCapacityDivTiers >= rInt ? 4 : 2); - } - } - if (this.lEUt > 0) { - this.lEUt = (-this.lEUt); - } - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - // Collect fluid outputs - FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; - for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { - if (tRecipe.getFluidOutput(h) != null) { - tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); - tOutputFluids[h].amount *= parallelRecipes; - } - } - - // Collect output item types - ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; - for (int h = 0; h < tRecipe.mOutputs.length; h++) { - if (tRecipe.getOutput(h) != null) { - tOutputItems[h] = tRecipe.getOutput(h).copy(); - tOutputItems[h].stackSize = 0; - } - } - - // Set output item stack sizes (taking output chance into account) - for (int f = 0; f < tOutputItems.length; f++) { - if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { - for (int g = 0; g < parallelRecipes; g++) { - if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) - tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - - tOutputItems = removeNulls(tOutputItems); - - // Sanitize item stack size, splitting any stacks greater than max stack size - List<ItemStack> splitStacks = new ArrayList<ItemStack>(); - for (ItemStack tItem : tOutputItems) { - while (tItem.getMaxStackSize() < tItem.stackSize) { - ItemStack tmp = tItem.copy(); - tmp.stackSize = tmp.getMaxStackSize(); - tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); - splitStacks.add(tmp); - } - } - - if (splitStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[splitStacks.size()]; - tmp = splitStacks.toArray(tmp); - tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); - } - - // Strip empty stacks - List<ItemStack> tSList = new ArrayList<ItemStack>(); - for (ItemStack tS : tOutputItems) { - if (tS.stackSize > 0) tSList.add(tS); - } - tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); - - // Commit outputs - this.mOutputItems = tOutputItems; - this.mOutputFluids = tOutputFluids; + GT_OverclockCalculator calculator = new GT_OverclockCalculator() + .setRecipeEUt(tRecipe.mEUt) + .setEUt(tEnergy) + .setDuration(tRecipe.mDuration) + .setEUtDiscount(aEUPercent / 100.0f) + .setSpeedBoost(100.0f / (100.0f + aSpeedBonusPercent)) + .setParallel(Math.min(aMaxParallelRecipes, helper.getCurrentParallel())) + .enableHeatOC() + .setRecipeHeat(0) + // Need to multiple by 2 because heat OC is done only once every 1800 and this one does it once every + // 900 + .setMultiHeat((int) getCoilLevel().getHeat() * 2) + .calculate(); + lEUt = -calculator.getConsumption(); + mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplier()); + + mOutputItems = helper.getItemOutputs(); + mOutputFluids = helper.getFluidOutputs(); updateSlots(); // Play sounds (GT++ addition - GT multiblocks play no sounds) startProcess(); - - Logger.WARNING("GOOD RETURN - 1"); return true; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java index 6250d34dab..4316cf936d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java @@ -5,7 +5,6 @@ import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElement import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.GT_HatchElement.*; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -16,6 +15,8 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_OverclockCalculator; +import gregtech.api.util.GT_ParallelHelper; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.block.ModBlocks; @@ -28,7 +29,6 @@ import java.util.List; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.ArrayUtils; import team.chisel.carving.Carving; public class GregtechMetaTileEntity_IndustrialChisel @@ -234,7 +234,6 @@ public class GregtechMetaTileEntity_IndustrialChisel GT_Recipe tRecipe = generateChiselRecipe(aItems.get(0), this.getGUIItemStack()); if (tRecipe == null) { - log("BAD RETURN - 0"); return false; } @@ -249,11 +248,7 @@ public class GregtechMetaTileEntity_IndustrialChisel this.mOutputFluids = new FluidStack[] {}; long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); long tEnergy = getMaxInputEnergy(); - log("Running checkRecipeGeneric(0)"); - - log("Running checkRecipeGeneric(1)"); // Remember last recipe - an optimization for findRecipe() this.mLastRecipe = tRecipe; @@ -261,136 +256,48 @@ public class GregtechMetaTileEntity_IndustrialChisel int aEUPercent = getEuDiscountForParallelism(); int aSpeedBonusPercent = 200; - aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); - if (aMaxParallelRecipes == 0) { - log("BAD RETURN - 2"); - return false; + GT_ParallelHelper helper = new GT_ParallelHelper() + .setRecipe(tRecipe) + .setItemInputs(aItemInputs) + .setFluidInputs(aFluidInputs) + .setAvailableEUt(tEnergy) + .setMaxParallel(aMaxParallelRecipes) + .enableConsumption() + .enableOutputCalculation(); + if (!mVoidExcess) { + helper.enableVoidProtection(this); } - // EU discount - float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; - float tTotalEUt = 0.0f; - - int parallelRecipes = 0; - - log("parallelRecipes: " + parallelRecipes); - log("aMaxParallelRecipes: " + aMaxParallelRecipes); - log("tTotalEUt: " + tTotalEUt); - log("tVoltage: " + tVoltage); - log("tRecipeEUt: " + tRecipeEUt); - // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { - if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { - log("Broke at " + parallelRecipes + "."); - break; - } - log("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); - tTotalEUt += tRecipeEUt; + if (mUseMultiparallelMode) { + helper.enableBatchMode(128); } - if (parallelRecipes == 0) { - log("BAD RETURN - 3"); + helper.build(); + + if (helper.getCurrentParallel() == 0) { return false; } - // -- Try not to fail after this point - inputs have already been consumed! -- - log("parallelRecipes: " + parallelRecipes); - log("aMaxParallelRecipes: " + aMaxParallelRecipes); - log("tTotalEUt: " + tTotalEUt); - log("tVoltage: " + tVoltage); - log("tRecipeEUt: " + tRecipeEUt); - - // Convert speed bonus to duration multiplier - // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. - aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); - float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); - this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor); - - this.lEUt = (long) Math.ceil(tTotalEUt); - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; - // Overclock - if (this.lEUt <= 16) { - this.lEUt = (this.lEUt * (1L << tTier - 1) * (1L << tTier - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); - } else { - while (this.lEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.lEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - - if (this.lEUt > 0) { - this.lEUt = (-this.lEUt); - } - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - // Collect fluid outputs - FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; - for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { - if (tRecipe.getFluidOutput(h) != null) { - tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); - tOutputFluids[h].amount *= parallelRecipes; - } - } - - // Collect output item types - ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; - for (int h = 0; h < tRecipe.mOutputs.length; h++) { - if (tRecipe.getOutput(h) != null) { - tOutputItems[h] = tRecipe.getOutput(h).copy(); - tOutputItems[h].stackSize = 0; - } - } - - // Set output item stack sizes (taking output chance into account) - for (int f = 0; f < tOutputItems.length; f++) { - if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { - for (int g = 0; g < parallelRecipes; g++) { - if (getBaseMetaTileEntity().getRandomNumber(10000) <= tRecipe.getOutputChance(f)) - tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - - tOutputItems = removeNulls(tOutputItems); - - // Sanitize item stack size, splitting any stacks greater than max stack size - List<ItemStack> splitStacks = new ArrayList<ItemStack>(); - for (ItemStack tItem : tOutputItems) { - while (tItem.getMaxStackSize() < tItem.stackSize) { - ItemStack tmp = tItem.copy(); - tmp.stackSize = tmp.getMaxStackSize(); - tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); - splitStacks.add(tmp); - } - } - - if (splitStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[splitStacks.size()]; - tmp = splitStacks.toArray(tmp); - tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); - } - - // Strip empty stacks - List<ItemStack> tSList = new ArrayList<ItemStack>(); - for (ItemStack tS : tOutputItems) { - if (tS.stackSize > 0) tSList.add(tS); - } - tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); - - // Commit outputs - this.mOutputItems = tOutputItems; - this.mOutputFluids = tOutputFluids; + GT_OverclockCalculator calculator = new GT_OverclockCalculator() + .setRecipeEUt(tRecipe.mEUt) + .setEUt(tEnergy) + .setDuration(tRecipe.mDuration) + .setEUtDiscount(aEUPercent / 100.0f) + .setSpeedBoost(100.0f / (100.0f + aSpeedBonusPercent)) + .setParallel(Math.min(aMaxParallelRecipes, helper.getCurrentParallel())) + .calculate(); + lEUt = -calculator.getConsumption(); + mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplier()); + + mOutputItems = helper.getItemOutputs(); + mOutputFluids = helper.getFluidOutputs(); updateSlots(); // Play sounds (GT++ addition - GT multiblocks play no sounds) startProcess(); - - log("GOOD RETURN - 1"); return true; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java index 320ff62f29..3fd71a56d2 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java @@ -6,7 +6,6 @@ import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose import static gregtech.api.enums.GT_HatchElement.*; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; import static gregtech.api.util.GT_StructureUtility.ofCoil; -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -19,22 +18,20 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_OverclockCalculator; +import gregtech.api.util.GT_ParallelHelper; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtP |
