A Kotlin library to write Datapacks for Minecraft.
This library is compatible and made for Minecraft Java 1.20 and later versions, I don't think I will support older versions nor Bedrock
Edition.
You can still create your own fork and make it compatible with older versions.
I will accept pull requests for older versions on a separate branch.
You can use the Kore Template to start a new project with Kore.
Or install the library by hand with Gradle.
With Kotlin DSL:
implementation("io.github.ayfri.kore:kore:VERSION")
With Groovy DSL:
implementation 'io.github.ayfri.kore:kore:VERSION'
Then activate the -Xcontext-receivers
compiler option:
kotlin {
compilerOptions {
freeCompilerArgs.add("-Xcontext-receivers")
}
}
You should also use Java 21 or higher:
kotlin {
jvmToolchain(21)
}
Then create a Main.kt
file and start writing your datapacks. See
the documentation for more information.
fun main() {
val datapack = dataPack("test") {
function("display_text") {
tellraw(allPlayers(), textComponent("Hello World!"))
}
recipes {
craftingShaped("enchanted_golden_apple") {
pattern(
"GGG",
"GAG",
"GGG"
)
key("G", Items.GOLD_BLOCK)
key("A", Items.APPLE)
result(Items.ENCHANTED_GOLDEN_APPLE)
}
}
function("tp_random_entity_to_entity") {
val entityName = "test"
val entity = allEntities(limitToOne = true) {
name = entityName
}
summon(Entities.CREEPER, vec3(), nbt {
this["CustomName"] = textComponent("Hello World!")
})
execute {
asTarget(allEntities {
limit = 3
sort = Sort.RANDOM
})
ifCondition {
score(self(), "test") lessThan 10
}
run {
teleport(entity)
}
}
}
pack {
description = textComponent("Datapack test for ", Color.GOLD) + text("Kore", Color.AQUA) { bold = true }
}
}
datapack.generateZip()
}
- Datapack generation as files or zips or jar files for mod-loaders.
- Function generation.
- All commands with all subcommands and multiple syntaxes.
- Generation of all JSON-based features of Minecraft (Advancements, Loot Tables, Recipes, ...).
- Selectors.
- NBT tags.
- Chat components.
- Lists for all registries (Blocks, Items, Entities, Advancements, ...).
- Colors/Vector/Rotation/... classes with common operations.
- Macros support.
- Inventory/Scheduler managers.
- Merging datapacks, even with existing zips.
- Scoreboard display manager (like on servers).
- Debugging system inside commands or functions.
- Common Nbt tags generation (blocks, items, entities, ...).
- OOP module (experimental).
Note: All APIs for commands, selectors, NBT tags, ... are public, so you can use them to create your own features.
If you want to contribute to this project, you can follow these steps:
- Fork the repository.
- Run gradle
kore:run
to run the tests. - Make your changes.
- Create a pull request and wait for it to be reviewed and merged.
You can also create an issue if you find a bug or if you want to suggest a new feature.
If you want to support the project, please consider donating !
This project is licensed under the GNU 3.0 License – see the LICENSE file for details.