-
Notifications
You must be signed in to change notification settings - Fork 4
Creating a Datapack
A DataPack in Kore represents a Minecraft datapack that contains custom game data and resources.
To create a DataPack, use the dataPack
function:
dataPack("my_datapack") {
// datapack code here
}.generate()
This will generate the datapack with the given name in the out
folder by default. If generate()
is not called, the datapack will not be
generated.
Check the Generation section for more information.
To change the output folder, use the path
property:
dataPack("my_datapack") {
path = Path("%appdata%/.minecraft/saves/my_world/datapacks")
}
To add an icon to the datapack, use the iconPath
property:
dataPack("my_datapack") {
iconPath = Path("icon.png")
}
See Configuration
The dataPack
function generates a pack.mcmeta
file containing metadata about the datapack.
Configure this metadata using the pack
block:
dataPack("mydatapack") {
pack {
format = 15
description = textComponent("My Datapack")
supportedFormat(15..20)
}
}
-
format
- The datapack format version. -
description
- A text component for the datapack description. -
supportedFormats
- The supported format versions.
Filters are used to filter out certain files from the datapack. For now, you can only filter out block files.
For example, to filter out all .txt
files:
dataPack("my_datapack") {
filter {
blocks("stone*")
}
}
This will filter out all block files that start with stone
.
The main content of the datapack is generated from the various builder functions like biome
, lootTable
, etc.
For example:
dataPack("my_datapack") {
// ...
recipes {
craftingShaped("enchanted_golden_apple") {
pattern(
"GGG",
"GAG",
"GGG"
)
key("G", Items.GOLD_BLOCK)
key("A", Items.APPLE)
result(Items.ENCHANTED_GOLDEN_APPLE)
}
}
}
This demonstrates adding a custom recipe to the datapack.
To generate the datapack, call the generate()
function:
dataPack("my_datapack") {
// datapack code here
}.generate()
This will generate the datapack with the given name in the out
folder by default.
To change the output folder, use the path
property:
dataPack("my_datapack") {
path = Path("%appdata%/.minecraft/saves/my_world/datapacks")
}.generate()
To generate a zip file of the datapack, use the generateZip
function:
dataPack("my_datapack") {
// datapack code here
}.generateZip()
To merge the generated datapack with an existing datapack, use the DSL with the function mergeWithDatapacks
:
dataPack("my_datapack") {
// datapack code here
}.generate {
mergeWithDatapacks("existing_datapack 1", "existing_datapack 2")
}
If a zip is provided, it will be considered as a datapack and merged with the generated datapack.
It will unzip the zip in a temporary folder of your system and merge it with the generated datapack, this will not remove the temporary
folder.
When merging with other datapacks, Kore will check if the pack format is the same. If it is not, it will print a warning message.
Example:
val myDatapack1 = dataPack("my_datapack 1") {
// datapack code here
pack {
format = 40
}
}
val myDatapack2 = dataPack("my_datapack 2") {
// datapack code here
pack {
format = 50
}
}
myDatapack1.generate {
mergeWithDatapacks(myDatapack2)
}
This will print out the following message:
The pack format of the other pack is different from the current one. This may cause issues.
Format: current: 40 other: 50.
It also checks for supportedFormats
and warns if the other pack is not supported.
When merging with other datapacks, Kore will merge the tags minecraft/tags/function/load.json
and minecraft/tags/functions/tick.json
.
Example:
val myDatapack1 = dataPack("my_datapack 1") {
// datapack code here
load("my_main_function") {
say("Hello World!")
}
}
val myDatapack2 = dataPack("my_datapack 2") {
// datapack code here
load("load") {
say("Hello Everyone!")
}
}
myDatapack1.generate {
mergeWithDatapacks(myDatapack2)
}
The resulting load.json
file will contain:
{
"replace": false,
"values": [
"my_datapack_1:generated_scope/my_main_function",
"my_datapack_2:generated_scope/load"
]
}
Explore the different pages:
Helpers: