A python library for creating Minecraft Datapacks!
The examples below are combined into a python file located in the examples folder.
from pydatapack import *
dp = Datapack('.','Name','Description')
Functions are objects defined in the library to hold all of the commands run when called in the game. Using .newFunction()
on the datapack pre registers the function with the datapack. This method also returns the Function object created.
hello = dp.functions.newFunction('hello_world')
hello.add_command('say hello')
hello.add_command(tellraw('world!'))
A function can be defined before the datapack, and then added afterwards.
hello = functions.Function('hello_world')
hello.add_command('say hello')
hello.add_command(tellraw('world!'))
dp.functions.registerFunction(hello)
Calling the function (function_name()
) as if it were a python function converts it to a runnable minecraft command.
wrapper = dp.newFunction('hello_world_wrapper')
wrapper.add_command(hello())
compiling the datapack with .compile()
places the unzipped datapack in the current directory.
dp.compile()