dtcraft-datapacks
A collection of vanilla enhancement datapacks and utilities. Click on the following datapacks for specific usage and installation information or see the general Installation section here.
Note These datapacks are in development and may not be stable or up to date.
Autocraft
Automate the crafting process with a redstone enabled crafting table.
Inventory Sort
A quality of life datapack that will sort your inventory (excluding hotbar) into a defined group ordering.
Refill
Automatically refill an empty stack of a hotbar item with available stacks from your inventory.
Library Datapacks
The following datapacks are libraries of functions that are intended to be used by other datapacks, and are not standalone.
Call-stack
This datapack provides some bare bones support for a call stack like data structure, providing scope to your function variables. This is very convenient for avoiding side effects from other functions overwriting variable values.
Array
This datapack encapsulates common array operations.
Crafting
This datapack offers an api for crafting items from recipes through commands.
Inventory
This datapack offers a number of commonly repeated functions for manipulating player inventories complete with shulker box looting. Functions include, getting only hotbar items, only inventory items, replacing a single slot of user inventory with custom item, getting first item by id, and getting all items by id. Other functionality will be added as needed.
Raycast
A utility datapack used for performing raycasts with configurable parameters.
Custom-Block
Easily create blocks with custom models and behaviors.
GUI
Easily create container based GUIs.
Unit-Test
This datapack offers an api for testing functions. Additionally includes experimental multi-tick testing functionality.
Installation
Navigate to the Releases tab and download the desired datapack's .zip
file. Copy the zip file into your Minecraft world's datapacks
folder. Open your Minecraft world and type /reload
.
Library datapacks (intended for datapack devs) such as call-stack
or crafting
can be added to existing datapacks with Lantern Load. This entails adding the load function of the library datapack to the load.json
tag.
For example:
{
"values": [
"dt.crafting:load",
"your_pack:load"
]
}
Building From Source
-
Create a datapack development directory and change directories into it. For example,
mkdir -p dev/datapacks; cd dev/datapacks
-
Clone this repository into your datapack development directory
git clone git@github.com:dthigpen/dtcraft-datapacks.git
-
Create a libraries directory, and put the latest compatible PlayerDB release zip into it.
-
You should have something like
ls dtcraft-datapacks/ libraries/ playerdb-v1.20.zip
-
Navigate into the
dtcraft-datapacks
directory withcd dtcraft-datapacks
. -
Create and source a Python virtual envirnment so that we can install project dependencies. Remember to run the
source
command in the future.python -m venv env source env/bin/activate
-
Install dependencies with
pip
.pip install -e .
-
Run build tasks with
invoke
.# show commands invoke --list # bundle the datapack with dependencies invoke bundle autocraft ~/.minecraft/saves/test-world/datapacks --watch
Datapack Conventions
All of these datapacks utilize the call-stack
utility when calling functions. Functions that implement this utility have function level variables, arguments, and return values without chance of side effects from other functions.
Example
example.mcfunction
data modify storage call_stack: call.arg0 set value "foo"
function namespace:some/function
data modify storage namespace:storage from storage call_stack: call.return
lib/foo_bar.mcfunction
# push a new frame to the stack
function call_stack:push
data modify storage call_stack: this.foo set from storage call_stack: this.arg0
data modify storage call_stack: this.return value "bar"
# pop the frame and replace with parent frame
function call_stack:pop
See the call-stack for more details.
To Do
- Update libraries and dependencies to current Minecraft version
- Update pre-macro mcfunction methods
- Update recursive functions to use
return
- Update tree functions to use
return
Credits
- Rx for providing the essential PlayerDB datapack
- CloudWolf for recipe format inspiration