Skip to content

Commit

Permalink
fix: make nested overlays load after generated overlays
Browse files Browse the repository at this point in the history
  • Loading branch information
BPR02 committed Jan 14, 2025
1 parent 8e154df commit eea04a7
Show file tree
Hide file tree
Showing 16 changed files with 207 additions and 30 deletions.
8 changes: 5 additions & 3 deletions beet_observer/data_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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}})
Expand Down
8 changes: 5 additions & 3 deletions beet_observer/resource_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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}})
Expand Down
14 changes: 2 additions & 12 deletions examples/existing_overlay2/beet.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 13 additions & 1 deletion examples/existing_overlay2/proc/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
{
"pack": {
"pack_format": 48,
"description": ""
"description": "",
"supported_formats": [
47,
48
]
},
"overlays": {
"entries": [
{
"formats": 47,
"directory": "overlay_47"
}
]
}
}
22 changes: 22 additions & 0 deletions examples/existing_overlay3/beet.yaml
Original file line number Diff line number Diff line change
@@ -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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
say this only exists in the overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
say this is the same in both
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
say this is in an overlay that exists already
18 changes: 18 additions & 0 deletions examples/existing_overlay3/proc/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"pack": {
"pack_format": 48,
"description": "",
"supported_formats": [
47,
48
]
},
"overlays": {
"entries": [
{
"formats": 47,
"directory": "overlay_47"
}
]
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
say this is the same in both
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
say this is in an overlay that exists already
19 changes: 8 additions & 11 deletions tests/snapshots/examples__build_existing_overlay2__0.pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@
"pack_format": 57,
"description": "",
"supported_formats": [
48,
47,
57
]
},
"overlays": {
"entries": [
{
"formats": 48,
"formats": [
47,
48
],
"directory": "overlay_48"
},
{
"formats": {
"min_inclusive": 47,
"max_inclusive": 47
},
"formats": 47,
"directory": "overlay_47"
}
]
Expand Down Expand Up @@ -76,17 +76,14 @@ say this is in an overlay that exists already
"pack_format": 57,
"description": "",
"supported_formats": [
48,
47,
57
]
},
"overlays": {
"entries": [
{
"formats": {
"min_inclusive": 47,
"max_inclusive": 47
},
"formats": 47,
"directory": "overlay_47"
}
]
Expand Down
129 changes: 129 additions & 0 deletions tests/snapshots/examples__build_existing_overlay3__0.pack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Lectern snapshot

## Data pack

`@data_pack pack.mcmeta`

```json
{
"pack": {
"pack_format": 57,
"description": "",
"supported_formats": [
44,
57
]
},
"overlays": {
"entries": [
{
"formats": [
47,
48
],
"directory": "overlay_48"
},
{
"formats": 47,
"directory": "overlay_47"
},
{
"formats": {
"min_inclusive": 44,
"max_inclusive": 44
},
"directory": "overlay_44"
}
]
}
}
```

### demo

`@function demo:foo`

```mcfunction
say this is the same in both
```

## Overlay `overlay_44`

`@overlay overlay_44`

### demo

`@function demo:foo`

```mcfunction
say this is in an overlay that exists already
```

## Overlay `overlay_48`

`@overlay overlay_48`

### demo

`@function demo:demo`

```mcfunction
say this only exists in the overlay
```

## Overlay `overlay_47`

`@overlay overlay_47`

### demo

`@function demo:foo`

```mcfunction
say this is in an overlay that exists already
```

`@endoverlay`

## Resource pack

`@resource_pack pack.mcmeta`

```json
{
"pack": {
"pack_format": 57,
"description": "",
"supported_formats": [
44,
57
]
},
"overlays": {
"entries": [
{
"formats": 47,
"directory": "overlay_47"
}
]
}
}
```

### demo

`@texture demo:foo`

![texture.png](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAACZElEQVR4Ae1Yi2rDMAxsxv7/l7fd4MohpNrRTOQ1ChTbku70sBycHl8/z+PGz8eNc/9NvQvQHXDzCvQRuHkDPLoDugNuXoE+AjdvgH4Jfs50wHEcrhm+o6jTbyqV6RwkXFtCxVud4miX5bHcl74DoqBtUKP1Kh74meoAW3WuR4FG+r/iybuCZ6oAdPhqPLMrnm0mmRU8ywrwqjjUeUl6SdA+GlfxgH9ZATSoKKlIHiUayVfxgP/Sl2CUkBYvspmRZ3iOH1D/JzhT3Xe12eIIVBa3C1BZ/R18dwfssAuVMXQHVFZ/B9/Pq3B0vcQ9iTq9M6mMcy8hxXh6yCI8sZ7e6rhWPsg8LOOAvvwIvApQk2HQHC2Oa460G43PDmAFScD1iED1GQzxI6zqGSOxHCM59IqnPcZnAVQYzV85AEb1kcMz3Mqh3B4HbGHD0dooXnlPFcCS2rUSW1209jAabITz5B4X7SLdqQIoiRekJ1MMg9HRw6iec+WZxRCL0cOAs/wlqEHqXBNW+ep5/x+wuqL/jW/bI3BVIbsAV1V6Vz/dAbvuzFVxdQdcVeld/dy+A4bfArxD42qqc+6oJ6NOR9qpDHO98no21Hs64qmjLeSeDHL7pDqA5JYssyYXR8sRya1ddj3sgIgYgWnFIzsrV4yXXKSnnBiuLf/ZdaoAcI5AGMwZpxazKhHEYLln4kodARBnAweOP/BkggZu1ZPqADpHImcTGNmP9PTtjbopszzpDvACyMgYNEfLEcmtXXbdf4hkK/cuuPIjUF3ILkD1DlT77w6o3oFq/90B1TtQ7b87oHoHqv1/A4i35Y8io2pYAAAAAElFTkSuQmCC)

## Overlay `overlay_47`

`@overlay overlay_47`

### demo

`@texture demo:demo`

![tex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