mirror of
https://github.com/GTNewHorizons/Applied-Energistics-2-Unofficial.git
synced 2026-11-25 14:34:34 +00:00
p2p rebooting the network (#329)
* Not sure why this flag was originally inverted, perhaps to prevent cycles in the old pathfinding algorithm * update storage grid after recalculating channels (previously any grid node was considered active while booting) * compress path recalculation a bit * fix p2p tunnels updating * Decrease monitor container flickering while rebuilding the grid * Added node API method for those cases when the caller doesn't care if the node grid is booting * spotlessApply (#338) Co-authored-by: GitHub GTNH Actions <> * Remove wildcard imports --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Firenoo <[email protected]>
This commit is contained in:
7 files changed
+83
-38
No files matched your search
+35
-12
@@ -10,14 +10,29 @@
|
||||
|
||||
package appeng.me.cache;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import appeng.api.networking.*;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridBlock;
|
||||
import appeng.api.networking.IGridConnection;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridMultiblock;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.IGridStorage;
|
||||
import appeng.api.networking.events.MENetworkBootingStatusChange;
|
||||
import appeng.api.networking.events.MENetworkCellArrayUpdate;
|
||||
import appeng.api.networking.events.MENetworkChannelChanged;
|
||||
import appeng.api.networking.events.MENetworkControllerChange;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
@@ -30,12 +45,19 @@ import appeng.core.features.AEFeature;
|
||||
import appeng.core.stats.Achievements;
|
||||
import appeng.me.GridConnection;
|
||||
import appeng.me.GridNode;
|
||||
import appeng.me.pathfinding.*;
|
||||
import appeng.me.pathfinding.AdHocChannelUpdater;
|
||||
import appeng.me.pathfinding.BackbonePathSegment;
|
||||
import appeng.me.pathfinding.ControllerChannelUpdater;
|
||||
import appeng.me.pathfinding.ControllerValidator;
|
||||
import appeng.me.pathfinding.IPathItem;
|
||||
import appeng.me.pathfinding.PathSegment;
|
||||
import appeng.me.pathfinding.TopologyStage;
|
||||
import appeng.tile.networking.TileController;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class PathGridCache implements IPathingGrid {
|
||||
|
||||
private static final int STEPS_PER_TICK = 10;
|
||||
private final LinkedList<PathSegment> active = new LinkedList<>();
|
||||
private final Map<IPathItem, BackbonePathSegment> backbone = new HashMap<>();
|
||||
private final Set<TileController> controllers = new HashSet<>();
|
||||
@@ -96,8 +118,6 @@ public class PathGridCache implements IPathingGrid {
|
||||
final HashSet<IPathItem> closedList = new HashSet<>();
|
||||
this.semiOpen = new HashSet<>();
|
||||
|
||||
// myGrid.getPivot().beginVisit( new AdHocChannelUpdater( 0 )
|
||||
// );
|
||||
for (final IGridNode node : this.myGrid.getMachines(TileController.class)) {
|
||||
closedList.add((IPathItem) node);
|
||||
for (final IGridConnection gcc : node.getConnections()) {
|
||||
@@ -116,12 +136,14 @@ public class PathGridCache implements IPathingGrid {
|
||||
|
||||
if (!this.active.isEmpty() || !backbone.isEmpty() || this.ticksUntilReady > 0) {
|
||||
boolean firstStage = !this.active.isEmpty();
|
||||
final Iterator<PathSegment> i = this.active.iterator();
|
||||
while (i.hasNext()) {
|
||||
final PathSegment pat = i.next();
|
||||
if (pat.step(backbone, TopologyStage.CONTROLLER_TO_BACKBONE)) {
|
||||
pat.setDead(true);
|
||||
i.remove();
|
||||
for (int k = 0; k < STEPS_PER_TICK && !this.active.isEmpty(); ++k) {
|
||||
final Iterator<PathSegment> i = this.active.iterator();
|
||||
while (i.hasNext()) {
|
||||
final PathSegment pat = i.next();
|
||||
if (pat.step(backbone, TopologyStage.CONTROLLER_TO_BACKBONE)) {
|
||||
pat.setDead(true);
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (active.isEmpty() && !backbone.isEmpty()) {
|
||||
@@ -167,6 +189,7 @@ public class PathGridCache implements IPathingGrid {
|
||||
this.booting = false;
|
||||
this.setChannelPowerUsage(this.getChannelsByBlocks() / 128.0);
|
||||
this.myGrid.postEvent(new MENetworkBootingStatusChange());
|
||||
this.myGrid.postEvent(new MENetworkCellArrayUpdate());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -345,7 +368,7 @@ public class PathGridCache implements IPathingGrid {
|
||||
|
||||
@Override
|
||||
public boolean isNetworkBooting() {
|
||||
return (!this.active.isEmpty() || !this.backbone.isEmpty()) && !this.booting;
|
||||
return !this.active.isEmpty() || !this.backbone.isEmpty() || this.updateNetwork;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user