diff options
author | Glease <4586901+Glease@users.noreply.github.com> | 2023-02-27 13:49:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-27 06:49:05 +0100 |
commit | 44824520ab2140f561a741bc486bc2f3459da2fe (patch) | |
tree | 5d81da726f4cb783a6b2369241a7613a2eeefff6 /src/main/java/gregtech/common/tileentities | |
parent | f04ae276af1346fb8ca5a022b21f5f372960ae13 (diff) | |
download | GT5-Unofficial-44824520ab2140f561a741bc486bc2f3459da2fe.tar.gz GT5-Unofficial-44824520ab2140f561a741bc486bc2f3459da2fe.tar.bz2 GT5-Unofficial-44824520ab2140f561a741bc486bc2f3459da2fe.zip |
implement save & load for single recipe lock (#1771)
* implement save & load for single recipe lock
* fix fat finger
* fix NPE
* disable machine if old locked recipe is gone
* address reviews
* spotless
Diffstat (limited to 'src/main/java/gregtech/common/tileentities')
3 files changed, 32 insertions, 7 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java index 76d2ce80d3..70d9250206 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java @@ -129,6 +129,11 @@ public class GT_MetaTileEntity_LargeChemicalReactor } @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sMultiblockChemicalRecipes; + } + + @Override public boolean checkRecipe(ItemStack aStack) { long tVoltage = getMaxInputVoltage(); byte tier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); 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 f5f485b53e..b988f1f7a5 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 @@ -53,6 +53,7 @@ import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_ProcessingArray_Manager; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Single_Recipe_Check; import gregtech.api.util.GT_Single_Recipe_Check_Processing_Array; import gregtech.api.util.GT_Utility; import gregtech.common.blocks.GT_Item_Machines; @@ -194,13 +195,7 @@ public class GT_MetaTileEntity_ProcessingArray } if (mLastRecipe == null) { - IMetaTileEntity aMachine = GT_Item_Machines.getMetaTileEntity(mInventory[1]); - if (aMachine != null) tTier = ((GT_MetaTileEntity_TieredMachineBlock) aMachine).mTier; - mMult = 0; - if (downtierUEV && tTier > 9) { - tTier--; // Lowers down the tier by 1 to allow for bigger parallel - mMult = 2; // Multiplies Parallels by 4x, keeping the energy cost - } + setTierAndMult(); } ArrayList<FluidStack> tFluidList = getStoredFluids(); FluidStack[] tFluids = tFluidList.toArray(new FluidStack[0]); @@ -223,9 +218,24 @@ public class GT_MetaTileEntity_ProcessingArray return false; } + private void setTierAndMult() { + IMetaTileEntity aMachine = GT_Item_Machines.getMetaTileEntity(mInventory[1]); + if (aMachine != null) tTier = ((GT_MetaTileEntity_TieredMachineBlock) aMachine).mTier; + mMult = 0; + if (downtierUEV && tTier > 9) { + tTier--; // Lowers down the tier by 1 to allow for bigger parallel + mMult = 2; // Multiplies Parallels by 4x, keeping the energy cost + } + } + public boolean processLockedRecipe() { GT_Single_Recipe_Check_Processing_Array tSingleRecipeCheck = (GT_Single_Recipe_Check_Processing_Array) mSingleRecipeCheck; + if (mLastRecipe == null) { + setTierAndMult(); + mLastRecipe = tSingleRecipeCheck.getRecipe(); + } + int machines = mInventory[1].stackSize << mMult; int parallel = tSingleRecipeCheck.checkRecipeInputs(true, machines); @@ -410,6 +420,11 @@ public class GT_MetaTileEntity_ProcessingArray } @Override + protected GT_Single_Recipe_Check loadSingleRecipeChecker(NBTTagCompound aNBT) { + return GT_Single_Recipe_Check_Processing_Array.tryLoad(this, getRecipeMap(), aNBT, mInventory[1]); + } + + @Override public final void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aPlayer.isSneaking()) { // Lock to single recipe diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java index f87664a5fb..6d0b194612 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java @@ -130,6 +130,11 @@ public class GT_MetaTileEntity_PyrolyseOven extends } @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sPyrolyseRecipes; + } + + @Override public boolean checkRecipe(ItemStack aStack) { long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); |