diff options
author | Sampsa <69092953+S4mpsa@users.noreply.github.com> | 2022-10-24 23:23:52 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-24 22:23:52 +0200 |
commit | 5112a88b168aa81d158366b02f4f9dc4a3f17006 (patch) | |
tree | 47ae349e3c8b277bb091c8eaa58c8c163236fdfc /src/main | |
parent | 3d38b348e19a3e2cd3676316b8a849bd747b7393 (diff) | |
download | GT5-Unofficial-5112a88b168aa81d158366b02f4f9dc4a3f17006.tar.gz GT5-Unofficial-5112a88b168aa81d158366b02f4f9dc4a3f17006.tar.bz2 GT5-Unofficial-5112a88b168aa81d158366b02f4f9dc4a3f17006.zip |
Add balanced batch mode to MEBF, MVF, MCR & MDT (#225)
* Add batch mode to Mega Blast Furnace
* Add batch mode to Mega Chemical Reactor and Mega Vacuum Freezer
* Apply spotless
* do required changes
* fix wrong eu/t being used when batch mode is enabled
* Fix batchmode to be a float and add MDT to batching mode
* Spotless apply for branch batch_megas for #220 (#222)
* Fix EIG structure tooltip (#221)
* Added coil and glass count to the tooltip
* Fixed EIG structure tooltip
* spotlessApply
Co-authored-by: Maxim <maxim235@gmx.de>
Co-authored-by: Sampsa <69092953+S4mpsa@users.noreply.github.com>
Co-authored-by: GitHub GTNH Actions <>
* Fix imports hopefully
* Spotless apply for branch batch_megas for #220 (#223)
* Fix EIG structure tooltip (#221)
* Added coil and glass count to the tooltip
* Fixed EIG structure tooltip
* spotlessApply
Co-authored-by: Maxim <maxim235@gmx.de>
Co-authored-by: Sampsa <69092953+S4mpsa@users.noreply.github.com>
Co-authored-by: GitHub GTNH Actions <>
* do Sampsas wanted changes
* Spotless apply for branch batch_megas for #220 (#224)
* Fix EIG structure tooltip (#221)
* Added coil and glass count to the tooltip
* Fixed EIG structure tooltip
* spotlessApply
Co-authored-by: Maxim <maxim235@gmx.de>
Co-authored-by: Sampsa <69092953+S4mpsa@users.noreply.github.com>
Co-authored-by: GitHub GTNH Actions <>
* Simplify logic, remove batch mode tick limit bypass
* Apply spotless
* Fix unintentional speedup of batches less than 256
Co-authored-by: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com>
Co-authored-by: PGE Programirane <pge-programirane@abv.bg>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Maxim <maxim235@gmx.de>
Former-commit-id: 3ba950f0f7852e20ee08dac6ae119da7fd880ad8
Diffstat (limited to 'src/main')
5 files changed, 179 insertions, 13 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java index 3ab76bcef1..67dc33c702 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java @@ -223,10 +223,12 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_TileEntity_MegaMultiBlock this.circuitMode = aNBT.getByte("circuitMode"); this.glasTier = aNBT.getByte("glasTier"); this.isBussesSeparate = aNBT.getBoolean("isBussesSeparate"); + this.mUseMultiparallelMode = aNBT.getBoolean("mUseMultiparallelMode"); } private byte circuitMode = 0; private boolean isBussesSeparate = false; + private boolean mUseMultiparallelMode = false; @Override public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { @@ -246,10 +248,20 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_TileEntity_MegaMultiBlock @Override public boolean onWireCutterRightClick( byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - isBussesSeparate = !isBussesSeparate; - GT_Utility.sendChatToPlayer( - aPlayer, StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + isBussesSeparate); - return true; + if (aPlayer.isSneaking()) { + mUseMultiparallelMode = !mUseMultiparallelMode; + if (mUseMultiparallelMode) { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); + } else { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); + } + return true; + } else { + isBussesSeparate = !isBussesSeparate; + GT_Utility.sendChatToPlayer( + aPlayer, StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + isBussesSeparate); + return true; + } } @Override @@ -296,6 +308,7 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_TileEntity_MegaMultiBlock aNBT.setByte("glasTier", glasTier); aNBT.setByte("circuitMode", circuitMode); aNBT.setBoolean("isBussesSeparate", isBussesSeparate); + aNBT.setBoolean("mUseMultiparallelMode", mUseMultiparallelMode); } @Override @@ -402,12 +415,17 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_TileEntity_MegaMultiBlock long precutRecipeVoltage = (long) (tRecipe.mEUt * Math.pow(0.95, tHeatCapacityDivTiers)); long tMaxPara = Math.min(ConfigHandler.megaMachinesMax, nominalV / precutRecipeVoltage); - + if (mUseMultiparallelMode && tMaxPara == ConfigHandler.megaMachinesMax) { + tMaxPara *= 128; + } + float tBatchMultiplier = 1.0f; if (this.mHeatingCapacity >= tRecipe.mSpecialValue) { int tCurrentPara = handleParallelRecipe(tRecipe, tFluids, tInputs, (int) tMaxPara); + tBatchMultiplier = + mUseMultiparallelMode ? (float) Math.max(tCurrentPara / ConfigHandler.megaMachinesMax, 1.0f) : 1.0f; this.updateSlots(); if (tCurrentPara <= 0) return false; - processed = tCurrentPara; + processed = Math.min(tCurrentPara, ConfigHandler.megaMachinesMax); found_Recipe = true; Pair<ArrayList<FluidStack>, ArrayList<ItemStack>> Outputs = getMultiOutput(tRecipe, tCurrentPara); outputFluids = Outputs.getKey(); @@ -419,6 +437,7 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_TileEntity_MegaMultiBlock this.mEfficiencyIncrease = 10000; long actualEUT = precutRecipeVoltage * processed; + byte overclockCount = this.calculateOverclockedNessMultiInternal(actualEUT, tRecipe.mDuration, nominalV, false); @@ -433,6 +452,10 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_TileEntity_MegaMultiBlock if (this.mMaxProgresstime < 1) this.mMaxProgresstime = 1; // no eu efficiency correction } + if (mUseMultiparallelMode) { + this.mMaxProgresstime = (int) Math.ceil(this.mMaxProgresstime * tBatchMultiplier); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); this.polPtick = ConfigHandler.basePollutionMBFSecond / 20 * processed; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java index 1a9b1e7130..b65ff1697c 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java @@ -55,9 +55,12 @@ import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import java.util.ArrayList; import java.util.Collection; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.FluidStack; @Optional.Interface( @@ -158,6 +161,35 @@ public class GT_TileEntity_MegaChemicalReactor return false; } // TO IMPLEMENT + private boolean mUseMultiparallelMode = false; + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mUseMultiparallelMode", mUseMultiparallelMode); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mUseMultiparallelMode = aNBT.getBoolean("mUseMultiparallelMode"); + } + + @Override + public boolean onWireCutterRightClick( + byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + mUseMultiparallelMode = !mUseMultiparallelMode; + if (mUseMultiparallelMode) { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); + } else { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); + } + return true; + } + return false; + } + @Override public boolean checkRecipe(ItemStack itemStack) { ItemStack[] tInputs = this.getStoredInputs().toArray(new ItemStack[0]); @@ -174,16 +206,24 @@ public class GT_TileEntity_MegaChemicalReactor this.getBaseMetaTileEntity(), false, V[tTier], tInputFluids, tInputs); boolean found_Recipe = false; int processed = 0; + float tBatchMultiplier = 1.0f; if (tRecipe != null) { found_Recipe = true; long tMaxPara = Math.min(ConfigHandler.megaMachinesMax, nominalV / tRecipe.mEUt); + if (mUseMultiparallelMode && tMaxPara == ConfigHandler.megaMachinesMax) { + tMaxPara *= 128; + } + int tCurrentPara = handleParallelRecipe(tRecipe, tInputFluids, tInputs, (int) tMaxPara); + tBatchMultiplier = + mUseMultiparallelMode ? (float) Math.max(tCurrentPara / ConfigHandler.megaMachinesMax, 1.0f) : 1.0f; + this.updateSlots(); if (tCurrentPara <= 0) { return false; } - processed = tCurrentPara; + processed = Math.min(tCurrentPara, ConfigHandler.megaMachinesMax); Pair<ArrayList<FluidStack>, ArrayList<ItemStack>> Outputs = getMultiOutput(tRecipe, tCurrentPara); outputFluids = Outputs.getKey(); outputItems = Outputs.getValue(); @@ -192,12 +232,19 @@ public class GT_TileEntity_MegaChemicalReactor if (found_Recipe) { this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; - long actualEUT = ((long) tRecipe.mEUt) * processed; + + long actualEUT = (long) (tRecipe.mEUt) * processed; + calculatePerfectOverclockedNessMulti(actualEUT, tRecipe.mDuration, nominalV); // In case recipe is too OP for that machine if (this.mMaxProgresstime == Integer.MAX_VALUE - 1 && this.lEUt == Integer.MAX_VALUE - 1) { return false; } + + if (mUseMultiparallelMode) { + this.mMaxProgresstime = (int) Math.ceil(this.mMaxProgresstime * tBatchMultiplier); + } + if (this.lEUt > 0) { this.lEUt = (-this.lEUt); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaDistillTower.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaDistillTower.java index c6b2954f90..c7e5c9b934 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaDistillTower.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaDistillTower.java @@ -57,10 +57,13 @@ import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import java.util.ArrayList; import java.util.List; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.FluidStack; @Optional.Interface( @@ -515,6 +518,35 @@ public class GT_TileEntity_MegaDistillTower extends GT_TileEntity_MegaMultiBlock STRUCTURE_PIECE_TOP_HINT, stackSize, 7, 5 * mHeight, 0, realBudget, source, actor, false, true); } + private boolean mUseMultiparallelMode = false; + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mUseMultiparallelMode", mUseMultiparallelMode); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mUseMultiparallelMode = aNBT.getBoolean("mUseMultiparallelMode"); + } + + @Override + public boolean onWireCutterRightClick( + byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + mUseMultiparallelMode = !mUseMultiparallelMode; + if (mUseMultiparallelMode) { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); + } else { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); + } + return true; + } + return false; + } + @Override public boolean checkRecipe(ItemStack aStack) { @@ -548,13 +580,19 @@ public class GT_TileEntity_MegaDistillTower extends GT_TileEntity_MegaMultiBlock boolean found_Recipe = false; GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sDistillationRecipes.findRecipe( this.getBaseMetaTileEntity(), false, GT_Values.V[tTier], new FluidStack[] {tFluid}, tItems); - + float tBatchMultiplier = 1.0f; if (tRecipe != null) { found_Recipe = true; long tMaxPara = Math.min(ConfigHandler.megaMachinesMax, nominalV / tRecipe.mEUt); + if (mUseMultiparallelMode && tMaxPara == ConfigHandler.megaMachinesMax) { + tMaxPara *= 128; + } int tCurrentPara = handleParallelRecipe(tRecipe, new FluidStack[] {tFluid}, null, (int) tMaxPara); + tBatchMultiplier = mUseMultiparallelMode + ? (float) Math.max(tCurrentPara / ConfigHandler.megaMachinesMax, 1.0f) + : 1.0f; this.updateSlots(); - processed = tCurrentPara; + processed = Math.min(tCurrentPara, ConfigHandler.megaMachinesMax); Outputs = getMultiOutput(tRecipe, tCurrentPara); outputFluids = Outputs.getKey(); outputItems = Outputs.getValue(); @@ -563,13 +601,21 @@ public class GT_TileEntity_MegaDistillTower extends GT_TileEntity_MegaMultiBlock if (!found_Recipe) continue; this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; - long actualEUT = ((long) tRecipe.mEUt) * processed; + + long actualEUT = (long) (tRecipe.mEUt) * processed; + calculateOverclockedNessMulti(actualEUT, tRecipe.mDuration, nominalV); + // In case recipe is too OP for that machine if (this.mMaxProgresstime == Integer.MAX_VALUE - 1 && this.lEUt == Integer.MAX_VALUE - 1) return false; if (this.lEUt > 0) { this.lEUt = (-this.lEUt); } + + if (mUseMultiparallelMode) { + this.mMaxProgresstime = (int) Math.ceil(this.mMaxProgresstime * tBatchMultiplier); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); this.mOutputFluids = outputFluids.toArray(new FluidStack[0]); if (!outputItems.isEmpty()) this.mOutputItems = outputItems.toArray(new ItemStack[0]); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java index 93f6cf6aa3..c77a0a7af9 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java @@ -51,9 +51,12 @@ import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import java.util.ArrayList; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.FluidStack; @Optional.Interface( @@ -404,6 +407,35 @@ public class GT_TileEntity_MegaVacuumFreezer extends GT_TileEntity_MegaMultiBloc aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "VacuumFreezer.png"); } + private boolean mUseMultiparallelMode = false; + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mUseMultiparallelMode", mUseMultiparallelMode); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mUseMultiparallelMode = aNBT.getBoolean("mUseMultiparallelMode"); + } + + @Override + public boolean onWireCutterRightClick( + byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + mUseMultiparallelMode = !mUseMultiparallelMode; + if (mUseMultiparallelMode) { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); + } else { + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); + } + return true; + } + return false; + } + @Override public boolean checkRecipe(ItemStack itemStack) { ItemStack[] tInputs = this.getStoredInputs().toArray(new ItemStack[0]); @@ -420,14 +452,23 @@ public class GT_TileEntity_MegaVacuumFreezer extends GT_TileEntity_MegaMultiBloc this.getBaseMetaTileEntity(), false, V[tTier], tInputFluids, tInputs); boolean found_Recipe = false; int processed = 0; + float tBatchMultiplier = 1.0f; if (tRecipe != null) { found_Recipe = true; long tMaxPara = Math.min(ConfigHandler.megaMachinesMax, nominalV / tRecipe.mEUt); + + if (mUseMultiparallelMode && tMaxPara == ConfigHandler.megaMachinesMax) { + tMaxPara *= 128; + } + int tCurrentPara = handleParallelRecipe(tRecipe, tInputFluids, tInputs, (int) tMaxPara); + tBatchMultiplier = + mUseMultiparallelMode ? (float) Math.max(tCurrentPara / ConfigHandler.megaMachinesMax, 1.0f) : 1.0f; + this.updateSlots(); if (tCurrentPara <= 0) return false; - processed = tCurrentPara; + processed = Math.min(tCurrentPara, ConfigHandler.megaMachinesMax); Pair<ArrayList<FluidStack>, ArrayList<ItemStack>> Outputs = getMultiOutput(tRecipe, tCurrentPara); outputFluids = Outputs.getKey(); outputItems = Outputs.getValue(); @@ -436,13 +477,19 @@ public class GT_TileEntity_MegaVacuumFreezer extends GT_TileEntity_MegaMultiBloc if (found_Recipe) { this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; + long actualEUT = (long) (tRecipe.mEUt) * processed; - calculateOverclockedNessMulti((int) actualEUT, tRecipe.mDuration, nominalV); + calculateOverclockedNessMulti(actualEUT, tRecipe.mDuration, nominalV); // In case recipe is too OP for that machine if (this.mMaxProgresstime == Integer.MAX_VALUE - 1 && this.lEUt == Integer.MAX_VALUE - 1) return false; if (this.lEUt > 0) { this.lEUt = (-this.lEUt); } + + if (mUseMultiparallelMode) { + this.mMaxProgresstime = (int) Math.ceil(this.mMaxProgresstime * tBatchMultiplier); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); this.mOutputItems = new ItemStack[outputItems.size()]; this.mOutputItems = outputItems.toArray(this.mOutputItems); diff --git a/src/main/resources/assets/bartworks/lang/en_US.lang b/src/main/resources/assets/bartworks/lang/en_US.lang index e581657820..62e21aa642 100644 --- a/src/main/resources/assets/bartworks/lang/en_US.lang +++ b/src/main/resources/assets/bartworks/lang/en_US.lang @@ -174,4 +174,7 @@ BW.infoData.BioVat.production=Production BW.NEI.display.radhatch.0=Sievert: %s Sv BW.NEI.display.radhatch.1=Mass: %s kg BW.NEI.display.radhatch.2=Time: %s s + +misc.BatchModeTextOn=Batch recipes +misc.BatchModeTextOff=Don't batch recipes #Liquids |