1.20.2 added pack overlays (explained in the 23w31a changelog), which conditionally overlay resource/data pack files from sub-directories onto the base pack. This PR extends this system to allow for overlays based on resource conditions, which allow overlays to be applied based on conditions other than just the current pack format.
Supercedes #3702, rebased to target 1.21.