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
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
@Modannotated object. This means:
- Forgelin can no longer be shaded.
required-after:forgelin;can now be used in the
dependenciesfield of your
@Modannotation for a nicer error message when Forgelin isn’t installed.
A bare-bones example mod using Forgelin is available here.
Comments powered by ActivityPub. To respond to this post, enter your username and instance below, or copy its URL into the search interface for client for Mastodon, Pleroma, or other compatible software. Learn more.