From 7b0b8da50136dc9d5a0eaf70ccc1eacaacfb7e6e Mon Sep 17 00:00:00 2001 From: BPR02 Date: Sat, 23 Nov 2024 14:59:22 -0800 Subject: [PATCH] fix: load worldgen directives in snapshots - Fixes #361 --- examples/worldgen.md | 27 +++++++++ examples/worldgen_overlay.md | 57 +++++++++++++++++++ lectern/directive.py | 3 + ...__markdown_examples_worldgen_md__0.pack.md | 27 +++++++++ ...wn_examples_worldgen_overlay_md__0.pack.md | 57 +++++++++++++++++++ ...les__text_examples_worldgen_md__0.pack.txt | 15 +++++ ...t_examples_worldgen_overlay_md__0.pack.txt | 38 +++++++++++++ 7 files changed, 224 insertions(+) create mode 100644 examples/worldgen.md create mode 100644 examples/worldgen_overlay.md create mode 100644 tests/snapshots/examples__markdown_examples_worldgen_md__0.pack.md create mode 100644 tests/snapshots/examples__markdown_examples_worldgen_overlay_md__0.pack.md create mode 100644 tests/snapshots/examples__text_examples_worldgen_md__0.pack.txt create mode 100644 tests/snapshots/examples__text_examples_worldgen_overlay_md__0.pack.txt diff --git a/examples/worldgen.md b/examples/worldgen.md new file mode 100644 index 0000000..f7ff288 --- /dev/null +++ b/examples/worldgen.md @@ -0,0 +1,27 @@ +# Lectern snapshot + +## Data pack + +`@data_pack pack.mcmeta` + +```json +{ + "pack": { + "pack_format": 48, + "description": "" + } +} +``` + +### demo + +`@dimension demo:demo` + +```json +{ + "type": "demo:in-the-base-pack", + "generator": { + "type": "minecraft:debug" + } +} +``` diff --git a/examples/worldgen_overlay.md b/examples/worldgen_overlay.md new file mode 100644 index 0000000..1af90cb --- /dev/null +++ b/examples/worldgen_overlay.md @@ -0,0 +1,57 @@ +# Lectern snapshot + +## Data pack + +`@data_pack pack.mcmeta` + +```json +{ + "pack": { + "pack_format": 48, + "description": "" + }, + "overlays": { + "entries": [ + { + "formats": { + "min_inclusive": 48, + "max_inclusive": 48 + }, + "directory": "overlay_48" + } + ] + } +} +``` + +### demo + +`@dimension demo:demo` + +```json +{ + "type": "demo:in-the-base-pack", + "generator": { + "type": "minecraft:debug" + } +} +``` + +## Overlay `overlay_48` + +`@overlay overlay_48` + +### demo + +`@dimension demo:demo` + +```json +{ + "type": "demo:in-the-overlay-pack", + "generator": { + "type": "minecraft:debug" + } +} +``` + +`@endoverlay` diff --git a/lectern/directive.py b/lectern/directive.py index 83d4012..45f4677 100644 --- a/lectern/directive.py +++ b/lectern/directive.py @@ -16,6 +16,7 @@ from zipfile import ZipFile from beet import Container, DataPack, NamespaceFile, ResourcePack +from beet.contrib.worldgen import worldgen from beet.core.utils import snake_case from .fragment import Fragment @@ -52,6 +53,8 @@ def __init__( @self.add_resolver def _(self: DirectiveRegistry): for pack in [self.assets, self.data]: + if isinstance(pack, DataPack): + worldgen(pack) for file_type in pack.resolve_scope_map().values(): name = snake_case(file_type.__name__) self[name] = NamespacedResourceDirective(file_type) diff --git a/tests/snapshots/examples__markdown_examples_worldgen_md__0.pack.md b/tests/snapshots/examples__markdown_examples_worldgen_md__0.pack.md new file mode 100644 index 0000000..f7ff288 --- /dev/null +++ b/tests/snapshots/examples__markdown_examples_worldgen_md__0.pack.md @@ -0,0 +1,27 @@ +# Lectern snapshot + +## Data pack + +`@data_pack pack.mcmeta` + +```json +{ + "pack": { + "pack_format": 48, + "description": "" + } +} +``` + +### demo + +`@dimension demo:demo` + +```json +{ + "type": "demo:in-the-base-pack", + "generator": { + "type": "minecraft:debug" + } +} +``` diff --git a/tests/snapshots/examples__markdown_examples_worldgen_overlay_md__0.pack.md b/tests/snapshots/examples__markdown_examples_worldgen_overlay_md__0.pack.md new file mode 100644 index 0000000..1af90cb --- /dev/null +++ b/tests/snapshots/examples__markdown_examples_worldgen_overlay_md__0.pack.md @@ -0,0 +1,57 @@ +# Lectern snapshot + +## Data pack + +`@data_pack pack.mcmeta` + +```json +{ + "pack": { + "pack_format": 48, + "description": "" + }, + "overlays": { + "entries": [ + { + "formats": { + "min_inclusive": 48, + "max_inclusive": 48 + }, + "directory": "overlay_48" + } + ] + } +} +``` + +### demo + +`@dimension demo:demo` + +```json +{ + "type": "demo:in-the-base-pack", + "generator": { + "type": "minecraft:debug" + } +} +``` + +## Overlay `overlay_48` + +`@overlay overlay_48` + +### demo + +`@dimension demo:demo` + +```json +{ + "type": "demo:in-the-overlay-pack", + "generator": { + "type": "minecraft:debug" + } +} +``` + +`@endoverlay` diff --git a/tests/snapshots/examples__text_examples_worldgen_md__0.pack.txt b/tests/snapshots/examples__text_examples_worldgen_md__0.pack.txt new file mode 100644 index 0000000..7a2aef5 --- /dev/null +++ b/tests/snapshots/examples__text_examples_worldgen_md__0.pack.txt @@ -0,0 +1,15 @@ +@data_pack pack.mcmeta +{ + "pack": { + "pack_format": 48, + "description": "" + } +} + +@dimension demo:demo +{ + "type": "demo:in-the-base-pack", + "generator": { + "type": "minecraft:debug" + } +} diff --git a/tests/snapshots/examples__text_examples_worldgen_overlay_md__0.pack.txt b/tests/snapshots/examples__text_examples_worldgen_overlay_md__0.pack.txt new file mode 100644 index 0000000..a548521 --- /dev/null +++ b/tests/snapshots/examples__text_examples_worldgen_overlay_md__0.pack.txt @@ -0,0 +1,38 @@ +@data_pack pack.mcmeta +{ + "pack": { + "pack_format": 48, + "description": "" + }, + "overlays": { + "entries": [ + { + "formats": { + "min_inclusive": 48, + "max_inclusive": 48 + }, + "directory": "overlay_48" + } + ] + } +} + +@dimension demo:demo +{ + "type": "demo:in-the-base-pack", + "generator": { + "type": "minecraft:debug" + } +} + +@overlay overlay_48 + +@dimension demo:demo +{ + "type": "demo:in-the-overlay-pack", + "generator": { + "type": "minecraft:debug" + } +} + +@endoverlay