Fixed #1235 - "Breaking cable with destructor crashes game"
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
### 1.4.8
|
||||
- Fixed missing config categories in ingame config (raoulvdberge)
|
||||
- Fixed Controller not working anymore after changing redstone setting (raoulvdberge)
|
||||
- Fixed crash when placing or destroying network blocks (raoulvdberge)
|
||||
|
||||
### 1.4.7
|
||||
- Fixed bug where Portable Grid would dupe in inventory (raoulvdberge)
|
||||
|
||||
@@ -38,11 +38,6 @@ public interface INetworkNodeManager {
|
||||
*/
|
||||
Collection<INetworkNode> all();
|
||||
|
||||
/**
|
||||
* Clears all the nodes.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Marks the network node manager for saving.
|
||||
*/
|
||||
|
||||
@@ -20,7 +20,7 @@ public class NetworkNodeListener {
|
||||
|
||||
if (e.phase == TickEvent.Phase.END) {
|
||||
for (INetworkNode node : API.instance().getNetworkNodeManager(e.world).all()) {
|
||||
if (e.world.isBlockLoaded(node.getPos())) {
|
||||
if (node.getWorld() != null && e.world.isBlockLoaded(node.getPos())) {
|
||||
node.update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class NetworkNodeManager extends WorldSavedData implements INetworkNodeManager {
|
||||
@@ -24,7 +24,7 @@ public class NetworkNodeManager extends WorldSavedData implements INetworkNodeMa
|
||||
private static final String NBT_NODE_DATA = "Data";
|
||||
private static final String NBT_NODE_POS = "Pos";
|
||||
|
||||
private Map<BlockPos, INetworkNode> nodes = new HashMap<>();
|
||||
private Map<BlockPos, INetworkNode> nodes = new ConcurrentHashMap<>();
|
||||
|
||||
public NetworkNodeManager(String s) {
|
||||
super(s);
|
||||
@@ -32,7 +32,7 @@ public class NetworkNodeManager extends WorldSavedData implements INetworkNodeMa
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
clear();
|
||||
Map<BlockPos, INetworkNode> newNodes = new ConcurrentHashMap<>();
|
||||
|
||||
if (tag.hasKey(NBT_NODES)) {
|
||||
NBTTagList list = tag.getTagList(NBT_NODES, Constants.NBT.TAG_COMPOUND);
|
||||
@@ -53,7 +53,7 @@ public class NetworkNodeManager extends WorldSavedData implements INetworkNodeMa
|
||||
Function<NBTTagCompound, INetworkNode> factory = API.instance().getNetworkNodeRegistry().get(id);
|
||||
|
||||
if (factory != null) {
|
||||
setNode(pos, factory.apply(data));
|
||||
newNodes.put(pos, factory.apply(data));
|
||||
|
||||
RSUtils.debugLog("Node at " + pos + " read... (" + (++read) + "/" + toRead + ")");
|
||||
} else {
|
||||
@@ -65,6 +65,8 @@ public class NetworkNodeManager extends WorldSavedData implements INetworkNodeMa
|
||||
} else {
|
||||
RSUtils.debugLog("Cannot read nodes, as there is no 'nodes' tag on this WorldSavedData");
|
||||
}
|
||||
|
||||
this.nodes = newNodes;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -117,13 +119,6 @@ public class NetworkNodeManager extends WorldSavedData implements INetworkNodeMa
|
||||
return nodes.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
RSUtils.debugLog("Clearing all nodes!");
|
||||
|
||||
nodes.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markForSaving() {
|
||||
markDirty();
|
||||
|
||||
@@ -105,7 +105,7 @@ public abstract class TileNode<N extends NetworkNode> extends TileBase implement
|
||||
NetworkNode node = (NetworkNode) API.instance().getNetworkNodeManager(getWorld()).getNode(pos);
|
||||
|
||||
if (node == null) {
|
||||
throw new IllegalStateException("Node cannot be null!");
|
||||
throw new IllegalStateException("Node cannot be null at " + pos + "!");
|
||||
}
|
||||
|
||||
if (node.getContainer().world() == null) {
|
||||
|
||||
Reference in New Issue
Block a user