2.5 KiB
metadata.title = "Kotlin and Minecraft Forge"
metadata.category = "minecraft"
metadata.date = "2016-08-06 16:45:30 -0400"
metadata.oldPermalink = "/forge/2016/08/06/kotlin-and-forge/"
So, you wanna use Kotlin in your Forge mod? Well there's good news, I've just released Forgelin, a fork of Emberwalker's Forgelin, a library that provides utilities for using Kotlin with Minecraft/Forge.
Forgelin provides a Kotlin langauge adapter that allows your main-mod class to be a object
. In order to use the language adapter, you must specify the modLanguageAdapter
property in your @Mod
annotation to be net.shadowfacts.forgelin.KotlinAdapter
.
Additionally, Forgelin repackages the Kotlin standard library, reflect library, and runtime so that you don't have to, and so that end users don't have to download the 3 megabytes of Kotlin libraries multiple times.
Additionally, Forgelin provides a number of extensions (which are viewable here) for working with Minecraft/Forge.
While you can shade Forgelin, it is not recommended to do so. It will increase your jar size by approximately 3 megabytes (as Forgelin itself includes the entire Kotlin, standard lib, reflect lib, and runtime) and may cause issues with other mods that shade Kotlin or Forgelin. It is recommended that you have your users download Forgelin from CurseForge.
Update Feb 17, 2017:
- As of Forgelin 1.1.0, the extensions have been moved from Forgelin to ShadowMC.
- As of Forgelin 1.3.0, Forgelin includes an
@Mod
annotated object. This means:- Forgelin can no longer be shaded.
required-after:forgelin;
can now be used in thedependencies
field of your@Mod
annotation for a nicer error message when Forgelin isn't installed.
A bare-bones example mod using Forgelin is available here.