diff options
author | repo-alt <wvk17@yandex.ru> | 2022-11-27 00:53:33 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-26 22:53:33 +0100 |
commit | e5c7e6eca4f5d35c7cdab66dc641a8de521757b4 (patch) | |
tree | c6ab55fc6ea39a4a13f67bae2d748db6128f8c59 /src/main/java | |
parent | 9295ba16ff1847ca296873484bf7ff258ff89e06 (diff) | |
download | GT5-Unofficial-e5c7e6eca4f5d35c7cdab66dc641a8de521757b4.tar.gz GT5-Unofficial-e5c7e6eca4f5d35c7cdab66dc641a8de521757b4.tar.bz2 GT5-Unofficial-e5c7e6eca4f5d35c7cdab66dc641a8de521757b4.zip |
fix locked recipe processing for the stocking input bus (#1526)
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/gregtech/api/util/GT_Single_Recipe_Check_Processing_Array.java | 27 | ||||
-rw-r--r-- | src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java | 10 |
2 files changed, 27 insertions, 10 deletions
diff --git a/src/main/java/gregtech/api/util/GT_Single_Recipe_Check_Processing_Array.java b/src/main/java/gregtech/api/util/GT_Single_Recipe_Check_Processing_Array.java index 585460842d..68db933a4e 100644 --- a/src/main/java/gregtech/api/util/GT_Single_Recipe_Check_Processing_Array.java +++ b/src/main/java/gregtech/api/util/GT_Single_Recipe_Check_Processing_Array.java @@ -155,16 +155,31 @@ public class GT_Single_Recipe_Check_Processing_Array extends GT_Single_Recipe_Ch } /** Call this before inputs are consumed by the recipe. */ - public Builder setBefore() { - beforeItems = buildItemMap(multiBlockBase); - beforeFluids = buildFluidMap(multiBlockBase); + public Builder setBefore(ItemStack[] inputs, FluidStack[] fluids) { + beforeItems = buildItemMapDirect(inputs); + beforeFluids = buildFluidMapDirect(fluids); return this; } + static Map<GT_Utility.ItemId, Integer> buildItemMapDirect(ItemStack[] inputs) { + Map<GT_Utility.ItemId, Integer> itemMap = new HashMap<>(); + for (ItemStack itemStack : inputs) { + itemMap.merge(GT_Utility.ItemId.create(itemStack), itemStack.stackSize, Integer::sum); + } + return itemMap; + } + static Map<Fluid, Integer> buildFluidMapDirect(FluidStack[] fluids) { + Map<Fluid, Integer> fluidMap = new HashMap<>(); + for (FluidStack fluidStack : fluids) { + fluidMap.merge(fluidStack.getFluid(), fluidStack.amount, Integer::sum); + } + return fluidMap; + } + /** Call this after inputs are consumed by the recipe. */ - public Builder setAfter() { - afterItems = buildItemMap(multiBlockBase); - afterFluids = buildFluidMap(multiBlockBase); + public Builder setAfter(ItemStack[] inputs, FluidStack[] fluids) { + afterItems = buildItemMapDirect(inputs); + afterFluids = buildFluidMapDirect(fluids); return this; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java index 62d5fefc0d..42640c832a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java @@ -244,10 +244,12 @@ public class GT_MetaTileEntity_ProcessingArray } public boolean processRecipe(ItemStack[] tInputs, FluidStack[] tFluids, GT_Recipe.GT_Recipe_Map map) { - if (tInputs.length <= 0 && tFluids.length <= 0) return false; + if (tInputs.length <= 0 && tFluids.length <= 0) + return false; GT_Recipe tRecipe = map.findRecipe( getBaseMetaTileEntity(), mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - if (tRecipe == null) return false; + if (tRecipe == null) + return false; if (GT_Mod.gregtechproxy.mLowGravProcessing && tRecipe.mSpecialValue == -100 && !isValidForLowGravity(tRecipe, getBaseMetaTileEntity().getWorld().provider.dimensionId)) @@ -258,7 +260,7 @@ public class GT_MetaTileEntity_ProcessingArray // We're locked to a single recipe, but haven't built the recipe checker yet. // Build the checker on next successful recipe. tSingleRecipeCheckBuilder = GT_Single_Recipe_Check_Processing_Array.processingArrayBuilder(this) - .setBefore(); + .setBefore(tInputs, tFluids); } boolean recipeLocked = false; @@ -271,7 +273,7 @@ public class GT_MetaTileEntity_ProcessingArray } else if (mLockedToSingleRecipe && !recipeLocked) { // We want to lock to a single run of the recipe. mSingleRecipeCheck = tSingleRecipeCheckBuilder - .setAfter() + .setAfter(tInputs, tFluids) .setRecipe(tRecipe) .setRecipeAmperage(map.mAmperage) .build(); |