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)
|
- 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)
|
- Added Korean translation (01QueN10)
|
||||||
- Fixed error logs when watching a Controller when a network changes (raoulvdberge)
|
- 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
|
### 1.4.11
|
||||||
- Removed debug log configuration option, as it's no longer needed (raoulvdberge)
|
- 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 EnumFacing direction;
|
||||||
|
|
||||||
private boolean couldUpdate;
|
private boolean couldUpdate;
|
||||||
|
private int ticksSinceUpdateChanged;
|
||||||
|
|
||||||
private boolean active;
|
private boolean active;
|
||||||
|
|
||||||
public NetworkNode(World world, BlockPos pos) {
|
public NetworkNode(World world, BlockPos pos) {
|
||||||
@@ -94,19 +96,28 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor,
|
|||||||
boolean canUpdate = getNetwork() != null && canUpdate();
|
boolean canUpdate = getNetwork() != null && canUpdate();
|
||||||
|
|
||||||
if (couldUpdate != canUpdate) {
|
if (couldUpdate != canUpdate) {
|
||||||
couldUpdate = canUpdate;
|
++ticksSinceUpdateChanged;
|
||||||
|
|
||||||
if (hasConnectivityState()) {
|
// If we go from inactive to active, throttle for 20 ticks
|
||||||
RSUtils.updateBlock(world, pos);
|
// If we go from active to inactive, throttle for 4 ticks
|
||||||
}
|
if (canUpdate ? (ticksSinceUpdateChanged > 20) : (ticksSinceUpdateChanged > 4)) {
|
||||||
|
ticksSinceUpdateChanged = 0;
|
||||||
|
couldUpdate = canUpdate;
|
||||||
|
|
||||||
if (network != null) {
|
if (hasConnectivityState()) {
|
||||||
onConnectedStateChange(network, couldUpdate);
|
RSUtils.updateBlock(world, pos);
|
||||||
|
}
|
||||||
|
|
||||||
if (shouldRebuildGraphOnChange()) {
|
if (network != null) {
|
||||||
network.getNodeGraph().rebuild();
|
onConnectedStateChange(network, canUpdate);
|
||||||
|
|
||||||
|
if (shouldRebuildGraphOnChange()) {
|
||||||
|
network.getNodeGraph().rebuild();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
ticksSinceUpdateChanged = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user