Any 4.0l OHV from 1990 to 2000 with be a direct swap.
You do want to use your '99 intake(upper and lower) to match '99 wiring harness and fuel pressure, and use your CPS/cam syncronizer to match '99 computer.
Explorers got 4.0l SOHC in 1997 as an option, but 4.0l OHV was stock, so they had BOTH for a few years.
Rangers had 4.0l OHV thru 2000.
2001 and up would have 4.0l SOHC
Recommended things to do when engine is out.
Oil pan gasket, for year of engine, not year of Ranger
Rear Main seal
(oil pumps tend to last in the 4.0l, but...........up to you really)
New intake gaskets and valve cover gaskets
new thermostat, flush heater core
CPS/Cam Syncronizer; Ford switch from a 3 wire to a 2 wire CPS in the late '90's, they are not interchangeable, computer made for 2 wire can't "see" 3 wire, and visa versa.
Either will fit the 4.0l OHV engine, that part didn't change