-
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 generate a JAR file for your datapack, use the generateJar
function. This function packages the datapack into a JAR file which can then
be used directly with your Minecraft installation or distributed for others to use.
dataPack("my_datapack") {
// datapack code here
}.generateJar()
By calling generateJar()
, the generated JAR file will be placed in the default output folder. If you wish to specify a different location,
use the path
property:
dataPack("my_datapack") {
path = Path("path/to/output/folder")
}.generateJar()
You can also configure the JAR generation for different mod loaders such as Fabric, Forge, Quilt, and NeoForge.
This will add metadata to the JAR file that is specific to the mod loader.
You will be able to include your datapack as a mod for your mod loader and simplify the installation process for users.
Below are examples of how to set up these mod loaders:
To configure Fabric mod loader, use the fabric
block inside the generateJar
function:
dataPack("my_datapack") {
// datapack code here
}.generateJar {
fabric {
version = "1.2.5"
contact {
email = "kore@kore.kore"
homepage = "https://kore.ayfri.com"
}
author("Ayfri")
}
}
This sets the Fabric version, and includes contact information and the author's name.
To configure Forge mod loader, use the forge
block:
dataPack("my_datapack") {
// datapack code here
}.generateJar {
forge {
mod {
authors = "Ayfri"
credits = "Generated by Kore"
dependency("my_dependency") {
mandatory = true
version = "1.2.5"
}
}
}
}
This sets the mod authors, credits, and dependencies for Forge.
To configure Quilt mod loader, use the quilt
block:
dataPack("my_datapack") {
// datapack code here
}.generateJar {
quilt("kore") {
metadata {
contact {
email = "kore@kore.kore"
homepage = "https://kore.ayfri.com"
}
contributor("Ayfri", "Author")
}
version = "1.2.5"
}
}
This sets the metadata such as contact information and contributors for Quilt.
To configure NeoForge mod loader, use the neoForge
block:
dataPack("my_datapack") {
// datapack code here
}.generateJar {
neoForge {
mod {
authors = "Ayfri"
credits = "Generated by Kore"
dependency("my_dependency") {
type = NeoForgeDependencyType.REQUIRED
version = "1.2.5"
}
}
}
}
This sets the authors, credits, and dependencies for NeoForge.
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:
- Home
- Chat Components
- Configuration
- Creating a Datapack
- Functions
- Data-Driven Features:
- Scoreboards
Helpers: