Bindings (Import Existing Datapacks)
The bindings module isexperimental. APIs and generated output may change without notice.
The bindings module lets you import existing datapacks and generates Kotlin types so you can reference functions, resources, and tags safely in your code.
Install this module
Add the bindings artifact when you want to import an existing datapack and generate Kotlin bindings from it.
Artifact
Best fit
- Use
korefor the main DSL. - Add
bindingswhen you want type-safe access to resources coming from an external datapack. - Combine it with
ooporhelpersonly if your project also needs those higher-level utilities.
Quick start
Using generated bindings
When you import a datapack, Kore generates a data object with a name derived from the datapack's name (e.g., VanillaRefresh).
Accessing resources
Resources are organized by namespace and type. If a datapack has only one namespace, resources are accessible directly:
For more on using commands with imported resources, see Commands.
If the datapack uses multiple namespaces, they are nested:
Tags
Tags are also imported and can be used wherever a tag of that type is expected:
Pack metadata
The generated object also contains information about the original datapack:
When pack metadata is reconstructed in generated bindings, Kore emits the PackSection using the same helpers as handwritten code, including packFormat(...) for version formats and SupportedFormats(...) when legacy supported formats are present.
Generated structure
For each imported datapack, a Kotlin file is generated containing:
- A
data objectnamed after the datapack. - Nested
data objects for each namespace (if multiple). - Nested
enums orobjects for each resource type:Functions: All.mcfunctionfiles.Advancements: All advancements.LootTables: All loot tables.Recipes: All recipes.Tags: All tags, further nested by type (Blocks,Items,Functions, etc.).Worldgen: All worldgen resources, further nested by type (Biomes,Structures, etc.).
Subfolders in the datapack are preserved as nested objects.
Explore without generating
You can explore the content of a datapack programmatically without generating any code.
Download sources
GitHub
Downloads a repository or a specific asset from a release.
Patterns:
user.repo: Latest commit on the default branch.user.repo:tag: Specific tag, branch, or commit.user.repo:tag:asset.zip: Specific asset from a release.
Modrinth
Downloads the latest or a specific version of a Modrinth project.
Patterns:
slug: Latest stable version.slug:version: Specific version ID or number.
CurseForge
Downloads from CurseForge. Requires the CURSEFORGE_API_KEY environment variable or the curseforge.api.key system property
Patterns:
projectId: Latest file for the project.projectId:fileId: Specific file.slug: Project slug.slug:fileId: Specific file for a project slug.URL: Full CurseForge project URL.
URL / local path
Patterns:
https://example.com/pack.zip./path/to/pack(Local folder)./path/to/pack.zip(Local zip)
Configuration
Global configuration
Defined in the configuration {} block:
| Property | Default | Description |
|---|---|---|
outputPath |
build/generated/kore/imported |
Directory where Kotlin files will be generated. |
packagePrefix |
kore.dependencies |
Base package for all generated bindings. |
generateSingleFile |
true |
If true, generates one Kotlin file per datapack. |
skipCache |
false |
If true, re-downloads even if already in cache. |
debug |
false |
Prints extra information during the process. |
Per-datapack configuration
Defined in the block following a source:
TheremappedName property is deprecated. Use remappings { objectName("...") } instead.
Namespace normalization
Namespace names are automatically normalized when generating Kotlin object names: dots (.) and other non-alphanumeric characters are replaced with underscores, then converted to PascalCase. For example, my.namespace becomes MyNamespace. You can override this behavior for any namespace using the remappings {} block described above.
Cache
Downloaded files are cached to speed up subsequent runs in a different directory depending on your OS:
- On Windows,
LOCALAPPDATAor~/AppData/Local/kore. - On macOS,
~/Library/Caches. - On Linux, XDG cache directory or fallback to
~/.cache/kore/datapacks. This can be overridden by theKORE_CACHE_HOMEenvironment variable or thekore.cache.homesystem property. UseskipCache = truein the global configuration or delete the cache folder to force a re-download.
Troubleshooting
- Rate Limits: GitHub API is limited for unauthenticated calls.
- CurseForge API: Ensure your API key is valid and has permissions for the project.
- Invalid resources: If a resource type is unknown to Kore, it will be skipped to avoid generating invalid code.
