Skip to content

Commit b4ce6b8

Browse files
committed
Use module version of mixin with fallback to package impl version to work in cases where mixin is modular or not
Depends on FabricMC/Mixin#184
1 parent 37c142c commit b4ce6b8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

loader/src/main/java/net/neoforged/fml/loading/moddiscovery/ModFileParser.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.electronwill.nightconfig.core.file.FileConfig;
1111
import com.electronwill.nightconfig.toml.TomlFormat;
1212
import com.mojang.logging.LogUtils;
13+
import java.lang.module.ModuleDescriptor;
1314
import java.nio.file.Files;
1415
import java.nio.file.Path;
1516
import java.util.ArrayList;
@@ -82,7 +83,10 @@ public MixinConfig(String config, List<String> requiredMods) {
8283
private static final ArtifactVersion LOWEST_MIXIN_VERSION;
8384

8485
static {
85-
HIGHEST_MIXIN_VERSION = new DefaultArtifactVersion(FabricUtil.class.getPackage().getImplementationVersion());
86+
HIGHEST_MIXIN_VERSION = new DefaultArtifactVersion(Optional.ofNullable(FabricUtil.class.getModule().getDescriptor())
87+
.flatMap(ModuleDescriptor::version).map(ModuleDescriptor.Version::toString)
88+
.or(() -> Optional.ofNullable(FabricUtil.class.getPackage().getImplementationVersion()))
89+
.orElseThrow(() -> new IllegalStateException("Cannot determine version of currently running mixin")));
8690
int defaultMixinVersion = DeferredMixinConfigRegistration.DEFAULT_BEHAVIOUR_VERSION;
8791
int patch = defaultMixinVersion % 1000;
8892
defaultMixinVersion /= 1000;

0 commit comments

Comments
 (0)