private void updateNetwork() { if (worldObj.isRemote) { return; } BlockPosition ourbp = new BlockPosition(this); RedstoneNetwork.log("Cable at %s updating network", ourbp.toString()); if (_network == null) { for (BlockPosition bp : ourbp.getAdjacent(true)) { TileEntity te = bp.getTileEntity(worldObj); if (te instanceof TileEntityRedNetCable) { TileEntityRedNetCable cable = ((TileEntityRedNetCable) te); if (cable.getNetwork() != null && !cable.getNetwork().isInvalid()) { _network = cable.getNetwork(); break; } } } } if (_network == null) { RedstoneNetwork.log("Initializing new network at %s", ourbp.toString()); setNetwork(new RedstoneNetwork(worldObj)); } for (BlockPosition bp : ourbp.getAdjacent(true)) { TileEntity te = bp.getTileEntity(worldObj); if (te instanceof TileEntityRedNetCable) { TileEntityRedNetCable cable = ((TileEntityRedNetCable) te); if (cable.getNetwork() == null) { cable.setNetwork(_network); } else if (cable.getNetwork() != _network && cable.getNetwork() != null && !cable.getNetwork().isInvalid()) { _network.mergeNetwork(cable.getNetwork()); } } else { updateNearbyNode(bp); } } }