Instructions for other versions: 1.20.6 | 1.19.2 | 1.14-1.16.5 | 1.17-1.17.1
Makes Kotlin Forge-friendly by doing the following:
- Provides Kotlin stdlib, reflection, JSON serialization, and coroutines libraries.
- Provides
KotlinLanguageProvider
to allow usage of object declarations as @Mod targets. - Provides
AutoKotlinEventBusSubscriber
to allow usage of object declarations as @Mod.EventBusSubscriber targets. - Provides useful utility functions and constants
A 1.19.3 (works for 1.19.4 too) example mod is provided here: 1.19.3 KotlinModdingSkeleton repository
A 1.20 example mod is provided here: 1.20 KotlinModdingSkeleton repository
A 1.20.6 example mod is provided here: 1.20.6 KotlinModdingSkeleton repository
If you aren't sure where to start, make a fork of the KotlinModdingSkeleton repository (replace BRANCH with your version)
git clone --branch BRANCH https://github.com/thedarkcolour/KotlinModdingSkeleton.git
To implement in an existing project, merge the following into your build script:
Gradle
plugins {
// Adds the Kotlin Gradle plugin
id 'org.jetbrains.kotlin.jvm' version '1.9.22'
// OPTIONAL Kotlin Serialization plugin
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.22'
}
repositories {
// Add KFF Maven repository
maven {
name = 'Kotlin for Forge'
url = 'https://thedarkcolour.github.io/KotlinForForge/'
}
}
dependencies {
// Adds KFF as dependency and Kotlin libs (use the variant matching your mod loader)
// FORGE
implementation 'thedarkcolour:kotlinforforge:4.10.0'
// NEOFORGE
implementation 'thedarkcolour:kotlinforforge-neoforge:4.10.0'
}
Gradle (Kotlin)
plugins {
// Adds the Kotlin Gradle plugin
kotlin("jvm") version "1.9.22"
// OPTIONAL Kotlin Serialization plugin
kotlin("plugin.serialization") version "1.9.22"
}
repositories {
// Add KFF Maven repository
maven {
name = "Kotlin for Forge"
setUrl("https://thedarkcolour.github.io/KotlinForForge/")
}
}
dependencies {
// Adds KFF as dependency and Kotlin libs (use the variant matching your mod loader)
// FORGE
implementation("thedarkcolour:kotlinforforge:4.10.0")
// NEOFORGE
implementation("thedarkcolour:kotlinforforge-neoforge:4.10.0")
}
Then, change the following to your mods.toml file:
modLoader="kotlinforforge"
# Change this if you require a certain version of KotlinForForge
loaderVersion="[4.10,)"
Use
thedarkcolour.kotlinforforge.forge.MOD_CONTEXT
instead of net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext