Kotlin and Minecraft 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:

  1. As of Forgelin 1.1.0, the extensions have been moved from Forgelin to ShadowMC.
  2. As of Forgelin 1.3.0, Forgelin includes an @Mod annotated object. This means:
    1. Forgelin can no longer be shaded.
    2. required-after:forgelin; can now be used in the dependencies 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.


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.

Reply from your instance: