aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGlodBlock <1356392126@qq.com>2021-11-20 21:52:00 +0800
committerGlodBlock <1356392126@qq.com>2021-11-20 21:52:00 +0800
commit5d274d2be291d76b898f709535d316b0b672e76f (patch)
tree03c0cf3e47e1db006925a01bbef0045b687a071a /src
parent116ae744161eff30f8e7e536d5193391686d2a49 (diff)
downloadGT5-Unofficial-5d274d2be291d76b898f709535d316b0b672e76f.tar.gz
GT5-Unofficial-5d274d2be291d76b898f709535d316b0b672e76f.tar.bz2
GT5-Unofficial-5d274d2be291d76b898f709535d316b0b672e76f.zip
remove hacky code
Former-commit-id: 78faefd2b12534fcb0fe06738abd34b24c98174b
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java7
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaDistillTower.java6
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java7
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/util/RecipeFinderForParallel.java26
4 files changed, 18 insertions, 28 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 0c99ff8947..f2af0dd849 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
@@ -28,6 +28,7 @@ import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry;
import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference;
import com.github.bartimaeusnek.bartworks.util.BW_Util;
import com.github.bartimaeusnek.bartworks.util.MegaUtils;
+import com.github.bartimaeusnek.bartworks.util.Pair;
import com.github.bartimaeusnek.crossmod.tectech.TecTechEnabledMulti;
import com.github.bartimaeusnek.crossmod.tectech.helper.TecTechUtils;
import com.github.bartimaeusnek.crossmod.tectech.tileentites.tiered.LowPowerLaser;
@@ -398,9 +399,9 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl
int tCurrentPara = handleParallelRecipe(tRecipe, tFluids, tInputs, (int) tMaxPara);
processed = tCurrentPara;
found_Recipe = true;
- Object[] Outputs = getMultiOutput(tRecipe, tCurrentPara);
- outputFluids = (ArrayList<FluidStack>) Outputs[0];
- outputItems = (ArrayList<ItemStack>) Outputs[1];
+ Pair<ArrayList<FluidStack>, ArrayList<ItemStack>> Outputs = getMultiOutput(tRecipe, tCurrentPara);
+ outputFluids = Outputs.getKey();
+ outputItems = Outputs.getValue();
}
if (found_Recipe) {
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 d13b5d8016..4604f2d230 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
@@ -230,7 +230,7 @@ public class GT_TileEntity_MegaDistillTower extends GT_MetaTileEntity_Distillati
for (FluidStack tFluid : tFluids) {
ArrayList<FluidStack> outputFluids = new ArrayList<>();
ArrayList<ItemStack> outputItems = new ArrayList<>();
- Object[] Outputs;
+ Pair<ArrayList<FluidStack>, ArrayList<ItemStack>> Outputs;
int processed = 0;
boolean found_Recipe = false;
GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sDistillationRecipes.findRecipe(this.getBaseMetaTileEntity(), false, GT_Values.V[tTier], new FluidStack[]{tFluid});
@@ -241,8 +241,8 @@ public class GT_TileEntity_MegaDistillTower extends GT_MetaTileEntity_Distillati
int tCurrentPara = handleParallelRecipe(tRecipe, new FluidStack[]{tFluid}, null, (int) tMaxPara);
processed = tCurrentPara;
Outputs = getMultiOutput(tRecipe, tCurrentPara);
- outputFluids = (ArrayList<FluidStack>) Outputs[0];
- outputItems = (ArrayList<ItemStack>) Outputs[1];
+ outputFluids = Outputs.getKey();
+ outputItems = Outputs.getValue();
}
if (!found_Recipe)
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 3e6506eb27..8a968094d3 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
@@ -27,6 +27,7 @@ import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler;
import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference;
import com.github.bartimaeusnek.bartworks.util.BW_Util;
import com.github.bartimaeusnek.bartworks.util.MegaUtils;
+import com.github.bartimaeusnek.bartworks.util.Pair;
import com.github.bartimaeusnek.crossmod.tectech.TecTechEnabledMulti;
import com.github.bartimaeusnek.crossmod.tectech.helper.TecTechUtils;
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
@@ -115,9 +116,9 @@ public class GT_TileEntity_MegaVacuumFreezer extends GT_MetaTileEntity_VacuumFre
long tMaxPara = Math.min(ConfigHandler.megaMachinesMax, nominalV / tRecipe.mEUt);
int tCurrentPara = handleParallelRecipe(tRecipe, tInputFluids, tInputs, (int) tMaxPara);
processed = tCurrentPara;
- Object[] Outputs = getMultiOutput(tRecipe, tCurrentPara);
- outputFluids = (ArrayList<FluidStack>) Outputs[0];
- outputItems = (ArrayList<ItemStack>) Outputs[1];
+ Pair<ArrayList<FluidStack>, ArrayList<ItemStack>> Outputs = getMultiOutput(tRecipe, tCurrentPara);
+ outputFluids = Outputs.getKey();
+ outputItems = Outputs.getValue();
}
if (found_Recipe) {
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/RecipeFinderForParallel.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/RecipeFinderForParallel.java
index 0d7da1ccd3..ab2fd8976a 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/util/RecipeFinderForParallel.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/RecipeFinderForParallel.java
@@ -16,6 +16,8 @@ public class RecipeFinderForParallel {
*/
public static int handleParallelRecipe(GT_Recipe aRecipe, FluidStack[] aFluidInputs, ItemStack[] aItemStacks, int aMaxParallel) {
+ if (aFluidInputs == null) aFluidInputs = new FluidStack[0];
+ if (aItemStacks == null) aItemStacks = new ItemStack[0];
HashMap<Integer, Integer> tCompressedFluidInput = compressFluid(aFluidInputs);
HashMap<Integer, Integer> tCompressedItemInput = compressItem(aItemStacks);
HashMap<Integer, Integer> tCompressedFluidRecipe = compressFluid(aRecipe.mFluidInputs);
@@ -69,11 +71,11 @@ public class RecipeFinderForParallel {
return tCurrentPara;
}
- public static Object[] getMultiOutput(GT_Recipe aRecipe, int aPall) {
+ public static Pair<ArrayList<FluidStack>, ArrayList<ItemStack>> getMultiOutput(GT_Recipe aRecipe, int aPall) {
ArrayList<FluidStack> tFluidList = new ArrayList<>();
ArrayList<ItemStack> tItemList = new ArrayList<>();
if (aRecipe == null)
- return new Object[]{tFluidList, tItemList};
+ return new Pair<>(tFluidList, tItemList);
if (aRecipe.mFluidOutputs != null && aRecipe.mFluidOutputs.length > 0) {
for (FluidStack tFluid : aRecipe.mFluidOutputs) {
if (tFluid != null && tFluid.amount > 0) {
@@ -93,9 +95,7 @@ public class RecipeFinderForParallel {
}
}
}
- return new Object[]{
- tFluidList, tItemList
- };
+ return new Pair<>(tFluidList, tItemList);
}
public static HashMap<Integer, Integer> compressItem(ItemStack[] aItemStacks) {
@@ -104,13 +104,7 @@ public class RecipeFinderForParallel {
if (tItem != null) {
int tItemID = GT_Utility.stackToInt(tItem);
int tItemSize = tItem.stackSize;
- if (tCompressed.containsKey(tItemID)) {
- int tOldSize = tCompressed.get(tItemID);
- tCompressed.put(tItemID, tOldSize + tItemSize);
- }
- else {
- tCompressed.put(tItemID, tItemSize);
- }
+ tCompressed.merge(tItemID, tItemSize, Integer::sum);
}
}
return tCompressed;
@@ -122,13 +116,7 @@ public class RecipeFinderForParallel {
if (tFluid != null) {
int tFluidID = tFluid.getFluidID();
int tFluidSize = tFluid.amount;
- if (tCompressed.containsKey(tFluidID)) {
- int tOldSize = tCompressed.get(tFluidID);
- tCompressed.put(tFluidID, tOldSize + tFluidSize);
- }
- else {
- tCompressed.put(tFluidID, tFluidSize);
- }
+ tCompressed.merge(tFluidID, tFluidSize, Integer::sum);
}
}
return tCompressed;