Kotlin language provider for Forge 1.13-1.15. 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
- Currently provides Kotlin libraries with version
1.3.61
, Kotlin coroutines version1.3.2
and JetBrains annotations version18.0.0
.
First of all, make sure you're on Forge 31.0.0 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 {
implementation "kottle:Kottle:$kottleVersion"
}
, in your gradle.properties
:
# This is your kotlin gradle plugin version. For now, use 1.3.61.
kotlinVersion = 1.3.61
# Change this to the most recent release version from CurseForge
kottleVersion = 1.5.2
, in your mods.toml
:
modLoader="kotlinfml"
loaderVersion="[1,)"
Finally, replace FMLJavaModLoadingContext
references in your code with FMLKotlinModLoadingContext
.
For more info, checkout test sources here or my mod, Roomery, here.
-
addListener(SetupLifecycle::registerItems)
crashes the game:TL;DR: nothing that can be done about it. Use other methods. See #8