---
# System prepended metadata

title: Drakon's Datapacks Development Q&A

---

# Drakon's Datapacks Development Q&A

## Getting Started

### How do I get started?

Generally, you will be developing on a specific singleplayer world that is linked to the [**Drakon's Datapacks**](https://github.com/Drakonkinst/DrakonsDatapacks) repository. The following instructions show you how to set this up properly. This guide also assumes you are contributing to the Drakon's Datapacks repository, either as an owner or by making pull requests. If you would like to make your own copy, feel free to fork the repository on GitHub and follow all of the same instructions with your own repository!

#### Downloading Stuff

You need some way of accessing the GitHub repository. The two main avenues are [**GitHub Desktop**](https://desktop.github.com/) (GUI-based, recommended for people unfamiliar with command line) or [**git command line**](https://git-scm.com/downloads) (command line-based, more powerful). Alternatively, your code editor may also support git.

You also need to install [**Python**](https://www.python.org/downloads/) (latest or 3.9+) if you want to run the build scripts included in the repository. Note that for MacOS and various other platforms, `python` should be replaced with `python3` where applicable.

Naturally, you will need a copy of [**Minecraft**](https://www.minecraft.net/en-us/download). Drakon's Datapacks targets the latest release, which is currently **1.19**, and does not intend to provide support for earlier releases of the game.

It will also be useful to have a code editor that can modify `.mcfunction` and `.json` files. I recommend [**Visual Studio Code**](https://code.visualstudio.com/), along with the [language-mcfunction](https://marketplace.visualstudio.com/items?itemName=arcensoth.language-mcfunction) extension that adds simple syntax highlighting for `.mcfunction` files.

#### Creating Your Development World

First, open (vanilla) Minecraft on the version you want to develop on. Create a new singleplayer world. After the world generates, locate its `datapacks` folder. This can be found by searching for `%appdata%` in the Windows search menu, then navigating to `.minecraft`, then `saves`. You should see your singleplayer world folder here. Click on it and find the `datapacks` folder.

Do **not** use the "pre-generation" datapacks folder during the world creation menu! This points to a temporary folder that does not exist once the world is actually created. Simply wait for the world to generate, then find its corresponding `datapacks` folder.

#### Installing Drakon's Datapacks

##### Option A: GitHub Desktop

* Copy the full path to the `datapacks` folder. On Windows, this can most easily be done by opening the folder in Windows Explorer, typing `Ctrl-L` to highlight the address bar, then `Ctrl-C` to copy it.
* In GitHub Desktop, select `Add` -> `Clone Repository`. Select the Drakon's Datapacks repository, or paste `https://github.com/Drakonkinst/DrakonsDatapacks.git` into the URL if you don't see it on the standard menu.
* In the local path, paste (`Ctrl-V`) the path to the datapcks folder. Make sure to do this **after** selecting the repository so nothing extra is added to the path. Do **not** use the `Choose Folder` option, as this is currently bugged on Windows!
* Click `Clone`.

##### Option B: Git Command Line

* Open the current folder in a command line. On Windows, this can most easily be done by opening the folder in Windows Explorer, typing `Ctrl-L` to highlight the address bar, typing `cmd`, and pressing `ENTER`.
* In the command line, run:

```
git clone https://github.com/Drakonkinst/DrakonsDatapacks.git .
```

* Make sure to include the `.` at the end, as this ensures the datapacks will be installed in the correct directory and do not make their own nested directory!

#### Finishing Up

At this point, you may want to ensure you switch to a **different branch** or create a new one if you do not want to develop on the main branch. See [here](https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/making-changes-in-a-branch/managing-branches) for a guide on how to do this in GitHub Desktop, or [here](https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging) for git command line.

Now you can open your editor of choice in the `datapacks` folder. For Visual Studio Code on Windows, this is most easily done by opening the folder in Windows Explorer, typing `Ctrl-L` to highlight the address bar, typing `cmd`, and pressing `ENTER` to open a command line. Then simply type `code .` to open Visual Studio Code in the current folder. Alternatively, if you have set up Visual Studio Code to add Windows Explorer context options, you can right click the folder and select "Open in Visual Studio Code".

In your editor, you should see the contents of the repository. On your development world, you can type `/reload` to refresh your datapacks. This can take a while since all of the datapacks are loaded by default. Then, you should see a "Drakon's Datapacks successfully loaded!" message as well as another message asking you to declare yourself as an admin.

**Note**: These instructions are specifically set up so you edit your world's datapacks directly. Therefore, any code change can affect the world after using the `/reload` command. However, you may find it beneficial to keep the repository separate from the world files (if, for example, you don't want every repository loaded) and then manually copy over the datapack source code (or zipped output files) to the world. If you do this, make sure to copy over `drakoncore.zip` which contains many of the core functionality required for datapacks!

### How do I create a new datapack?

There is a build tool located at `utils/new_datapack.py` that helps create a new datapack based on a template (which can be found at `dc_template`).

Open your terminal in the `utils` folder and run `python new_datapack.py`. A prompt should appear asking for the name of your datapack, which should follow the naming convention `dc_datapack_name`. Once you hit `ENTER`, a datapack by this name is created in the root directory of the repository. You should be able to see this in your code editor.

After running `/reload` in your world, you should be able to see this new mod by running `/trigger mods` (which brings up DrakonCore's registered mod list) or `/datapack list` (which lists all datapacks on the world). You'll notice it has a default name and description, these can be changed by modifying `<datapack_name>/pack.mcmeta` inside of the new datapack's folder as well as the `mod_info` hook, which can be found at `<datapack_name>/data/<datapack_name>/functions/hooks/mod_info.mcfunction`. Make sure to update both of these messages to register your datapack properly!

In the `functions/hooks` folder, you'll also find many other `mcfunction` files. These are all of the possible hooks from DrakonCore that are available to you. **To optimize your datapack, delete all empty hook `.mcfunction` files as well as their corresponding .json file under `<datapack_name>/data/drakoncore/tags/functions`.** This ensures that no hooks are attached unnecesarily! It is best to do this once you have established which hooks you'll use, as it can be quite annoying to attach them again if you delete them.

### How do I build and publish my datapack?

There is a build tool located at `utils/build_all_datapacks.py` that can help accomplish this.

First, create a folder named `out` in the root directory of the repository. This is necessary since the build tool does not create the folder by itself. Then, open your terminal in the `utils` folder and run `python build_all_datapacks.py`. This will populate the `out` folder with zipped versions of every datapack in the root directory of the repository.

These compressed datapacks can then be distributed to other servers or websites. To install this on a world, drop the zipped folder in the world's `datapacks` folder.

### How do I commit/push code changes?

#### GitHub Desktop

* Click "Fetch origin" to refresh changes and pull all changes made by other developers.
* Checkmark all of the files you want to add to this commit.
* Write a commit title and press "Commit" to commit your changes.
* Click "Push" to push your changes.

When you are developing on a different branch, you can then create a pull request. Instructions for this can be found [here](https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/working-with-your-remote-repository-on-github-or-github-enterprise/creating-an-issue-or-pull-request#creating-a-pull-request).

A note on commit messages: it is generally best to use **imperative present** tense. You can see examples in the [commit history](https://github.com/Drakonkinst/DrakonsDatapacks/commits/master) of my repository. [**Good commit messages are important**](https://levelup.gitconnected.com/the-importance-of-good-commit-messages-9331251e5e33) so it is possible to trace changes when needed. For example:

* `Add X`
* `Update Y`
* `Remove Z`
* `Implement X`
* `Polish Y`
* `Fix Z`

Adding a description with more details is recommended, especially on larger teams, but not required.

#### Git Command Line

* Run `git pull` to pull all changes in case changes have been made by other developers.
* In the datapack folders you have edited (or the root of the repository), run `git add .` to add all changes in that folder.
* Run `git commit -m "<commit message>"` to commit your code.
* Run `git push` to push the code to your branch on GitHub.

When you are developing on a different branch, you can then create a pull request on GitHub's website. Instructions for this can be found [here](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request).


## Design and Implementation

To be added.