From eea04a7121e05ea4af46a153489c1d2a2f06fd0e Mon Sep 17 00:00:00 2001 From: BPR02 Date: Mon, 13 Jan 2025 17:04:47 -0800 Subject: [PATCH] fix: make nested overlays load after generated overlays --- beet_observer/data_pack.py | 8 +- beet_observer/resource_pack.py | 8 +- examples/existing_overlay2/beet.yaml | 14 +- examples/existing_overlay2/proc/pack.mcmeta | 14 +- examples/existing_overlay3/beet.yaml | 22 +++ .../proc/assets/demo/textures/foo.png | Bin 0 -> 669 bytes .../proc/data/demo/function/demo.mcfunction | 1 + .../proc/data/demo/function/foo.mcfunction | 1 + .../overlay_47/assets/demo/textures/demo.png | Bin 0 -> 971 bytes .../data/demo/function/foo.mcfunction | 1 + examples/existing_overlay3/proc/pack.mcmeta | 18 +++ .../src/assets/demo/textures/foo.png | Bin 0 -> 669 bytes .../src/data/demo/function/foo.mcfunction | 1 + .../data/demo/function/foo.mcfunction | 1 + ...amples__build_existing_overlay2__0.pack.md | 19 ++- ...amples__build_existing_overlay3__0.pack.md | 129 ++++++++++++++++++ 16 files changed, 207 insertions(+), 30 deletions(-) create mode 100644 examples/existing_overlay3/beet.yaml create mode 100644 examples/existing_overlay3/proc/assets/demo/textures/foo.png create mode 100644 examples/existing_overlay3/proc/data/demo/function/demo.mcfunction create mode 100644 examples/existing_overlay3/proc/data/demo/function/foo.mcfunction create mode 100644 examples/existing_overlay3/proc/overlay_47/assets/demo/textures/demo.png create mode 100644 examples/existing_overlay3/proc/overlay_47/data/demo/function/foo.mcfunction create mode 100644 examples/existing_overlay3/proc/pack.mcmeta create mode 100644 examples/existing_overlay3/src/assets/demo/textures/foo.png create mode 100644 examples/existing_overlay3/src/data/demo/function/foo.mcfunction create mode 100644 examples/existing_overlay3/src/overlay_44/data/demo/function/foo.mcfunction create mode 100644 tests/snapshots/examples__build_existing_overlay3__0.pack.md diff --git a/beet_observer/data_pack.py b/beet_observer/data_pack.py index e18c930..6c779a2 100644 --- a/beet_observer/data_pack.py +++ b/beet_observer/data_pack.py @@ -110,9 +110,6 @@ def gen_dp_overlays( for registry, registry_overlay in file_types: check_registry(ctx, ctx_overlay, overlay_dir, registry, registry_overlay) - # add current overlays to pack - ctx.data.overlays.merge(ctx_overlay.data.overlays) - # get pack.mcmeta overlay entries mcmeta: dict[str, dict[str, list[dict[str, Any]]]] = ctx.data.mcmeta.data.copy() if "overlays" not in mcmeta: @@ -147,6 +144,11 @@ def gen_dp_overlays( } ) + # add current overlays to pack + ctx.data.overlays.merge(ctx_overlay.data.overlays) + if "overlays" in ctx_overlay.data.mcmeta.data: + entries.extend(ctx_overlay.data.mcmeta.data["overlays"]["entries"]) + # save overlay entries in pack.mcmeta if len(entries) > 0: ctx.data.mcmeta.data.update({"overlays": {"entries": entries}}) diff --git a/beet_observer/resource_pack.py b/beet_observer/resource_pack.py index 0845eb5..10564bc 100644 --- a/beet_observer/resource_pack.py +++ b/beet_observer/resource_pack.py @@ -38,9 +38,6 @@ def gen_rp_overlays( for registry, registry_overlay in file_types: check_registry(ctx, ctx_overlay, overlay_dir, registry, registry_overlay) - # add current overlays to pack - ctx.assets.overlays.merge(ctx_overlay.assets.overlays) - # get pack.mcmeta overlay entries mcmeta: dict[str, dict[str, list[dict[str, Any]]]] = ctx.assets.mcmeta.data.copy() if "overlays" not in mcmeta: @@ -75,6 +72,11 @@ def gen_rp_overlays( } ) + # add current overlays to pack + ctx.assets.overlays.merge(ctx_overlay.assets.overlays) + if "overlays" in ctx_overlay.assets.mcmeta.data: + entries.extend(ctx_overlay.assets.mcmeta.data["overlays"]["entries"]) + # save overlay entries in pack.mcmeta if len(entries) > 0: ctx.assets.mcmeta.data.update({"overlays": {"entries": entries}}) diff --git a/examples/existing_overlay2/beet.yaml b/examples/existing_overlay2/beet.yaml index 3de50b2..4ea23c1 100644 --- a/examples/existing_overlay2/beet.yaml +++ b/examples/existing_overlay2/beet.yaml @@ -1,22 +1,12 @@ data_pack: load: src pack_format: 57 - supported_formats: [48,57] - overlays: - - formats: - min_inclusive: 47 - max_inclusive: 47 - directory: overlay_47 + supported_formats: [47,57] resource_pack: load: src pack_format: 57 - supported_formats: [48,57] - overlays: - - formats: - min_inclusive: 47 - max_inclusive: 47 - directory: overlay_47 + supported_formats: [47,57] pipeline: - beet_observer diff --git a/examples/existing_overlay2/proc/pack.mcmeta b/examples/existing_overlay2/proc/pack.mcmeta index 8b4f4d2..c20a3fd 100644 --- a/examples/existing_overlay2/proc/pack.mcmeta +++ b/examples/existing_overlay2/proc/pack.mcmeta @@ -1,6 +1,18 @@ { "pack": { "pack_format": 48, - "description": "" + "description": "", + "supported_formats": [ + 47, + 48 + ] + }, + "overlays": { + "entries": [ + { + "formats": 47, + "directory": "overlay_47" + } + ] } } diff --git a/examples/existing_overlay3/beet.yaml b/examples/existing_overlay3/beet.yaml new file mode 100644 index 0000000..63e2807 --- /dev/null +++ b/examples/existing_overlay3/beet.yaml @@ -0,0 +1,22 @@ +data_pack: + load: src + pack_format: 57 + supported_formats: [44,57] + overlays: + - formats: + min_inclusive: 44 + max_inclusive: 44 + directory: overlay_44 + +resource_pack: + load: src + pack_format: 57 + supported_formats: [44,57] + +pipeline: + - beet_observer + +meta: + observer: + overlays: + - process: proc diff --git a/examples/existing_overlay3/proc/assets/demo/textures/foo.png b/examples/existing_overlay3/proc/assets/demo/textures/foo.png new file mode 100644 index 0000000000000000000000000000000000000000..777339df0be65caa3eae3f6afb0803196f7c7580 GIT binary patch literal 669 zcmV;O0%HA%P)e8|3iJ`U zc>_GU1G)olUV%OWH*bJ`34YFWz;PU|8NQ>a({C!3=^P|nTSCQKo#JSh<+0qCz5}A5 zZBV22DjxWm>Hu4Hu1A4J`oH4IyMkw`0Cf0jJhLmFZ6=u&Jj)93syNhnNqR}pJ{ni? zfPYy5G^i-4NFF5`$yf1!|I(LWl#muLvYC-*c#a=X|0g(8-FLOw;s{h0w+m2N{T+OF z2kfv5l`(V&R91fn-_NUXbiKqqi8{SAsf=?kA;oxl$Ra$kp5E%XRzAo)EaQN_{0O`X zP?KTM94(G(j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