aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity
diff options
context:
space:
mode:
authorGDCloud <93287602+GDCloudstrike@users.noreply.github.com>2023-01-12 15:33:10 +0100
committerGitHub <noreply@github.com>2023-01-12 15:33:10 +0100
commitbca969349fc7db4ff20eeb78ae956e2142683b43 (patch)
tree9ff0f9f3dc484e1b835411a784a4f9465bf971fa /src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity
parentbf43425a62e78e71c100e70eba933c0717e82a30 (diff)
downloadGT5-Unofficial-bca969349fc7db4ff20eeb78ae956e2142683b43.tar.gz
GT5-Unofficial-bca969349fc7db4ff20eeb78ae956e2142683b43.tar.bz2
GT5-Unofficial-bca969349fc7db4ff20eeb78ae956e2142683b43.zip
Add batch mode to gt++ multis (#486)
* buffs * Base logic * Fixes * Spotless * Social Experiment * swap separate input bus to screwdriver * It lives * Spotless * Fix Massfab * Fix LPF, packager, replicator * address reviews + spotless * address more requested changes * more fixes * fix fix * Spotless
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity')
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
index 7cfe59fa06..b37d042ff9 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
@@ -169,6 +169,9 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex
return this.mTotalRunTime;
}
+ protected float batchMultiplier = 1.0f;
+ protected static final int MAX_BATCH_SIZE = 128;
+
public abstract String getMachineType();
public String getMachineTooltip() {
@@ -967,12 +970,26 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex
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);
@@ -1001,6 +1018,10 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex
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++) {
@@ -2146,6 +2167,7 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex
public void saveNBTData(NBTTagCompound aNBT) {
aNBT.setLong("mTotalRunTime", this.mTotalRunTime);
aNBT.setBoolean("mVoidExcess", this.mVoidExcess);
+ aNBT.setBoolean("mUseMultiparallelMode", mUseMultiparallelMode);
super.saveNBTData(aNBT);
}
@@ -2153,6 +2175,7 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex
public void loadNBTData(NBTTagCompound aNBT) {
this.mTotalRunTime = aNBT.getLong("mTotalRunTime");
this.mVoidExcess = aNBT.getBoolean("mVoidExcess");
+ this.mUseMultiparallelMode = aNBT.getBoolean("mUseMultiparallelMode");
super.loadNBTData(aNBT);
}
@@ -2452,6 +2475,23 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex
return true;
}
+ protected boolean mUseMultiparallelMode = false;
+
+ @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;
+ }
+
public boolean isValidBlockForStructure(
IGregTechTileEntity aBaseMetaTileEntity,
int aCasingID,