diff options
author | repo_alt <wvk17@yandex.ru> | 2021-07-24 11:34:14 +0300 |
---|---|---|
committer | repo_alt <wvk17@yandex.ru> | 2021-07-24 11:34:14 +0300 |
commit | 41e3bfddf317ebb56f8c6e0110a0d47db29e1780 (patch) | |
tree | 3f6877d3e3f90f324da91ec8e776e3c9c7a2668f /src/main/java/gregtech/common/tileentities | |
parent | cc08b8898a3cdc3a207fe93ff7d2d6b359a66f9b (diff) | |
download | GT5-Unofficial-41e3bfddf317ebb56f8c6e0110a0d47db29e1780.tar.gz GT5-Unofficial-41e3bfddf317ebb56f8c6e0110a0d47db29e1780.tar.bz2 GT5-Unofficial-41e3bfddf317ebb56f8c6e0110a0d47db29e1780.zip |
Missing bit of ME output bus optimization (leftover piece of cached stack gets stuck in the bus)
Diffstat (limited to 'src/main/java/gregtech/common/tileentities')
-rw-r--r-- | src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java index ef3689f64c..4b6ce12e65 100644 --- a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java +++ b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java @@ -118,7 +118,6 @@ public class GT_MetaTileEntity_Hatch_OutputBus_ME extends GT_MetaTileEntity_Hatc if (rest != null && rest.getStackSize() > 0) { lastOutputFailed = true; - cachedStack.stackSize = (int)rest.getStackSize(); if (sameStack) // return all that was cached to sender { cachedStack = null; @@ -191,9 +190,39 @@ public class GT_MetaTileEntity_Hatch_OutputBus_ME extends GT_MetaTileEntity_Hatc public void gridChanged() { } + @Optional.Method(modid = "appliedenergistics2") + private void flushCachedStack() + { + if (cachedStack == null) + return; + AENetworkProxy proxy = getProxy(); + if (proxy == null) { + lastOutputFailed = true; + return; + } + try { + IMEMonitor<IAEItemStack> sg = proxy.getStorage().getItemInventory(); + IAEItemStack toStore = AEApi.instance().storage().createItemStack(cachedStack); + IAEItemStack rest = Platform.poweredInsert(proxy.getEnergy(), sg, toStore, getRequest()); + if (rest != null && rest.getStackSize() > 0) { + lastOutputFailed = true; + cachedStack.stackSize = (int) rest.getStackSize(); + } + else + cachedStack = null; + } + catch( final GridAccessException ignored ) + { + lastOutputFailed = true; + } + lastOutputTick = tickCounter; + } + @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { tickCounter = aTick; + if (tickCounter > (lastOutputTick + 40)) + flushCachedStack(); super.onPostTick(aBaseMetaTileEntity, aTick); } |