Download Krysztal's Language Scala — Minecraft Mods — MetaMods

Krysztal's Language Scala

Active

Downloads

0

Last update

3 months ago

Versions

1.17 — 1.21.8
Client and server
Fabric
Libraries

Krysztal's Language Scala

This is an adapted version of the fabric-language-scala library that supports the latest Scala3 versions and includes bundled Scala libraries.

Why This Version Was Created?

Although Scala is not the most popular programming language, its expressive capabilities make it practically ideal for mod development. The original fabric-language-scala was no longer maintained by developers and gradually became non-functional, especially regarding Scala3 support. Therefore, a forked version called krysztal-language-scala was created, which is fully compatible with the original.

The capabilities of this library will be regularly updated and maintained to ensure stable operation.

Usage Instructions

Adding Dependencies

Add the following lines to your project's build.gradle file:

plugins {
  ...
    id 'scala' // Add scala plugin for gradle
  ...
}

repositories {
  ...
    maven { url "https://maven.krysztal.dev/releases" }
  ...
}

dependencies {
  ...
    modImplementation "dev.krysztal:krysztal-language-scala:${project.kls_version}+scala.${project.scala_version}"
  ...
}

Example Usage with class

Suppose your main file is called ExampleEntry.scala:

import net.fabricmc.api.ModInitializer;

class ExampleEntry extends ModInitializer {
   lazy val logger = LoggerFactory.getLogger("KMMO")
   override def onInitialize(): Unit = {
       logger.info("Hi")
   }
}

And in the fabric.mod.json file:

    ...
 "entrypoints": {
    "main": [
      "dev.example.ExampleEntry"
    ],
  },
    ...

Thanks to Scala's excellent compatibility with Java, this library can be used as a standard Java entry point.

Example Usage with object

Suppose your main file is called ExampleEntry.scala:

import net.fabricmc.api.ModInitializer;

object ExampleEntry extends ModInitializer {
    lazy val logger = LoggerFactory.getLogger("KMMO")
    override def onInitialize(): Unit = {
        logger.info("Hi")
    }
}

And in the fabric.mod.json file:

    ...
 "entrypoints": {
    "main": [
      {
        "adapter": "scala",
        "value": "dev.example.ExampleEntry"
      }
    ],
  },
    ...

Known Issues

Unknown invokedynamic bsm: scala/runtime* - this issue is caused by Scala's class loading mechanism. It practically doesn't affect anything and can be ignored.

Project members
Krysztal112233

Krysztal112233

Developer

Created: 8 Apr 2024

ID: 20676