
If you are writing a Fabric mod in Kotlin, Fabric Language Kotlin gives you two things: the Kotlin runtime libraries at play time, and an entrypoint adapter that understands Kotlin declarations. This guide follows the official README.
1. Add the Gradle dependency
The project is published to Fabric's Maven repository, which Fabric Loom already uses. The README shows the dependency like this. Replace the version with the release you target.
Also apply the Kotlin JVM Gradle plugin, so your Kotlin sources compile. Keep its Kotlin version no newer than the Kotlin version bundled in the Fabric Language Kotlin release you depend on.
Starting a new project? Fabric's online template generator can create a Kotlin-ready project for you, which saves setting up the plugin by hand.
2. Set the adapter in fabric.mod.json
Tell Fabric to use the Kotlin adapter for your entrypoints, and declare the dependency, so players get a clear message if it is missing:
The README warns that schemaVersion must be set to 1. Without it, Fabric treats the file as schema 0, which does not load entrypoints.
3. Pick an entrypoint style
The Kotlin adapter supports more shapes than plain Java classes. The value string changes with each style:
| Style | value | Kotlin declaration |
|---|---|---|
| Class | mymod.MyMod | class MyMod : ModInitializer |
| Object | mymod.MyMod | object MyMod : ModInitializer |
| Object function | mymod.MyMod::init | object MyMod { fun init() } |
| Object field | mymod.MyMod::initializer | val initializer = ModInitializer { } in an object |
| Companion object | mymod.MyMod$Companion | companion object : ModInitializer |
| Companion function | mymod.MyMod$Companion::init | companion object { fun init() } |
| Top-level function | mymod.MyModKt::init | fun init() in MyMod.kt |
For companion objects, the README notes that Gradle's processResources may try to expand the $Companion part, so you may need to escape it.
4. Use the bundled libraries
Because Fabric Language Kotlin ships kotlinx coroutines, serialization (core, JSON and CBOR), atomicfu, datetime and io, you can use them without packing your own copies. Add them as compile-time dependencies in your build if your IDE needs them for autocompletion. At runtime, players already have them through Fabric Language Kotlin.
5. Tell players what to install
- List Fabric Language Kotlin as a required dependency on your mod page.
- State the minimum version, the same one you wrote in
depends. - Link players to an install guide, for example our installation walkthrough.
Choosing which version to target
Target the release whose bundled Kotlin version matches the compiler you use. A higher minimum gives you newer Kotlin features but asks players to update. See Version Numbers Explained for how the version string is built.
Keep language integration explicit in your project
A Kotlin Fabric project benefits from deliberate build configuration rather than relying on libraries that happen to arrive through another dependency. Define the Kotlin compiler plugin and the Fabric Language Kotlin dependency in the relevant Gradle configuration, then make sure the versions are selected together. The library module supplies runtime support, while the Kotlin compiler transforms source code into JVM bytecode; they solve different problems. Build reproducibility improves when version values live in one documented place, such as a version catalog or central Gradle property. That makes dependency upgrades reviewable and reduces accidental differences between a local workstation and a continuous integration environment.
Design entrypoints with predictable lifecycle behaviour
The entrypoint adapter connects Fabric Loader to Kotlin declarations, but the existence of an adapter does not eliminate lifecycle considerations. Your main entrypoint should perform only work appropriate to the startup phase in which it runs. Avoid accessing client-only classes from code loaded by a dedicated server, and separate client registration from common initialisation where your mod needs both environments. Kotlin objects and top-level functions can be convenient entrypoints, provided the declaration syntax and adapter configuration match the documented implementation. After editing fabric.mod.json, inspect the packaged jar rather than assuming your source tree configuration was copied correctly.
Test the actual packaged jar
A development environment can hide problems because the IDE supplies dependencies, generated classes, and runtime arguments that differ from an ordinary player's installation. Run the normal Gradle build, locate the final distributable jar, and test it in a separate Fabric instance with only the dependencies you intend to declare. Start with a clean log. If an entrypoint fails to load, check the adapter name, class or function reference, package spelling, and whether Kotlin support is present in that test instance. A successful compilation establishes only that the project built; the clean-instance launch is the stronger evidence that the jar is ready to distribute.
Declare dependencies for users, not just developers
The project metadata should communicate every essential runtime dependency. If your release requires Fabric Language Kotlin, include it in the appropriate dependency declaration and establish a minimum version only when your code genuinely depends on features introduced in that release. Do not choose an arbitrarily high minimum just because it is the newest version available during development. Clear dependency metadata allows launchers and mod managers to identify missing components before the game enters a confusing failure state. It also gives pack maintainers a more accurate picture of what must accompany the mod on clients, servers, or both.
Use an upgrade checklist for compiler changes
When updating Kotlin, check the relationship among the compiler plugin, Gradle, mappings, Fabric Loom, Java toolchain, and the language module. Update one layer at a time whenever feasible and record the outcome of a clean build. Pay particular attention to binary compatibility and any new language features used in source code. A simple smoke test should cover startup, registration, basic interaction with important mod systems, and shutdown without unexpected errors. Maintaining that routine is more valuable than choosing an impressive version number: it gives contributors a repeatable way to evaluate whether a proposed dependency upgrade actually improves the project.
Treat a project release as complete only after it has passed a clean-environment launch. The packaged jar should include accurate metadata and should not depend on IDE conveniences. Keep a short upgrade note describing compiler and runtime changes so that other contributors can reproduce the build and explain why a dependency was raised.
Conclusion
Fabric Language Kotlin is most effective when its role is understood within the broader Fabric setup. Treat a project release as complete only after it has passed a clean-environment launch. The packaged jar should include accurate metadata and should not depend on IDE conveniences. Keep a short upgrade note describing compiler and runtime changes so that other contributors can reproduce the build and explain why a dependency was raised. Make each change deliberately, verify the outcome in the correct game profile, and keep a record of the configuration that works. This practical approach produces a more dependable modded Minecraft experience.

