Skip to content

Commit d0f3422

Browse files
authored
stage2/ml9: Support NeoForge merging ModLauncher into FancyModLoader
GitHub: #27
1 parent ee20a37 commit d0f3422

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

stage2/modlauncher9/src/main/java/gg/essential/loader/stage2/EssentialTransformationService.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,16 @@
2424

2525
public class EssentialTransformationService implements ITransformationService {
2626
private static final Logger LOGGER = LogManager.getLogger(EssentialTransformationService.class);
27-
private static final Map<String, String> COMPATIBILITY_IMPLEMENTATIONS = Map.of(
27+
private static final Map<String, String> ML_COMPATIBILITY_IMPLEMENTATIONS = Map.of(
2828
"11.", "ML11CompatibilityLayer",
2929
"10.", "ML10CompatibilityLayer",
3030
"9.", "ML9CompatibilityLayer"
3131
);
32+
// NeoForge as of 1.21.7 has merged ModLauncher into FancyModLoader and reports the version of that instead of
33+
// ModLauncher.
34+
private static final Map<String, String> FMLML_COMPATIBILITY_IMPLEMENTATIONS = Map.of(
35+
"9.", "ML11CompatibilityLayer"
36+
);
3237
private static CompatibilityLayer compatibilityLayer;
3338

3439
private final Path gameDir;
@@ -82,7 +87,13 @@ public void initialize(IEnvironment environment) {
8287
@SuppressWarnings("unchecked")
8388
private CompatibilityLayer findCompatibilityLayerImpl(String mlVersion) {
8489
String implementation = null;
85-
for (Map.Entry<String, String> entry : COMPATIBILITY_IMPLEMENTATIONS.entrySet()) {
90+
Map<String, String> impls;
91+
if ("fml_loader".equals(ITransformationService.class.getModule().getName())) {
92+
impls = FMLML_COMPATIBILITY_IMPLEMENTATIONS;
93+
} else {
94+
impls = ML_COMPATIBILITY_IMPLEMENTATIONS;
95+
}
96+
for (Map.Entry<String, String> entry : impls.entrySet()) {
8697
if (mlVersion.startsWith(entry.getKey())) {
8798
implementation = entry.getValue();
8899
break;

0 commit comments

Comments
 (0)