search

linkCreating 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()
Kotlin

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.

linkChanging Output Folder

To change the output folder, use the path property:

dataPack("my_datapack") {
	path = Path("%appdata%/.minecraft/saves/my_world/datapacks")
}
Kotlin

linkAdding Icon

To add an icon to the datapack, use the iconPath property:

dataPack("my_datapack") {
	iconPath = Path("icon.png")
}
Kotlin

linkConfiguration

See Configuration

linkPack Metadata

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)
	}
}
Kotlin
  • format - The datapack format version.
  • description - A text component for the datapack description.
  • supportedFormats - The supported format versions.

linkFilters

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*")
	}
}
Kotlin

This will filter out all block files that start with stone.

linkContent

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)
		}
	}
}
Kotlin

This demonstrates adding a custom recipe to the datapack.

linkGeneration

To generate the datapack, call the generate() function:

dataPack("my_datapack") {
	// datapack code here
}.generate()
Kotlin

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()
Kotlin

linkZip Generation

To generate a zip file of the datapack, use the generateZip function:

dataPack("my_datapack") {
	// datapack code here
}.generateZip()
Kotlin

linkJar Generation

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()
Kotlin

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()
Kotlin

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:

linkFabric

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 = "[email protected]"
			homepage = "https://kore.ayfri.com"
		}

		author("Ayfri")
	}
}
Kotlin

This sets the Fabric version, and includes contact information and the author's name.

linkForge

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"
			}
		}
	}
}
Kotlin

This sets the mod authors, credits, and dependencies for Forge.

linkQuilt

To configure Quilt mod loader, use the quilt block:

dataPack("my_datapack") {
	// datapack code here
}.generateJar {
	quilt("kore") {
		metadata {
			contact {
				email = "[email protected]"
				homepage = "https://kore.ayfri.com"
			}
			contributor("Ayfri", "Author")
		}

		version = "1.2.5"
	}
}
Kotlin

This sets the metadata such as contact information and contributors for Quilt.

linkNeoForge

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"
			}
		}
	}
}
Kotlin

This sets the authors, credits, and dependencies for NeoForge.

linkMerging with existing datapacks

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")
}
Kotlin

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.

linkChecking for compatibility

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)
}
Kotlin

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.
Null

It also checks for supportedFormats and warns if the other pack is not supported.

linkTags

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)
}
Kotlin

The resulting load.json file will contain:

{
	"replace": false,
	"values": [
		"my_datapack_1:generated_scope/my_main_function",
		"my_datapack_2:generated_scope/load"
	]
}
JSON