Branch 26.1
This mod adds a Scala library to Minecraft 26.1.2 with Forge and NeoForge. NO COMPATIBILITY WITH 1.x version of SLP.
-
For Player – Download a Jar file from Curse Forge or Modrinth and move the file to your
modsfolder. This mod will not appear in the mod list. -
For Developer
See the example directory.In your
build.gradle, add below code in the top-level.repositories { maven { name = "kotori316" url = uri("https://maven.kotori316.com") content { // The artifact id differs by loader: "scalablecatsforce" for Forge, // "scalablecatsforce-neoforge" for NeoForge. includeModule("com.kotori316", "scalablecatsforce") includeModule("com.kotori316", "scalablecatsforce-neoforge") } } } dependencies { // Add Forge or NeoForge dependency as the platform requires // Scala, no need to add Scala2 dependency since 3.8.3 implementation('org.scala-lang:scala3-library_3:3.8.4') // Add if you need this library. // the runtime copy is bundled in the SLP jar. implementation('org.typelevel:cats-kernel_3:2.13.0') // The language loader. You can put the jar to the mods dir instead of declaring in `build.gradle.kts`. // Pick the artifact for your loader (the version below is shared by both). // Forge: runtimeOnly("com.kotori316:scalablecatsforce:5.0.0-mc26.1.2-3.8.4:dev") { transitive(false) } // NeoForge: // runtimeOnly("com.kotori316:scalablecatsforce-neoforge:5.0.0-mc26.1.2-3.8.4:dev") { // transitive(false) // } }- If the Minecraft client doesn't launch with an exception to modules, change scala dependency from "implementation" to "compileOnly" and add slp mod in the mods directory.
- The published artifact id depends on the loader:
com.kotori316:scalablecatsforce(Forge) andcom.kotori316:scalablecatsforce-neoforge(NeoForge). Available versions are listed in their Maven metadata: - Change the library version if needed.
- See detail pages in CurseForge or Modrinth to get which library version is included in the Jar file.
- From 26.1.2 version, SLP includes Scala 3.8.4
In this section, I note some points you should care.
- Avoid use of
Mod.EventBusSubscriberin Java code. This will cause exception in "compileScala" task.
- Use in Scala code will not throw an exception.
- If you got the compile error "ambiguous reference to overloaded definition", specify the return type.
- For example,
val offsetPos = pos.relative(direction)will cause this error becauserelativeis declared both inBlockPosandVec3i, and the return types are different. So, the compiler can't determine which method to call. To resolve this issue, specify the return type as follows.val offsetPos: BlockPos = pos.relative(direction)
- On Forge, do not import the per-primitive Cats convenience packages
cats.kernel.instances.{byte, char, short, int, long, float, double, boolean}directly.
- These packages are named after Java reserved words, so the Forge jar drops them (see the API section). Code such as
import cats.kernel.instances.int.*compiles against the official Cats but throwsNoClassDefFoundError: cats/kernel/instances/int/package$at runtime on Forge. The instances are still available viacats.implicits.*,cats.syntax.*,cats.kernel.instances.all.*, orcats.kernel.instances.<Type>Instances(e.g.cats.kernel.instances.IntInstances). NeoForge bundles the jars as-is and is unaffected.
- Scala - GitHub - is licenced under the Apache License, Version 2.0.
- Cats - GitHub - is licenced under
the License.
- SLP bundles the official Cats. NeoForge uses the jars as-is. The Forge jar removes the
Java-reserved-word packages (e.g.
cats.kernel.instances.byte) fromcats-kernel, because Forge's module system rejects them while building the module layer at boot.
- SLP bundles the official Cats. NeoForge uses the jars as-is. The Forge jar removes the
Java-reserved-word packages (e.g.