Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/ISSUE_TEMPLATE/000-report-bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ body:
required: true
- label: "I have installed [Fugue](https://www.curseforge.com/minecraft/mc-mods/fugue) and it didn't fix my issue."
required: true
- label: "I have installed [Scalar Legacy](https://www.curseforge.com/minecraft/mc-mods/scalar-legacy) and it didn't fix my issue."
required: true
- label: "I have switched my Forgelin and LibrarianLib to continuous versions(check readme for more detail)."
required: true
- label: "I am running a test build from Cleanroom Github Actions. (Or, if I've compiled it myself I plan to fix the issue)"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ As for Cleanroom mods, before Cleanroom 1.0.0, no binary compatibility is guaran

- The official template is [CleanroomModTemplate](https://github.com/CleanroomMC/CleanroomModTemplate). A porting guide is in the [Cleanroom wiki](https://cleanroommc.com/wiki/cleanroom-mod-development/introduction) (WIP).

- Scala 3 and Kotlin 2 are both usable for mod code, through Scalar and Forgelin-Continuous.
- Scala 2.11 and Scala 3 mods run on runtimes Cleanroom provides, Kotlin 2 is usable through Forgelin-Continuous.

## Development & Build System

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* Copyright (c) 2026 CleanroomMC contributors
*
* This file is licensed under the CleanroomMC License Version 1.0.
* See the applicable LICENSE file in this directory or a parent directory
* for the full licence terms.
*
* This is visible-source software and is not open-source software.
*/

@HideFromUserdev
package zone.rong.mixinbooter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public final class ModListConfig {
"configanytime",
"mixinbooter",
"fugue",
"scalar",
"kirino_ecs",
"kirino_engine",
"kirino_gl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,15 @@
public final class PatchModPresentChecker {

private static final String FUGUE_COREMOD_CLASS = "com.cleanroommc.fugue.common.FugueLoadingPlugin";
private static final String SCALAR_COREMOD_CLASS = "com.cleanroommc.scalar.ScalarLoadingPlugin";

private static boolean fuguePresent;
private static boolean scalarPresent;
private static boolean checkPerformed;

private PatchModPresentChecker() { }

public static void performCheck() {
if (ForgeEarlyConfig.DISABLE_PATCH_MOD_CHECK) {
fuguePresent = true;
scalarPresent = true;
return;
}

Expand All @@ -38,16 +35,8 @@ public static void performCheck() {
checkPerformed = true;

fuguePresent = Launch.classLoader.isClassExist(FUGUE_COREMOD_CLASS);
scalarPresent = Launch.classLoader.isClassExist(SCALAR_COREMOD_CLASS);

if (!fuguePresent || !scalarPresent) {
FMLLog.log.warn("These mods are missing:");
if (!fuguePresent) {
FMLLog.log.warn(" Fugue is missing");
}
if (!scalarPresent) {
FMLLog.log.warn(" Scalar is missing");
}
if (!fuguePresent) {
FMLLog.log.warn("Fugue is missing");
}
}

Expand All @@ -61,25 +50,17 @@ public static boolean isNotPresent() {
if (!checkPerformed) {
performCheck();
}
return !fuguePresent || !scalarPresent;
return !fuguePresent;
}

public static String getWarningMessage() {
if (!checkPerformed) {
performCheck();
}
if (fuguePresent && scalarPresent) {
if (fuguePresent) {
return "";
}
String missing;
if (!fuguePresent && !scalarPresent) {
missing = "Fugue and Scalar are not installed";
} else if (!fuguePresent) {
missing = "Fugue is not installed";
} else {
missing = "Scalar is not installed";
}
return "WARNING\n" + missing + "\n" + "Your pack may crash without these mods.\n" +
return "WARNING\nFugue is not installed\nYour pack may crash without it.\n" +
"To disable this warning, check forge_early.cfg";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
import com.cleanroommc.common.CleanroomEnvironment;
import com.cleanroommc.common.ConfigAnytimeContainer;
import com.cleanroommc.kirino.KirinoCommonCore;
import com.cleanroommc.language.scala.ScalaProvider;
import com.cleanroommc.language.scala.ScalaScanner;
import com.cleanroommc.language.scala.ScalaUsage;
import com.cleanroommc.language.scala.ScalarContainer;
import com.cleanroommc.util.CleanroomLog;
import top.outlands.foundation.boot.ActualClassLoader;
import zone.rong.mixinbooter.MixinBooterModContainer;
Expand Down Expand Up @@ -147,8 +151,11 @@ public final class CleanroomModDiscoverer extends ModDiscoverer {
private static final String FERMIUM_PLUGIN = "fermiumbooter.FermiumPlugin";
private static final String FILE_DIRECTOR = "net.jan.moddirector.core.ModDirector";
private static final String FILE_DIRECTOR_TWEAKER = "net.jan.moddirector.launchwrapper.ModDirectorTweaker";
private static final String SCALAR_PLUGIN = "com.cleanroommc.scalar.ScalarLoadingPlugin";

private final List<ModContainer> builtInMods = List.of(new MixinBooterModContainer(), new ConfigAnytimeContainer());
private final List<ModContainer> builtInMods = List.of(
new MixinBooterModContainer(), new ConfigAnytimeContainer(), new ScalarContainer()
);
private final List<String> builtInModIds = builtInMods.stream().map(ModContainer::getModId).toList();
private final SetMultimap<String, File> modIdToFiles = HashMultimap.create();
private final SetMultimap<File, String> fileToModIds = LinkedHashMultimap.create();
Expand Down Expand Up @@ -449,6 +456,7 @@ public void discoverCoreMods(File minecraftDirectory, LaunchClassLoader classLoa
if (fileDirector != null) {
discoverFileDirectorMods(minecraftDirectory, classLoader);
}
provideScala();

CleanroomLog.get().debug("Discovering coremods");
File containedDepsDir = new File(new File(Launch.minecraftHome, "mods"), ForgeVersion.mcVersion);
Expand Down Expand Up @@ -584,6 +592,20 @@ private void discoverFileDirectorMods(File gameDir, LaunchClassLoader classLoade
}
}

private void provideScala() {
ScalaProvider.provide(discoveredFiles.values(), mod -> {
File original = mod.scala().original();
File rewritten = normalize(mod.file());
discoveredFiles.remove(original);
discoveredFiles.put(rewritten, mod);
for (String modId : fileToModIds.removeAll(original)) {
fileToModIds.put(rewritten, modId);
modIdToFiles.remove(modId, original);
modIdToFiles.put(modId, rewritten);
}
});
}

private void discover(Map<File, Boolean> files) {
CleanroomLog.get().info("Discovering mods");
long startTime = System.nanoTime();
Expand All @@ -600,6 +622,14 @@ private void discover(Map<File, Boolean> files) {
// Merged in discovery order, so jars declaring a built-in mod id are dropped as they were when scanned one by one
mods:
for (DiscoveredMod mod : runScans(scans)) {
if (SCALAR_PLUGIN.equals(mod.coremod())) {
CleanroomLog.get()
.warn(
"{} is no longer needed as Cleanroom provides Scala, it will not be loaded",
mod.file().getName()
);
continue;
}
for (String modId : mod.modIds()) {
if (recordMod(modId, mod.file())) {
continue mods;
Expand Down Expand Up @@ -630,7 +660,7 @@ private DiscoveredMod scan(File absolute, boolean onClasspath, byte[][] descript
if (!isArchive(absolute)) {
return new DiscoveredMod(
absolute, null, List.of(), Map.of(), Map.of(), List.of(), ManifestAttributes.CLEANROOMMODTYPE, false,
false, false, null, null, onClasspath, Map.of(), Set.of(), List.of()
false, false, null, null, onClasspath, Map.of(), Set.of(), List.of(), ScalaUsage.NONE
);
}

Expand All @@ -649,6 +679,7 @@ private DiscoveredMod scan(File absolute, boolean onClasspath, byte[][] descript
boolean mixinTweakerForceMod = false;
boolean coreModContainsMod = false;
Map<String, String> accessTransformers = Map.of();
ScalaScanner scala = new ScalaScanner();

try (JarFile jarFile = new JarFile(absolute)) {
attributes = readManifestAttributes(absolute, jarFile);
Expand Down Expand Up @@ -681,7 +712,7 @@ private DiscoveredMod scan(File absolute, boolean onClasspath, byte[][] descript
}
scanModAnnotations(
jarFile, descriptors, modIds, modNames, modVersions, dependencies, configurationClasses,
fermiumConfigClasses
fermiumConfigClasses, scala
);
}
String atList = attributes == null ? null : attributes.getValue(ModAccessTransformer.FMLAT);
Expand All @@ -695,7 +726,7 @@ private DiscoveredMod scan(File absolute, boolean onClasspath, byte[][] descript
return new DiscoveredMod(
absolute, attributes, List.copyOf(modIds), modNames, modVersions, configurationClasses, modType,
hasMixinManifestAttributes, mixinTweakerForceMod, coreModContainsMod, coremod, tweaker, onClasspath,
accessTransformers, dependencies, fermiumConfigClasses
accessTransformers, dependencies, fermiumConfigClasses, scala.result()
);
}

Expand Down Expand Up @@ -1007,13 +1038,15 @@ private void parseMcmodInfo(

private void scanModAnnotations(
JarFile jar, byte[][] descriptors, Set<String> modIds, Map<String, String> names, Map<String, String> versions,
Set<String> dependencies, List<String> configurationClasses, List<String> fermiumConfigClasses) {
Set<String> dependencies, List<String> configurationClasses, List<String> fermiumConfigClasses,
ScalaScanner scala) {
byte[] buffer = CLASS_BUFFER.get();
var entries = jar.entries();
entryLoop:
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
String name = entry.getName();
scala.entry(name);
if (entry.isDirectory() || !name.endsWith(".class")) {
continue;
}
Expand All @@ -1033,6 +1066,7 @@ private void scanModAnnotations(
buffer = Arrays.copyOf(buffer, length << 1);
}
}
scala.scan(buffer, length);
if (!namesAnnotation(buffer, descriptors)) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

package com.cleanroommc.discovery;

import com.cleanroommc.language.scala.ScalaUsage;

import java.io.File;
import java.util.List;
import java.util.Map;
Expand All @@ -32,7 +34,8 @@ public record DiscoveredMod(
boolean onClasspath,
Map<String, String> accessTransformers,
Set<String> dependencies,
List<String> fermiumConfigClasses) {
List<String> fermiumConfigClasses,
ScalaUsage scala) {

public DiscoveredMod {
file = file.getAbsoluteFile();
Expand All @@ -45,6 +48,14 @@ public record DiscoveredMod(
fermiumConfigClasses = List.copyOf(fermiumConfigClasses);
}

public DiscoveredMod withRewrittenFile(File rewritten) {
return new DiscoveredMod(
rewritten, attributes, modIds, modNames, modVersions, mixinConfigurationClasses, modType,
hasMixinManifestAttributes, mixinTweakerForceMod, coreModContainsMod, coremod, tweaker, onClasspath,
accessTransformers, dependencies, fermiumConfigClasses, new ScalaUsage(scala.kind(), scala.config(), file)
);
}

public boolean isDirectoryBased() {
return file.isDirectory();
}
Expand Down
Loading
Loading