diff --git a/beet/library/base.py b/beet/library/base.py index 32a34958..0c2e1be0 100644 --- a/beet/library/base.py +++ b/beet/library/base.py @@ -76,7 +76,13 @@ SupportsMerge, ) from beet.core.file import File, FileOrigin, JsonFile, PngFile -from beet.core.utils import FileSystemPath, JsonDict, SupportedFormats, TextComponent +from beet.core.utils import ( + FileSystemPath, + FormatsRangeDict, + JsonDict, + SupportedFormats, + TextComponent, +) from .utils import list_extensions, list_origin_folders @@ -579,9 +585,21 @@ def list_files( if extend and not issubclass(content_type, extend): continue - scope = get_output_scope( - content_type.scope, self.pack.pack_format if self.pack else 0 - ) + # Use the pack format from the pack's supported_formats. + # Otherwise, use the pack_format itself + pack_format = 0 + if self.pack: + supported_formats = self.pack.supported_formats + if type(supported_formats) is int: + pack_format = supported_formats + elif type(supported_formats) is list[int]: + pack_format = supported_formats[1] + elif type(supported_formats) is FormatsRangeDict: + pack_format = supported_formats["max_inclusive"] + else: + pack_format = self.pack.pack_format + scope = get_output_scope(content_type.scope, pack_format) + prefix = "/".join((self.directory, namespace) + scope) for name, item in container.items(): yield f"{overlay}{prefix}/{name}{content_type.extension}", item diff --git a/examples/load_overlay/beet.yml b/examples/load_overlay/beet.yml index 0619fa3e..8045138c 100644 --- a/examples/load_overlay/beet.yml +++ b/examples/load_overlay/beet.yml @@ -1,7 +1,7 @@ data_pack: load: "src" - pack_format: 20 - supported_formats: [18, 19, 20] + pack_format: 50 + supported_formats: [50, 50] overlays: - formats: min_inclusive: 18 diff --git a/examples/load_overlay/src/pack.mcmeta b/examples/load_overlay/src/pack.mcmeta index d145ca2d..1b5afc51 100644 --- a/examples/load_overlay/src/pack.mcmeta +++ b/examples/load_overlay/src/pack.mcmeta @@ -2,11 +2,17 @@ "overlays": { "entries": [ { - "formats": {"min_inclusive": 17, "max_inclusive": 18}, + "formats": { + "min_inclusive": 17, + "max_inclusive": 18 + }, "directory": "overlay1" }, { - "formats": {"min_inclusive": 18, "max_inclusive": 19}, + "formats": { + "min_inclusive": 18, + "max_inclusive": 19 + }, "directory": "overlay2" }, { @@ -15,4 +21,4 @@ } ] } -} +} \ No newline at end of file diff --git a/tests/snapshots/examples__build_load_overlay__0.data_pack/data/demo/functions/foo.mcfunction b/tests/snapshots/examples__build_load_overlay__0.data_pack/data/demo/function/foo.mcfunction similarity index 100% rename from tests/snapshots/examples__build_load_overlay__0.data_pack/data/demo/functions/foo.mcfunction rename to tests/snapshots/examples__build_load_overlay__0.data_pack/data/demo/function/foo.mcfunction diff --git a/tests/snapshots/examples__build_load_overlay__0.data_pack/pack.mcmeta b/tests/snapshots/examples__build_load_overlay__0.data_pack/pack.mcmeta index 1aa5c97c..3a177a56 100644 --- a/tests/snapshots/examples__build_load_overlay__0.data_pack/pack.mcmeta +++ b/tests/snapshots/examples__build_load_overlay__0.data_pack/pack.mcmeta @@ -1,11 +1,10 @@ { "pack": { - "pack_format": 20, + "pack_format": 50, "description": "", "supported_formats": [ - 18, - 19, - 20 + 50, + 50 ] }, "overlays": { @@ -37,4 +36,4 @@ } ] } -} +} \ No newline at end of file