Skip to content

thedarkcolour/KotlinForForge

Repository files navigation

KotlinForForge

Instructions for other versions: 1.20.6-1.21.8 | 1.19.3-1.20.4 | 1.19.2 | 1.14-1.16.5 | 1.17-1.17.1

Makes Kotlin Forge-friendly by doing the following:

  • Provides Kotlin stdlib, reflection, JSON serialization, and coroutines libraries.
  • Provides KotlinLanguageLoader to allow usage of object declarations as @Mod targets.
  • Provides AutoKotlinEventBusSubscriber to allow usage of object declarations as @EventBusSubscriber targets.
  • Provides useful utility functions and constants

To see which versions of the Kotlin libraries is bundled with a particular version of KFF, check the DEPENDENCY CHART.

Have questions or suggestions? Join the DISCORD SERVER.

MIGRATION GUIDE

Forge support Not yet implemented A 1.21.10 Forge example mod is provided here: 1.21 KotlinModdingSkeleton Forge repository
A 1.21.10 NeoForge example mod is provided here: 1.21.10 KotlinModdingSkeleton NeoForge repository

If you aren't sure where to start, make a fork of the KotlinModdingSkeleton repository (replace BRANCH with your version)

git clone --branch BRANCH https://github.com/thedarkcolour/KotlinModdingSkeleton.git 

To implement in an existing project, merge the following into your build script:

Gradle
plugins { // Adds the Kotlin Gradle plugin id 'org.jetbrains.kotlin.jvm' version '2.2.20' // OPTIONAL Kotlin Serialization plugin //id 'org.jetbrains.kotlin.plugin.serialization' version '2.2.20' } repositories { // Add KFF Maven repository maven { name = 'Kotlin for Forge' url = 'https://thedarkcolour.github.io/KotlinForForge/' } } dependencies { // Adds KFF as dependency and Kotlin libs (use the variant matching your mod loader) // FORGE (1.21+ ONLY) NOT IMPLEMENTED YET //implementation 'thedarkcolour:kotlinforforge:6.0.0' // NEOFORGE implementation 'thedarkcolour:kotlinforforge-neoforge:6.0.0' } // ONLY ON REGULAR FORGE sourceSets.each { def dir = layout.buildDirectory.dir("sourcesSets/$it.name")	it.output.resourcesDir = dir	it.java.destinationDirectory = dir	it.kotlin.destinationDirectory = dir }
Gradle (Kotlin)
plugins { // Adds the Kotlin Gradle plugin kotlin("jvm") version "2.2.20" // OPTIONAL Kotlin Serialization plugin //kotlin("plugin.serialization") version "2.2.20" } repositories { // Add KFF Maven repository maven { name = "Kotlin for Forge" setUrl("https://thedarkcolour.github.io/KotlinForForge/") } } dependencies { // Adds KFF as dependency and Kotlin libs (use the variant matching your mod loader) // FORGE (1.21+ ONLY) NOT IMPLEMENTED YET // implementation("thedarkcolour:kotlinforforge-neoforge:6.0.0") // NEOFORGE implementation("thedarkcolour:kotlinforforge-neoforge:6.0.0") } // ONLY ON REGULAR FORGE sourceSets.configureEach { val dir = layout.buildDirectory.dir("sourcesSets/$name") output.setResourcesDir(dir) java.destinationDirectory.set(dir) kotlin.destinationDirectory.set(dir) }

Then, change the following to your neoforge.mods.toml file:

modLoader="kotlinforforge" # Change this if you require a certain version of KotlinForForge loaderVersion="[6.0,)"

Use thedarkcolour.kotlinforforge.forge.MOD_BUS instead of
instead of net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext

About

Makes Kotlin forge-friendly.

Topics

Resources

License

Stars

Watchers

Forks