Protoplanetary core formation by rain-out of minerals