Skip to content

Commit 801bb67

Browse files
committed
feat: ignore overlays that exist before the plugin runs
1 parent 0fb8086 commit 801bb67

File tree

10 files changed

+110
-4
lines changed

10 files changed

+110
-4
lines changed

beet_observer/data_pack.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
from beet import Context, NamespaceProxy
55

66

7-
def gen_dp_overlays(ctx: Context, ctx_overlay: Context, overlay_dir: str) -> None:
7+
def gen_dp_overlays(
8+
ctx: Context, ctx_overlay: Context, overlay_dir: str, ignore: list[str]
9+
) -> None:
810
"""
911
Generates overlays between two datapacks.
1012
@@ -118,6 +120,8 @@ def gen_dp_overlays(ctx: Context, ctx_overlay: Context, overlay_dir: str) -> Non
118120

119121
# add overlays to pack.mcmeta
120122
for overlay in ctx.data.overlays:
123+
if overlay in ignore:
124+
continue
121125
# check if it's the top-level overlay
122126
if overlay == ctx.meta["observer"]["default_dir_dp"]:
123127
# delete pack.mcmeta from overlay (required for tests)

beet_observer/plugin.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ def beet_default(ctx: Context):
2424
ctx.meta["observer"]["default_dir_rp"] = ctx.meta["observer"]["default_dir"][
2525
"rp"
2626
]
27+
# save current overlays
28+
save: list[str] = []
29+
for overlay in ctx.data.overlays:
30+
save.append(overlay)
2731
# loop through all overlays
2832
for overlay in ctx.meta["observer"]["overlays"]:
2933
# create relative path
@@ -40,5 +44,5 @@ def beet_default(ctx: Context):
4044
dp_dir = overlay["directory"]
4145
rp_dir = overlay["directory"]
4246
# compare build pack and overlay pack
43-
gen_dp_overlays(ctx, ctx_overlay, dp_dir)
44-
gen_rp_overlays(ctx, ctx_overlay, rp_dir)
47+
gen_dp_overlays(ctx, ctx_overlay, dp_dir, save)
48+
gen_rp_overlays(ctx, ctx_overlay, rp_dir, save)

beet_observer/resource_pack.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
from beet import Context, NamespaceProxy
44

55

6-
def gen_rp_overlays(ctx: Context, ctx_overlay: Context, overlay_dir: str) -> None:
6+
def gen_rp_overlays(
7+
ctx: Context, ctx_overlay: Context, overlay_dir: str, ignore: list[str]
8+
) -> None:
79
"""
810
Generates overlays between two resource packs.
911
@@ -46,6 +48,8 @@ def gen_rp_overlays(ctx: Context, ctx_overlay: Context, overlay_dir: str) -> Non
4648

4749
# add overlays to pack.mcmeta
4850
for overlay in ctx.assets.overlays:
51+
if overlay in ignore:
52+
continue
4953
# check if it's the top-level overlay
5054
if overlay == ctx.meta["observer"]["default_dir_rp"]:
5155
# delete pack.mcmeta from overlay (required for tests)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
data_pack:
2+
load: src
3+
pack_format: 57
4+
supported_formats: [48,57]
5+
overlays:
6+
- formats:
7+
min_inclusive: 47
8+
max_inclusive: 47
9+
directory: overlay_47
10+
11+
pipeline:
12+
- beet_observer
13+
14+
meta:
15+
observer:
16+
overlays:
17+
- process: proc
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
say this only exists in the overlay
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
say this is the same in both
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"pack": {
3+
"pack_format": 48,
4+
"description": ""
5+
}
6+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
say this is the same in both
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
say this is in an overlay that exists already
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Lectern snapshot
2+
3+
## Data pack
4+
5+
`@data_pack pack.mcmeta`
6+
7+
```json
8+
{
9+
"pack": {
10+
"pack_format": 57,
11+
"description": "",
12+
"supported_formats": [
13+
48,
14+
57
15+
]
16+
},
17+
"overlays": {
18+
"entries": [
19+
{
20+
"formats": 48,
21+
"directory": "overlay_48"
22+
},
23+
{
24+
"formats": {
25+
"min_inclusive": 47,
26+
"max_inclusive": 47
27+
},
28+
"directory": "overlay_47"
29+
}
30+
]
31+
}
32+
}
33+
```
34+
35+
### demo
36+
37+
`@function demo:foo`
38+
39+
```mcfunction
40+
say this is the same in both
41+
```
42+
43+
## Overlay `overlay_47`
44+
45+
`@overlay overlay_47`
46+
47+
### demo
48+
49+
`@function demo:foo`
50+
51+
```mcfunction
52+
say this is in an overlay that exists already
53+
```
54+
55+
## Overlay `overlay_48`
56+
57+
`@overlay overlay_48`
58+
59+
### demo
60+
61+
`@function demo:demo`
62+
63+
```mcfunction
64+
say this only exists in the overlay
65+
```
66+
67+
`@endoverlay`

0 commit comments

Comments
 (0)