diff options
author | Sampsa <69092953+S4mpsa@users.noreply.github.com> | 2022-08-14 17:43:43 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-14 16:43:43 +0200 |
commit | 9c511772af32a6f2958cf8f25c537b07444ff050 (patch) | |
tree | d71b522fc3d0a22bad925c9fa18d397080f89ae7 | |
parent | 1cd8abb39d149d17e736739499c659e73b76b543 (diff) | |
download | GT5-Unofficial-9c511772af32a6f2958cf8f25c537b07444ff050.tar.gz GT5-Unofficial-9c511772af32a6f2958cf8f25c537b07444ff050.tar.bz2 GT5-Unofficial-9c511772af32a6f2958cf8f25c537b07444ff050.zip |
Rate-limit the YOTTAHatch to reduce their tick time. (#69)
* Rate-limit the YOTTAHatch to reduce their tick time.
* Move onPostTick to be called every tick
-rw-r--r-- | src/main/java/goodgenerator/blocks/tileEntity/GTMetaTileEntity/YOTTAHatch.java | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/main/java/goodgenerator/blocks/tileEntity/GTMetaTileEntity/YOTTAHatch.java b/src/main/java/goodgenerator/blocks/tileEntity/GTMetaTileEntity/YOTTAHatch.java index 52a58f42b3..80571221e5 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/GTMetaTileEntity/YOTTAHatch.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/GTMetaTileEntity/YOTTAHatch.java @@ -75,6 +75,7 @@ public class YOTTAHatch extends GT_MetaTileEntity_Hatch private YottaFluidTank host; private AENetworkProxy gridProxy = null; private int priority; + private byte ticksSinceUpdate; private AccessRestriction readMode = AccessRestriction.READ_WRITE; private final AccessRestriction[] AEModes = new AccessRestriction[] { AccessRestriction.NO_ACCESS, AccessRestriction.READ, AccessRestriction.WRITE, AccessRestriction.READ_WRITE @@ -224,21 +225,25 @@ public class YOTTAHatch extends GT_MetaTileEntity_Hatch @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - IGridNode node = getGridNode(null); - if (node != null) { - IGrid grid = node.getGrid(); - if (grid != null) { - grid.postEvent(new MENetworkCellArrayUpdate()); - IStorageGrid storageGrid = grid.getCache(IStorageGrid.class); - if (storageGrid == null) { - node.getGrid().postEvent(new MENetworkStorageEvent(null, StorageChannel.FLUIDS)); - } else { - node.getGrid() - .postEvent( - new MENetworkStorageEvent(storageGrid.getFluidInventory(), StorageChannel.FLUIDS)); + ticksSinceUpdate++; + if (ticksSinceUpdate > 20) { + IGridNode node = getGridNode(null); + if (node != null) { + IGrid grid = node.getGrid(); + if (grid != null) { + grid.postEvent(new MENetworkCellArrayUpdate()); + IStorageGrid storageGrid = grid.getCache(IStorageGrid.class); + if (storageGrid == null) { + node.getGrid().postEvent(new MENetworkStorageEvent(null, StorageChannel.FLUIDS)); + } else { + node.getGrid() + .postEvent(new MENetworkStorageEvent( + storageGrid.getFluidInventory(), StorageChannel.FLUIDS)); + } + node.getGrid().postEvent(new MENetworkCellArrayUpdate()); } - node.getGrid().postEvent(new MENetworkCellArrayUpdate()); } + ticksSinceUpdate = 0; } super.onPostTick(aBaseMetaTileEntity, aTick); } |