M

Kotlin for Forge: Empowering Kotlin Mod Development

MOD

Kotlin for Forge provides essential language support and utilities for creating Minecraft mods using Kotlin, serving as a vital dependency.

For Minecraft mod developers looking to leverage the modern capabilities of the Kotlin programming language, Kotlin for Forge provides the foundational support needed. This library adds a robust Kotlin language loader to the Forge ecosystem, enabling you to write your mods entirely in Kotlin, benefiting from Kotlin's concise syntax and powerful features.

Kotlin for Forge functions by shading the necessary Kotlin libraries directly into your mod environment, ensuring compatibility and ease of use. If you are a player, it is crucial to understand that this is a dependency mod; it will be required by any mod built with Kotlin for Forge to function correctly. Mod developers, however, will find a suite of tools designed to streamline their workflow, from automatic event bus subscriptions to custom utility functions.

  • A dedicated KotlinLanguageProvider to load your @Mod object declarations, integrating your Kotlin-based mod into Forge.
  • Automatic handling of event subscriptions with AutoKotlinEventBusSubscriber for @EventBusSubscriber declarations.
  • Bundling of essential Kotlin libraries, including Kotlin 1.4.21, Kotlin coroutines 1.4.2, Kotlin JSON serialization 1.0.1, and Jetbrains annotations 20.1.0.
  • An advanced IEventBus implementation, distinct from Kottle, which supports function references for both IEventBus#addListener and IEventBus#addGenericListener.
  • A collection of useful utility functions and constants to aid in common mod development tasks.

As a player, the primary requirement for Kotlin for Forge is to install it if any mod you wish to use lists it as a dependency. For mod developers, while the full suite of language loading and utility features is available, you retain the flexibility to solely utilize Kotlin for Forge for its bundled Kotlin libraries, even if you choose not to use its specific language loader or other provided features. This ensures you have access to up-to-date Kotlin functionality without enforcing its full framework upon your project.