Skip to content

Commit 28a4f2f

Browse files
authored
docs: getting started (#461)
1 parent 6c82ce5 commit 28a4f2f

File tree

6 files changed

+124
-179
lines changed

6 files changed

+124
-179
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
## Introduction
1414

15-
Minecraft [resource packs](https://minecraft.wiki/w/Resource_Pack) and [data packs](https://minecraft.wiki/w/Data_Pack) work well as _distribution_ formats but can be pretty limiting as _authoring_ formats. You can quickly end up having to manage hundreds of files, some of which might be buried within the bundled output of various generators.
15+
Minecraft [resource packs](https://minecraft.wiki/w/Resource_pack) and [data packs](https://minecraft.wiki/w/Data_pack) work well as _distribution_ formats but can be pretty limiting as _authoring_ formats. You can quickly end up having to manage hundreds of files, some of which might be buried within the bundled output of various generators.
1616

1717
The `beet` project is a development kit that tries to unify data pack and resource pack tooling into a single pipeline. The community is always coming up with pre-processors, frameworks, and generators of all kinds to make the developer experience more ergonomic. With `beet` you can seamlessly integrate all these tools in your project.
1818

docs/getting_started/index.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Getting Started
2+
```{toctree}
3+
:hidden:
4+
5+
plugins
6+
```
7+
Beet is a development toolkit for working with Minecraft data and resource packs. This section will explain how to install beet and get started with a first project.
8+
9+
## Installation
10+
To start, you will need [Python 3.10+](https://python.org/). Then, you can install beet via pip. This will give you access to the CLI command that you can use inside your terminal.
11+
```bash
12+
pip install beet
13+
```
14+
15+
## Creating a project
16+
Beet projects start with a configuration file, `beet.json`, in the root of your project.
17+
18+
```{tab} beet.json
19+
```json
20+
{
21+
"name": "My First Pack",
22+
"description": "Learning beet!",
23+
24+
"data_pack": {
25+
"load": ["src"]
26+
},
27+
28+
"output": "build"
29+
}
30+
```
31+
32+
This beet config describes a basic data pack which has a name, description, where to load in the data pack, and finally, where the output pack will be produced. To test it out, you can create a data pack function inside the `src` folder.
33+
34+
```{tab} src/data/example/function/hello.mcfunction
35+
```mcfunction
36+
say hello beet
37+
```
38+
39+
## Building the pack
40+
Now, navigating back to the root directory, you can invoke the build process and your pack will build, check it out in the output directory!
41+
```bash
42+
beet build
43+
```
44+
45+
Alternatively, beet can watch the source files and automatically build the pack when it detects changes:
46+
```bash
47+
beet watch
48+
```
49+
50+
## Linking to a world
51+
It is possible to automatically link the output pack to a world in your saves folder.
52+
```bash
53+
beet build --link "My World"
54+
```
55+
56+
This will automatically look for the minecraft folder. If you are using a third party launcher, you can override this with the `MINECRAFT_PATH` environment variable.

docs/getting_started/plugins.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Plugins
2+
A beet plugin is essentially a Python function that takes the build context as an argument.
3+
4+
```{tab} my_plugins.py
5+
```py
6+
from beet import Context, Function
7+
8+
def add_greeting(ctx: Context):
9+
ctx.data["example:hello"] = Function(["say hello from a plugin"])
10+
```
11+
12+
The `Context` object lets you access the data pack with the `data` attribute. Similarly, you are able to get the resource pack with the `assets` attribute.
13+
14+
Just adding this file won't change anything. That's because plugins need to be used inside the beet pipeline in the config:
15+
16+
```{tab} beet.json
17+
```json
18+
{
19+
"data_pack": {
20+
"load": ["src"]
21+
},
22+
"pipeline": [
23+
"my_plugins.add_greeting"
24+
],
25+
"output": "build"
26+
}
27+
```
28+
29+
## Modifying existing files
30+
Plugins can introspect and modify any part of the build. For example, the following plugin prepends every function with its name:
31+
32+
```{tab} my_plugins.py
33+
```py
34+
from beet import Context, Function
35+
36+
def function_headers(ctx: Context):
37+
for name, func in ctx.data.functions.items():
38+
func.lines.insert(0, f"# {name}")
39+
```

docs/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ You can follow the development of the project, discuss ideas, get help, and hang
1414

1515
```{toctree}
1616
:hidden:
17+
:maxdepth: 2
1718
19+
getting_started/index
1820
rationale
1921
overview
2022
changelog
@@ -26,6 +28,7 @@ changelog
2628
2729
GitHub Repository <https://github.com/mcbeet/beet>
2830
PyPI Package <https://pypi.org/project/beet>
31+
Beet Discord <https://discord.gg/98MdSGMm8j>
2932
```
3033

3134
```{include} ../README.md

0 commit comments

Comments
 (0)