Implemented block update throttling when network turns on and off, fixes #566
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
- You can now shift click items from the Grid crafting slots to the player inventory when the Grid is disconnected (raoulvdberge)
|
||||
- Added Korean translation (01QueN10)
|
||||
- Fixed error logs when watching a Controller when a network changes (raoulvdberge)
|
||||
- Implemented block update throttling when network turns on and off (raoulvdberge)
|
||||
|
||||
### 1.4.11
|
||||
- Removed debug log configuration option, as it's no longer needed (raoulvdberge)
|
||||
|
||||
@@ -32,6 +32,8 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor,
|
||||
private EnumFacing direction;
|
||||
|
||||
private boolean couldUpdate;
|
||||
private int ticksSinceUpdateChanged;
|
||||
|
||||
private boolean active;
|
||||
|
||||
public NetworkNode(World world, BlockPos pos) {
|
||||
@@ -94,6 +96,12 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor,
|
||||
boolean canUpdate = getNetwork() != null && canUpdate();
|
||||
|
||||
if (couldUpdate != canUpdate) {
|
||||
++ticksSinceUpdateChanged;
|
||||
|
||||
// If we go from inactive to active, throttle for 20 ticks
|
||||
// If we go from active to inactive, throttle for 4 ticks
|
||||
if (canUpdate ? (ticksSinceUpdateChanged > 20) : (ticksSinceUpdateChanged > 4)) {
|
||||
ticksSinceUpdateChanged = 0;
|
||||
couldUpdate = canUpdate;
|
||||
|
||||
if (hasConnectivityState()) {
|
||||
@@ -101,13 +109,16 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor,
|
||||
}
|
||||
|
||||
if (network != null) {
|
||||
onConnectedStateChange(network, couldUpdate);
|
||||
onConnectedStateChange(network, canUpdate);
|
||||
|
||||
if (shouldRebuildGraphOnChange()) {
|
||||
network.getNodeGraph().rebuild();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ticksSinceUpdateChanged = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user