Kotlin for Forge is a library mod that enables mod developers to write Minecraft mods using the Kotlin programming language. So it works with both Forge and NeoForge mod loaders, providing the necessary infrastructure to use Kotlin in mod development.
What It Does
The mod bundles the Kotlin standard library, reflection, JSON serialization, and coroutines libraries into the mod environment. It provides a KotlinLanguageLoader that allows developers to use Kotlin object declarations as @Mod targets. And it offers AutoKotlinEventBusSubscriber to enable the use of object declarations as @EventBusSubscriber targets. The mod also includes useful utility functions and constants for common tasks.
Who It's For
If you are a mod developer who prefers Kotlin over Java, you can add Kotlin for Forge as a dependency to write your mod in Kotlin. If you aren't a mod developer, you only need this mod when another mod that uses it's installed - it functions as a dependency mod in such cases.
Compatibility
Kotlin for Forge is available for multiple Minecraft versions across different release lines. The 5.12.0 release supports Minecraft 1.21, 1.21.1, 1.21.2, 1.21.3, 1.21.4, 1.21.5, 1.21.6, 1.21.7, and 1.21.8 on both Forge and NeoForge. This 6.x series targets NeoForge only and includes versions for Minecraft 1.21.9, 1.21.10, and 1.21.11. So that 4.x line covers Minecraft 1.19.3 through 1.20.4 on both Forge and NeoForge.
How It Works
Kotlin for Forge shades the Kotlin libraries into your mod environment, making them available without conflicts. It provides its own implementation of IEventBus that supports addListener and addGenericListener with function references. Developers aren't required to use the language loader or any of the provided features; the mod can be used solely for its bundled Kotlin libraries if desired.
Getting Started
For developers starting a new project, the project provides a KotlinModdingSkeleton repository on GitHub that can be forked to begin development. Honestly, for existing projects, users can add the KFF Maven repository and the Kotlin for Forge dependency to their build script. They must also set the mod loader to kotlinforforge in their neoforge.mods.toml file.
License
Kotlin for Forge is licensed under the GNU Lesser General Public License v2.1 only.