In case any person or corporation building any dam shall not agree with the owners of any lands used for the purpose of the dam or flooded thereby, the court shall assess the damages for the land flooded or taken and also the consequential damages to any lands necessary to the use of the lands taken or flooded and owned by the parties whose lands are taken and flooded.