Kottle
Kotlin language provider for Forge 1.13.2+. Originally a rewrite of Shadowfacts's Forgelin.
- Shades the Kotlin standard library, runtime, and reflect libraries so you don't have to.
- Provides a Forge
IModLanguageProvider
for using Kotlinobject
classes as your main mod class and adds support forobject
instances for@Mod.EventBusSubscriber
Usage
First of all, make sure you're on Forge 25.0.15 or higher.
Then, in your build.gradle
:
buildscript {
repositories {
jcenter()
}
dependencies {
// Remove this line: classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
// trove is forked and used by kotlin and we have to use it instead of the one forked by Forge
// to avoid compilation errors on Linux (see PR #2)
classpath(group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true) {
exclude group: 'trove', module: 'trove'
}
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
apply plugin: 'kotlin'
repositories {
maven { url 'https://minecraft.curseforge.com/api/maven/' }
}
dependencies {
compile "kottle:Kottle:$kottleVersion"
}
, in your gradle.properties
:
# This is your kotlin gradle plugin version. For now, use 1.3.21.
kotlinVersion = 1.3.21
# For now, use 1.0.5.
kottleVersion = 1.0.5
, in your mods.toml
:
modLoader="kotlinfml"
loaderVersion="[1,)"
Then download Kottle from here and drop it into your run/mods
folder of MDK. Create the folder if it doesn't exist.
Finally, replace FMLJavaModLoadingContext
references in your code with FMLKotlinModLoadingContext
and
Mod.EventBusSubcriber
with KotlinEventBusSubcriber
. For more info, checkout test sources
here or my mod,
Roomery, here.