Skip to content

Latest commit

 

History

History
105 lines (91 loc) · 3.79 KB

README.md

File metadata and controls

105 lines (91 loc) · 3.79 KB

KotlinForForge

Instructions for other versions: 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

MIGRATION GUIDE

A 1.21 Forge example mod is provided here: 1.21 KotlinModdingSkeleton Forge repository A 1.21 NeoForge example mod is provided here: 1.21 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.0.0'
    // OPTIONAL Kotlin Serialization plugin
    //id 'org.jetbrains.kotlin.plugin.serialization' version '2.0.0'
}

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)
    implementation 'thedarkcolour:kfflang:5.3.0'
    implementation 'thedarkcolour:kfflib:5.3.0'
    implementation 'thedarkcolour:kffmod:5.3.0'
    // NEOFORGE
    implementation 'thedarkcolour:kotlinforforge-neoforge:5.3.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.0.0"
    // OPTIONAL Kotlin Serialization plugin
    //kotlin("plugin.serialization") version "2.0.0"
}

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)
    implementation("thedarkcolour:kfflang:5.3.0")
    implementation("thedarkcolour:kfflib:5.3.0")
    implementation("thedarkcolour:kffmod:5.3.0")
    // NEOFORGE
    implementation("thedarkcolour:kotlinforforge-neoforge:5.3.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="[5.3,)"

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