beet-observer 0.3.0__tar.gz → 0.5.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: beet-observer
3
- Version: 0.3.0
3
+ Version: 0.5.0
4
4
  Summary: A beet plugin to automatically generate overlays from previous datapacks
5
5
  License: MIT
6
6
  Author: BPR02
@@ -1,3 +1,3 @@
1
- __version__ = "0.3.0"
1
+ __version__ = "0.5.0"
2
2
 
3
3
  from .plugin import *
@@ -1,9 +1,12 @@
1
1
  from typing import Any
2
2
 
3
+ import beet.contrib.worldgen as wg
3
4
  from beet import Context, NamespaceProxy
4
5
 
5
6
 
6
- 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:
7
10
  """
8
11
  Generates overlays between two datapacks.
9
12
 
@@ -48,6 +51,60 @@ def gen_dp_overlays(ctx: Context, ctx_overlay: Context, overlay_dir: str) -> Non
48
51
  ctx.data.point_of_interest_type_tags,
49
52
  ctx_overlay.data.point_of_interest_type_tags,
50
53
  ),
54
+ (ctx.data[wg.Dimension], ctx_overlay.data[wg.Dimension]),
55
+ (ctx.data[wg.DimensionType], ctx_overlay.data[wg.DimensionType]),
56
+ (ctx.data[wg.WorldgenBiome], ctx_overlay.data[wg.WorldgenBiome]),
57
+ (
58
+ ctx.data[wg.WorldgenConfiguredCarver],
59
+ ctx_overlay.data[wg.WorldgenConfiguredCarver],
60
+ ),
61
+ (
62
+ ctx.data[wg.WorldgenConfiguredFeature],
63
+ ctx_overlay.data[wg.WorldgenConfiguredFeature],
64
+ ),
65
+ (
66
+ ctx.data[wg.WorldgenDensityFunction],
67
+ ctx_overlay.data[wg.WorldgenDensityFunction],
68
+ ),
69
+ (ctx.data[wg.WorldgenNoise], ctx_overlay.data[wg.WorldgenNoise]),
70
+ (
71
+ ctx.data[wg.WorldgenNoiseSettings],
72
+ ctx_overlay.data[wg.WorldgenNoiseSettings],
73
+ ),
74
+ (
75
+ ctx.data[wg.WorldgenPlacedFeature],
76
+ ctx_overlay.data[wg.WorldgenPlacedFeature],
77
+ ),
78
+ (
79
+ ctx.data[wg.WorldgenProcessorList],
80
+ ctx_overlay.data[wg.WorldgenProcessorList],
81
+ ),
82
+ (ctx.data[wg.WorldgenStructure], ctx_overlay.data[wg.WorldgenStructure]),
83
+ (ctx.data[wg.WorldgenStructureSet], ctx_overlay.data[wg.WorldgenStructureSet]),
84
+ (
85
+ ctx.data[wg.WorldgenConfiguredSurfaceBuilder],
86
+ ctx_overlay.data[wg.WorldgenConfiguredSurfaceBuilder],
87
+ ),
88
+ (ctx.data[wg.WorldgenTemplatePool], ctx_overlay.data[wg.WorldgenTemplatePool]),
89
+ (ctx.data[wg.WorldgenWorldPreset], ctx_overlay.data[wg.WorldgenWorldPreset]),
90
+ (
91
+ ctx.data[wg.WorldgenFlatLevelGeneratorPreset],
92
+ ctx_overlay.data[wg.WorldgenFlatLevelGeneratorPreset],
93
+ ),
94
+ (ctx.data[wg.WorldgenBiomeTag], ctx_overlay.data[wg.WorldgenBiomeTag]),
95
+ (
96
+ ctx.data[wg.WorldgenStructureSetTag],
97
+ ctx_overlay.data[wg.WorldgenStructureSetTag],
98
+ ),
99
+ (ctx.data[wg.WorldgenStructureTag], ctx_overlay.data[wg.WorldgenStructureTag]),
100
+ (
101
+ ctx.data[wg.WorldgenConfiguredCarverTag],
102
+ ctx_overlay.data[wg.WorldgenConfiguredCarverTag],
103
+ ),
104
+ (
105
+ ctx.data[wg.WorldgenPlacedFeatureTag],
106
+ ctx_overlay.data[wg.WorldgenPlacedFeatureTag],
107
+ ),
51
108
  ]
52
109
  # for each file type, check for required overlays
53
110
  for registry, registry_overlay in file_types:
@@ -63,6 +120,8 @@ def gen_dp_overlays(ctx: Context, ctx_overlay: Context, overlay_dir: str) -> Non
63
120
 
64
121
  # add overlays to pack.mcmeta
65
122
  for overlay in ctx.data.overlays:
123
+ if overlay in ignore:
124
+ continue
66
125
  # check if it's the top-level overlay
67
126
  if overlay == ctx.meta["observer"]["default_dir_dp"]:
68
127
  # delete pack.mcmeta from overlay (required for tests)
@@ -155,13 +214,18 @@ def gen_registry_overlay(
155
214
  ctx.data.overlays[default_dir][name] = registry[name]
156
215
  del registry[name]
157
216
  elif type == "addition":
158
- # move function from overlay pack to overlay in build pack
217
+ # move file from overlay pack to overlay in build pack
159
218
  ctx.data.overlays[overlay_dir][name] = registry_overlay[name]
160
219
  else:
161
220
  # check if files are exactly the same
162
- if registry[name] != registry_overlay[name]:
163
- # move function from overlay pack to overlay in build pack
164
- ctx.data.overlays[overlay_dir][name] = registry_overlay[name]
221
+ try:
222
+ if registry[name].data != registry_overlay[name].data:
223
+ # move file from overlay pack to overlay in build pack
224
+ ctx.data.overlays[overlay_dir][name] = registry_overlay[name]
225
+ except AttributeError:
226
+ if registry[name] != registry_overlay[name]:
227
+ # move file from overlay pack to overlay in build pack
228
+ ctx.data.overlays[overlay_dir][name] = registry_overlay[name]
165
229
 
166
230
  # remove file from overlay pack
167
231
  if name in registry_overlay:
@@ -24,6 +24,10 @@ def beet_default(ctx: Context):
24
24
  ctx.meta["observer"]["default_dir_rp"] = ctx.meta["observer"]["default_dir"][
25
25
  "rp"
26
26
  ]
27
+ # save current overlays
28
+ save: list[str] = []
29
+ for overlay in ctx.data.overlays:
30
+ save.append(overlay)
27
31
  # loop through all overlays
28
32
  for overlay in ctx.meta["observer"]["overlays"]:
29
33
  # create relative path
@@ -40,5 +44,5 @@ def beet_default(ctx: Context):
40
44
  dp_dir = overlay["directory"]
41
45
  rp_dir = overlay["directory"]
42
46
  # 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)
@@ -3,7 +3,9 @@ from typing import Any
3
3
  from beet import Context, NamespaceProxy
4
4
 
5
5
 
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:
7
9
  """
8
10
  Generates overlays between two resource packs.
9
11
 
@@ -46,6 +48,8 @@ def gen_rp_overlays(ctx: Context, ctx_overlay: Context, overlay_dir: str) -> Non
46
48
 
47
49
  # add overlays to pack.mcmeta
48
50
  for overlay in ctx.assets.overlays:
51
+ if overlay in ignore:
52
+ continue
49
53
  # check if it's the top-level overlay
50
54
  if overlay == ctx.meta["observer"]["default_dir_rp"]:
51
55
  # delete pack.mcmeta from overlay (required for tests)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "beet-observer"
3
- version = "0.3.0"
3
+ version = "0.5.0"
4
4
  description = "A beet plugin to automatically generate overlays from previous datapacks"
5
5
  authors = ["BPR02 <dev@bpr02.com>"]
6
6
  license = "MIT"
@@ -38,6 +38,7 @@ typeCheckingMode = "strict"
38
38
  [tool.poe.tasks]
39
39
  format = {shell = "isort beet_observer & black beet_observer"}
40
40
  check = {shell = "isort --check-only beet_observer & black --check beet_observer"}
41
+ typing = {shell = "pyright"}
41
42
 
42
43
  [build-system]
43
44
  requires = ["poetry-core"]
File without changes
File without changes