Implemented controller update throttling, should fix lag issues with controllers that constantly turn off and on, fixes #1358
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
### 1.5.10
|
### 1.5.10
|
||||||
- Converted Solderer recipes to JSON (raoulvdberge)
|
- Converted Solderer recipes to JSON (raoulvdberge)
|
||||||
|
- Implemented controller update throttling, should fix lag issues with controllers that constantly turn off and on (raoulvdberge)
|
||||||
|
|
||||||
### 1.5.9
|
### 1.5.9
|
||||||
- Fixed crash relating to MCMP (raoulvdberge)
|
- Fixed crash relating to MCMP (raoulvdberge)
|
||||||
|
|||||||
@@ -108,6 +108,9 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
|||||||
return nodes;
|
return nodes;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
private static final int THROTTLE_INACTIVE_TO_ACTIVE = 20;
|
||||||
|
private static final int THROTTLE_ACTIVE_TO_INACTIVE = 4;
|
||||||
|
|
||||||
public static final String NBT_ENERGY = "Energy";
|
public static final String NBT_ENERGY = "Energy";
|
||||||
public static final String NBT_ENERGY_CAPACITY = "EnergyCapacity";
|
public static final String NBT_ENERGY_CAPACITY = "EnergyCapacity";
|
||||||
|
|
||||||
@@ -135,6 +138,7 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
|||||||
private int lastEnergyDisplay;
|
private int lastEnergyDisplay;
|
||||||
|
|
||||||
private boolean couldRun;
|
private boolean couldRun;
|
||||||
|
private int ticksSinceUpdateChanged;
|
||||||
|
|
||||||
private boolean craftingMonitorUpdateRequested;
|
private boolean craftingMonitorUpdateRequested;
|
||||||
|
|
||||||
@@ -216,15 +220,26 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
|||||||
energy.setEnergyStored(energy.getMaxEnergyStored());
|
energy.setEnergyStored(energy.getMaxEnergyStored());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (couldRun != canRun()) {
|
boolean canRun = canRun();
|
||||||
couldRun = canRun();
|
|
||||||
|
|
||||||
nodeGraph.rebuild();
|
if (couldRun != canRun) {
|
||||||
securityManager.rebuild();
|
++ticksSinceUpdateChanged;
|
||||||
|
|
||||||
|
if (canRun ? (ticksSinceUpdateChanged > THROTTLE_INACTIVE_TO_ACTIVE) : (ticksSinceUpdateChanged > THROTTLE_ACTIVE_TO_INACTIVE)) {
|
||||||
|
ticksSinceUpdateChanged = 0;
|
||||||
|
couldRun = canRun;
|
||||||
|
|
||||||
|
nodeGraph.rebuild();
|
||||||
|
securityManager.rebuild();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ticksSinceUpdateChanged = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getEnergyScaledForDisplay() != lastEnergyDisplay) {
|
int energyDisplay = getEnergyScaledForDisplay();
|
||||||
lastEnergyDisplay = getEnergyScaledForDisplay();
|
|
||||||
|
if (lastEnergyDisplay != energyDisplay) {
|
||||||
|
lastEnergyDisplay = energyDisplay;
|
||||||
|
|
||||||
RSUtils.updateBlock(world, pos);
|
RSUtils.updateBlock(world, pos);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user