aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/tileentities
diff options
context:
space:
mode:
authorMartin Robertz <dream-master@gmx.net>2021-07-29 18:33:34 +0200
committerGitHub <noreply@github.com>2021-07-29 18:33:34 +0200
commit559bdc58cdad797553257d8b8d4dd72b361d5066 (patch)
tree96ce7e2d87f0d09c2638d6621e3f2d781500b5f8 /src/main/java/gregtech/common/tileentities
parented0f15357e7b46cd58320497e3186db9bcb3b209 (diff)
parent41e3bfddf317ebb56f8c6e0110a0d47db29e1780 (diff)
downloadGT5-Unofficial-559bdc58cdad797553257d8b8d4dd72b361d5066.tar.gz
GT5-Unofficial-559bdc58cdad797553257d8b8d4dd72b361d5066.tar.bz2
GT5-Unofficial-559bdc58cdad797553257d8b8d4dd72b361d5066.zip
Merge pull request #604 from repo-alt/experimental
Missing bit of ME output bus optimization
Diffstat (limited to 'src/main/java/gregtech/common/tileentities')
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java31
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);
}