Skip to content

Conversation

@LexManos
Copy link
Member

@LexManos LexManos commented Jan 10, 2026

Quick pass to split ASMAPI into its own jar for use in Forge when not using JavaScript coremods.
There are 3 methods that call into the JavaScript coremoding manager, loadFile, loadData, and log.
These methods are expected to throw exceptions if invoked from a non-JS transformer. So it should be fine.

For old versions that ship the JS engine, they will now need to ship the ASMAPI artifact as well.

Comment on lines -55 to +56
rootProject.name = 'CoreMods'
rootProject.name = 'coremods'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change breaks importing the project on some versions of IntelliJ due to the cloned folder name not exactly matching the root project name, please change it back to how it was.

Comment on lines +122 to +127
private static String map(String name, INameMappingService.Domain domain) {
if (Launcher.INSTANCE == null || Launcher.INSTANCE.environment() == null)
return name;
var mapper = Launcher.INSTANCE.environment().findNameMapping("srg").orElse(null);
return mapper == null ? name : mapper.apply(domain, name);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good candidate for caching either in a static field or a lazy init class static final:

Suggested change
private static String map(String name, INameMappingService.Domain domain) {
if (Launcher.INSTANCE == null || Launcher.INSTANCE.environment() == null)
return name;
var mapper = Launcher.INSTANCE.environment().findNameMapping("srg").orElse(null);
return mapper == null ? name : mapper.apply(domain, name);
}
private static String map(String name, INameMappingService.Domain domain) {
final class LazyInit {
static final BiFunction<INameMappingService.Domain, String, String> MAPPER;
static {
BiFunction<INameMappingService.Domain, String, String> mapper = null;
if (Launcher.INSTANCE != null && Launcher.INSTANCE.environment() != null) {
mapper = Launcher.INSTANCE.environment().findNameMapping("srg").orElse(null);
}
MAPPER = mapper;
}
}
return LazyInit.MAPPER == null ? name : LazyInit.MAPPER.apply(domain, name);
}

newLine = false
}

dependencies {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the coremods-api should be added here as an api to avoid accidental breaking changes from forgetting to manually add it when updating?

org.gradle.caching=true
org.gradle.parallel=true
org.gradle.configuration-cache=true
org.gradle.configuration-cache=false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this was disabled, but if it's to fix IDE import issues, you can add org.gradle.configuration-cache.problems=warn instead like in MinecraftMavenizer and Renamer.

*/
private static final boolean DO_NOT_FIX_INSNBEFORE = shouldntFixInsnBefore();

private static final boolean shouldntFixInsnBefore() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final on a static method prevents subclasses from having a static method with the same name at compile-time only. Unlike virtual methods, it has no effect on runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants