Awesome
fabric-language-kotlin
Fabric language module for Kotlin. Adds support for Kotlin exclusive entrypoints and bundles the Kotlin Stdlib as well as common kotlinx libraries.
Usage
Dependency
Add it as a dependency to your Gradle project:
dependencies {
modImplementation("net.fabricmc:fabric-language-kotlin:1.13.0+kotlin.2.1.0")
}
Adapter
Use the kotlin
adapter for your mod by setting the adapter
property in the fabric.mod.json
file.
Remember to the add a dependency entry to your fabric.mod.json
file:
{
"schemaVersion": 1,
"entrypoints": {
"main": [
{
"adapter": "kotlin",
"value": "package.ClassName"
}
]
},
"depends": {
"fabric-language-kotlin": ">=1.13.0+kotlin.2.1.0"
}
}
For more info reference the fabric.mod.json documentation.
Do not forget to set the schemaVersion
to 1
or it will fall back to schema 0
and will not attempt to load entrypoints.
Entrypoint samples
<table> <tr> <th><i>Kind</i></th> <th>Class reference</th> <th>Function reference</th> <th>Field reference</th> </tr> <tr> <td><code>class</code></td> <td>{
"adapter": "kotlin",
"value": "mymod.MyMod"
}
package mymod
class MyMod : ModInitializer {
override fun onInitialize() {
TODO()
}
}
</td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>object</code></td>
<td>
{
"adapter": "kotlin",
"value": "mymod.MyMod"
}
package mymod
object MyMod : ModInitializer {
override fun onInitialize() {
TODO()
}
}
</td>
<td>
{
"adapter": "kotlin",
"value": "mymod.MyMod::init"
}
package mymod
object MyMod {
fun init() {
TODO()
}
}
</td>
<td>
{
"adapter": "kotlin",
"value": "mymod.MyMod::initializer"
}
package mymod
object MyMod {
val initializer = ModInitializer {
TODO()
}
}
</td>
</tr>
<tr>
<td><code>companion object</code></td>
<td>
{
"adapter": "kotlin",
"value": "mymod.MyMod$Companion"
}
package mymod
class MyMod {
companion object : ModInitializer {
override fun onInitialize() {
TODO()
}
}
}
</td>
<td>
{
"adapter": "kotlin",
"value": "mymod.MyMod$Companion::init"
}
package mymod
class MyMod {
companion object {
fun init() {
TODO()
}
}
}
</td>
<td>
{
"adapter": "kotlin",
"value": "mymod.MyMod$Companion::initializer"
}
package mymod
class MyMod {
companion object {
val initializer = ModInitializer {
TODO()
}
}
}
</td>
</tr>
<tr>
<td><code>top level</code></td>
<td></td>
<td>
{
"adapter": "kotlin",
"value": "mymod.MyModKt::init"
}
File: src/main/kotlin/mymod/MyMod.kt
package mymod
fun init() {
TODO()
}
</td>
<td></td>
</tr>
</table>
Companion objects can be used by appending $Companion
to the class.
Take care of processResources
there, it might try to expand it, in that case escape it.
Bundled libraries
org.jetbrains.kotlin
namespace:
org.jetbrains.kotlinx
namespace:
kotlinx-coroutines-core
1.9.0 Guide, API docs, GitHubkotlinx-coroutines-jdk8
1.9.0 API docskotlinx-serialization-core
1.7.3 Guide, API docs, GitHubkotlinx-serialization-json
1.7.3 API docskotlinx-serialization-cbor
1.7.3 API docsatomicfu
0.26.1 GitHubkotlinx-datetime
0.6.1 GitHubkotlinx-io-core
0.6.0 API docs, GitHubkotlinx-io-bytestring
0.6.0 API docs
Available Versions
https://maven.fabricmc.net/net/fabricmc/fabric-language-kotlin/
Updating README
- Update the readme in
templates/README.template.md
. - Run
./gradlew processMDTemplates
.