diff options
author | NotAPenguin <michiel.vandeginste@gmail.com> | 2024-03-15 06:45:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-15 06:45:28 +0100 |
commit | 12e48e706fce30084ff349d68139be4729dab6bf (patch) | |
tree | 1739ae65a8e844728fe6c97282820c995400c86b | |
parent | b9fca3bf7df8c0c2046bbefeeb25896cc39eea7b (diff) | |
download | GT5-Unofficial-12e48e706fce30084ff349d68139be4729dab6bf.tar.gz GT5-Unofficial-12e48e706fce30084ff349d68139be4729dab6bf.tar.bz2 GT5-Unofficial-12e48e706fce30084ff349d68139be4729dab6bf.zip |
Fix batch mode slowing down groups of multiple AAL (#35)
Uses the amount of fluid available instead of amount of first item to
limit batch count. Setups can then use regular input hatches to make
sure a group of multiple AALs doesn't "steal" batches from other AALs
connected to the same item inputs, which would slow down the entire
craft.
Addresses the final issue of #32
-rw-r--r-- | src/main/java/net/glease/ggfab/mte/MTE_AdvAssLine.java | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/main/java/net/glease/ggfab/mte/MTE_AdvAssLine.java b/src/main/java/net/glease/ggfab/mte/MTE_AdvAssLine.java index 7bdba48995..9bb97a0f76 100644 --- a/src/main/java/net/glease/ggfab/mte/MTE_AdvAssLine.java +++ b/src/main/java/net/glease/ggfab/mte/MTE_AdvAssLine.java @@ -644,6 +644,14 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas return itemInputsCurBatch[index]; } + private FluidStack getInputHatchContent(int index) { + GT_MetaTileEntity_Hatch_Input tInputHatch = mInputHatches.get(index); + if (!tInputHatch.isValid()) { + return null; + } + return tInputHatch.mFluid; + } + private GT_Recipe.GT_Recipe_AssemblyLine findRecipe(ItemStack tDataStick) { GT_AssemblyLineUtils.LookupResult tLookupResult = GT_AssemblyLineUtils .findAssemblyLineRecipeFromDataStick(tDataStick, false); @@ -813,11 +821,19 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas // Note that we skip this entirely if the time for each slice is more than // BATCH_MODE_DESIRED_TICKS_PER_SLICE ticks, since in this case the amount of batches will always be 1 if (super.isBatchModeEnabled() && timePerSlice < BATCH_MODE_DESIRED_TICKS_PER_SLICE) { - // Calculate parallel based on time per slice, and the amount of items in the first slot. - // If there is not enough fluid, no batching will be done. - - ItemStack firstItemSlot = getInputBusContent(0); - int recipesAvailable = Math.floorDiv(firstItemSlot.stackSize, recipe.mInputs[0].stackSize); + // Calculate parallel based on time per slice, and the amount of fluid in the first fluid slot. + // We use fluid, since this way players can limit parallel by controlling how much fluid + // ends up in each AAL. This way, batch mode will not slow down setups where multiple AAL + // are connected to the same set of input items. Note that this will still suffer from the same + // issue if using stocking hatch, but in this case increasing pattern size can help. + + // Note that every assline recipe has a fluid ingredient. + FluidStack firstFluidSlot = getInputHatchContent(0); + if (firstFluidSlot == null) { + // No input hatch, no valid recipe - this should be impossible. + break; + } + int recipesAvailable = Math.floorDiv(firstFluidSlot.amount, recipe.mFluidInputs[0].amount); // Divide recipes available by the amount of slices in the recipe. This will prevent the AAL from // batching instead of parallelizing, which would make it effectively slower. recipesAvailable = Math.floorDiv(recipesAvailable, recipe.mInputs.length); |