diff options
author | miozune <miozune@gmail.com> | 2023-08-17 16:03:14 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-17 09:03:14 +0200 |
commit | d9aa36bdf546650202eb86d14dfb3cd3ced22c7d (patch) | |
tree | 3eca8a01e83b2584089f06e3da534626cfed7f67 /src/main/java/gregtech/common/tileentities | |
parent | 691239c347ab09bd6f024ab4fa1afaf19819cad0 (diff) | |
download | GT5-Unofficial-d9aa36bdf546650202eb86d14dfb3cd3ced22c7d.tar.gz GT5-Unofficial-d9aa36bdf546650202eb86d14dfb3cd3ced22c7d.tar.bz2 GT5-Unofficial-d9aa36bdf546650202eb86d14dfb3cd3ced22c7d.zip |
Fix lag caused by getRecipeMap for PA (#2236)
Diffstat (limited to 'src/main/java/gregtech/common/tileentities')
2 files changed, 15 insertions, 11 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java index 70cf8bd7c8..dce2a4f93d 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java @@ -175,6 +175,7 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMult return new ProcessingLogic() { @Nonnull + @Override public CheckRecipeResult process() { setEuModifier(1.0F - Math.min(0.1F * (heatLevel.getTier() + 1), 0.5F)); return super.process(); 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 db17a76711..fe1d2865c3 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 @@ -178,8 +178,7 @@ public class GT_MetaTileEntity_ProcessingArray extends return new ITexture[] { Textures.BlockIcons.casingTexturePages[0][48] }; } - @Override - public GT_Recipe_Map getRecipeMap() { + private GT_Recipe_Map fetchRecipeMap() { if (isCorrectMachinePart(getControllerSlot())) { // Gets the recipe map for the given machine through its unlocalized name return GT_ProcessingArray_Manager @@ -189,6 +188,11 @@ public class GT_MetaTileEntity_ProcessingArray extends } @Override + public GT_Recipe_Map getRecipeMap() { + return mLastRecipeMap; + } + + @Override public boolean isCorrectMachinePart(ItemStack aStack) { return aStack != null && aStack.getUnlocalizedName() .startsWith("gt.blockmachines."); @@ -218,7 +222,7 @@ public class GT_MetaTileEntity_ProcessingArray extends if (!GT_Utility.areStacksEqual(lastControllerStack, getControllerSlot())) { // controller slot has changed lastControllerStack = getControllerSlot(); - mLastRecipeMap = getRecipeMap(); + mLastRecipeMap = fetchRecipeMap(); setTierAndMult(); } if (mLastRecipeMap == null) return SimpleCheckRecipeResult.ofFailure("no_machine"); @@ -254,8 +258,7 @@ public class GT_MetaTileEntity_ProcessingArray extends @Override protected void setProcessingLogicPower(ProcessingLogic logic) { - GT_Recipe_Map recipeMap = getRecipeMap(); - logic.setAvailableVoltage(GT_Values.V[tTier] * (recipeMap != null ? recipeMap.mAmperage : 1)); + logic.setAvailableVoltage(GT_Values.V[tTier] * (mLastRecipeMap != null ? mLastRecipeMap.mAmperage : 1)); logic.setAvailableAmperage(getMaxParallel()); logic.setAmperageOC(false); } @@ -285,11 +288,11 @@ public class GT_MetaTileEntity_ProcessingArray extends public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); if (mMachine && aTick % 20 == 0) { - GT_Recipe_Map tCurrentMap = getRecipeMap(); - if (tCurrentMap != mLastRecipeMap) { - for (GT_MetaTileEntity_Hatch_InputBus tInputBus : mInputBusses) tInputBus.mRecipeMap = tCurrentMap; - for (GT_MetaTileEntity_Hatch_Input tInputHatch : mInputHatches) tInputHatch.mRecipeMap = tCurrentMap; - mLastRecipeMap = tCurrentMap; + for (GT_MetaTileEntity_Hatch_InputBus tInputBus : mInputBusses) { + tInputBus.mRecipeMap = mLastRecipeMap; + } + for (GT_MetaTileEntity_Hatch_Input tInputHatch : mInputHatches) { + tInputHatch.mRecipeMap = mLastRecipeMap; } } } @@ -519,7 +522,7 @@ public class GT_MetaTileEntity_ProcessingArray extends public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y, int z) { super.getWailaNBTData(player, tile, tag, world, x, y, z); - if (getControllerSlot() != null) { + if (mLastRecipeMap != null && getControllerSlot() != null) { tag.setString("type", getControllerSlot().getDisplayName()); } } |