Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: load worldgen directives in snapshots #362

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions examples/worldgen.md
Original file line number Diff line number Diff line change
@@ -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"
}
}
```
57 changes: 57 additions & 0 deletions examples/worldgen_overlay.md
Original file line number Diff line number Diff line change
@@ -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`
3 changes: 3 additions & 0 deletions lectern/directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
27 changes: 27 additions & 0 deletions tests/snapshots/examples__markdown_examples_worldgen_md__0.pack.md
Original file line number Diff line number Diff line change
@@ -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"
}
}
```
Original file line number Diff line number Diff line change
@@ -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`
15 changes: 15 additions & 0 deletions tests/snapshots/examples__text_examples_worldgen_md__0.pack.txt
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -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