(A) Notwithstanding any local law or ordinance, an agricultural operation or facility is considered to be in compliance with the local law or ordinance if the operation or facility would otherwise comply with state law or regulations governing the facility or operation. With the exception of new swine operations and new slaughterhouse operations, to the extent an ordinance of a unit of local government:

(1) attempts to regulate the licensing or operation of an agricultural facility in any manner that is not identical to the laws of this State and regulations of the Department of Health and Environmental Control and amendments thereto;

(2) makes the operation of an agricultural facility or an agricultural operation at an agricultural facility a nuisance or providing for abatement as a nuisance in derogation of this chapter; or

(3) is not identical to state law and regulations governing agricultural operations or agricultural facilities, is null and void. The provisions of this section do not apply whenever a nuisance results from the negligent, illegal, or improper operation of an agricultural facility. The provisions of this section do not apply to an agricultural facility or agricultural operation at an agricultural facility located within the corporate limits of a city.

(B) The provisions of this section shall not preclude any right a county may have to determine whether an agricultural use is a permitted use under the county’s land use and zoning authority; provided, if an agricultural facility or an agricultural operation is a permitted use, or is approved as a use pursuant to any county conditional use, special exception or similar county procedure, county development standards, or other ordinances that are not identical with the laws of this State or the regulations of the Department of Health and Environmental Control are null and void to the extent they (a) apply to agricultural operations or facilities otherwise permitted by this chapter, the laws of this State, and the regulations of the Department of Health and Environmental Control, and (b) are not identical to this chapter, the laws of this State, and the regulations of the Department of Health and Environmental Control.