diff --git a/src/main/java/resonantinduction/core/grid/NodeGrid.java b/src/main/java/resonantinduction/core/grid/NodeGrid.java index 00e250f38..05ad68214 100644 --- a/src/main/java/resonantinduction/core/grid/NodeGrid.java +++ b/src/main/java/resonantinduction/core/grid/NodeGrid.java @@ -21,24 +21,21 @@ public abstract class NodeGrid extends Grid AbstractMap connections = node.getConnections(); - synchronized (connections) + for (Object connection : connections.keySet()) { - for (Object connection : connections.keySet()) + if (isValidNode(connection) && connection instanceof Node) { - if (isValidNode(connection) && connection instanceof Node) + Node connectedNode = (Node) connection; + + if (connectedNode.getGrid() != this) { - Node connectedNode = (Node) connection; - - if (connectedNode.getGrid() != this) + synchronized (connectedNode.getGrid().getNodes()) { - synchronized (connectedNode.getGrid().getNodes()) - { - connectedNode.getGrid().getNodes().clear(); - } - - add((N) connectedNode); - reconstructNode((N) connectedNode); + connectedNode.getGrid().getNodes().clear(); } + + add((N) connectedNode); + reconstructNode((N) connectedNode); } } } diff --git a/src/main/java/resonantinduction/core/grid/TickingGrid.java b/src/main/java/resonantinduction/core/grid/TickingGrid.java index dac13c17c..a0cd7e79f 100644 --- a/src/main/java/resonantinduction/core/grid/TickingGrid.java +++ b/src/main/java/resonantinduction/core/grid/TickingGrid.java @@ -20,7 +20,7 @@ public class TickingGrid extends NodeGrid implements IUpdate @Override public void update() { - // synchronized (nodes) + synchronized (nodes) { for (Node node : nodes) {