Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Introduction

MCpypack is a Python library to make the creation of Minecraft datapack easier.

In this book you will learn how to install MCpypack and how to use it properly.

We make the assumption that you already know how Python works.
Although you probably do not need to know a lot.

Installation

⚠️ Warning This guide only covers Linux Systems.

Python Version

MCpypack requires Python 3.14 or higher.
Run:

python --version

It should at least show:

Python 3.14.0

Virtual Environment

The next step is to create a new virtual environment in the directory of your project.

python -m venv venv

Then activate it.

source venv/bin/activate

Install MCpypack

Now you can install MCpypack via pip with the following command:

pip install MCpypack

Creating a new Datapack

In order to create a new datapack you first have to import MCpypack.

from MCpypack import *

Then you create a new datapack object using the Datapack class.

The Datapack class takes 5 arguments.
Out of them 3 are required and 2 are optional.

  • Required:
    • name: Name of the datapack.
    • description: Description of the datapack.
    • version: The Minecraft version the datapack should be created for.
my_pack: Datapack = Datapack(
    name="My Datapack",
    description="My first datapack",
    version="26.1"
)
  • Optional:
    • relative_icon_path: Relative path to an icon that should be used for your datapack.
    • relative_export_dir: Directory to export the datapack to. Default is export/.

In the end you have to export your datapack using the export method.

my_pack.export()

There are 2 optional parameters for this method.

  • overwrite: Whether the old version should be overwritten (True) or get a different name (False). Default is True.
  • zip: Whether a .zip should be created. Default is True.

Whole code

from MCpypack import *

my_pack: Datapack = Datapack(
    name="My Datapack",
    description="My first datapack",
    version="26.1"
)

my_pack.export()

Adding Namespaces

To add new namespaces to your datapack you use the Namespace class and the add_namespaces method from the Datapack class.

my_namespace: Namespace = Namespace(name="my_namespace")

my_pack.add_namespaces(my_namespace)

Of course you can create multiple namespaces.

Whole code

from MCpypack import *

my_pack: Datapack = Datapack(
    name="My Datapack",
    description="My first datapack",
    version="26.1"
)

my_namespace: Namespace = Namespace(name="my_namespace")
my_pack.add_namespaces(my_namespace)

my_pack.export()