FabricMC / fabric-loom

Gradle build system plugin used to automate the setup of a minecraft mod development environment.
MIT License
223 stars 194 forks source link

Sources Jar's `version.json` doesn't contain `release_target` #1081

Closed IsSkyfalls closed 3 months ago

IsSkyfalls commented 3 months ago

This is reproducible with a newly generated mod on 1.20.2 with https://fabricmc.net/develop/template/. I haven't tested other versions yet. Not possible After genSources the version.json in both clientOnly and common jars looks like this:

// ./testmod/.gradle/loom-cache/minecraftMaven/net/minecraft/minecraft-clientOnly-1f338b2c9f/1.20.2-net.fabricmc.yarn.1_20_2.1.20.2+build.4-v2/
{
    "id": "1.20.2",
    "name": "1.20.2",
    "world_version": 3578,
    "series_id": "main",
    "protocol_version": 764,
    "pack_version": {
        "resource": 18,
        "data": 18
    },
    "build_time": "2023-09-20T09:00:26+00:00",
    "java_component": "java-runtime-gamma",
    "java_version": 17,
    "stable": true,
    "use_editor": false
}

Which is missing the release_target. I don't know whether it's been there before or not, since I had to nuke all my gradle caches in order to pin point the issue. This causes McVersionLookup.fromVersionJson in the fabric loader to fail, and it eventually falls back to using the file name as version string, which is minecraft-clientOnly-1f338b2c9f-1.20.2-net.fabricmc.yarn.1_20_2.1.20.2+build.4-v2. Then it falls at the parser on runtime:

[05:51:13] [main/INFO]: Loading Minecraft minecraft-clientOnly-1f338b2c9f-1.20.2-net.fabricmc.yarn.1_20_2.1.20.2+build.4-v2 with Fabric Loader 0.14.1
[05:51:13] [main/ERROR]: Uncaught exception in thread "main"
java.lang.RuntimeException: net.fabricmc.loader.api.VersionParsingException: Could not parse version number component 'minecraft'!
    at net.fabricmc.loader.impl.metadata.BuiltinModMetadata$Builder.<init>(BuiltinModMetadata.java:177) ~[fabric-loader-0.14.1.jar:?]
    at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.getBuiltinMods(MinecraftGameProvider.java:114) ~[fabric-loader-0.14.1.jar:?]
    at net.fabricmc.loader.impl.discovery.ModDiscoverer.discoverMods(ModDiscoverer.java:118) ~[fabric-loader-0.14.1.jar:?]
    at net.fabricmc.loader.impl.FabricLoaderImpl.setup(FabricLoaderImpl.java:209) ~[fabric-loader-0.14.1.jar:?]
    at net.fabricmc.loader.impl.FabricLoaderImpl.load(FabricLoaderImpl.java:186) ~[fabric-loader-0.14.1.jar:?]
    at net.fabricmc.loader.impl.launch.knot.Knot.init(Knot.java:140) ~[fabric-loader-0.14.1.jar:?]
    at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:69) ~[fabric-loader-0.14.1.jar:?]
    at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23) ~[fabric-loader-0.14.1.jar:?]
    at net.fabricmc.devlaunchinjector.Main.main(Main.java:86) ~[?:?]
Caused by: net.fabricmc.loader.api.VersionParsingException: Could not parse version number component 'minecraft'!
    at net.fabricmc.loader.impl.util.version.SemanticVersionImpl.<init>(SemanticVersionImpl.java:113) ~[fabric-loader-0.14.1.jar:?]
    at net.fabricmc.loader.impl.util.version.VersionParser.parseSemantic(VersionParser.java:45) ~[fabric-loader-0.14.1.jar:?]
    at net.fabricmc.loader.impl.metadata.BuiltinModMetadata$Builder.<init>(BuiltinModMetadata.java:175) ~[fabric-loader-0.14.1.jar:?]
    ... 8 more
Caused by: java.lang.NumberFormatException: For input string: "minecraft"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:67) ~[?:?]
    at java.lang.Integer.parseInt(Integer.java:662) ~[?:?]
    at java.lang.Integer.parseInt(Integer.java:778) ~[?:?]
    at net.fabricmc.loader.impl.util.version.SemanticVersionImpl.<init>(SemanticVersionImpl.java:107) ~[fabric-loader-0.14.1.jar:?]
    at net.fabricmc.loader.impl.util.version.VersionParser.parseSemantic(VersionParser.java:45) ~[fabric-loader-0.14.1.jar:?]
    at net.fabricmc.loader.impl.metadata.BuiltinModMetadata$Builder.<init>(BuiltinModMetadata.java:175) ~[fabric-loader-0.14.1.jar:?]
    ... 8 more

I don't think I did anything before every single mod stopped being able to pass this step on my machine. Maybe it's a dependency issue? I can investigate more if anyone can point me to where this version.json is generated, thanks.

Juuxel commented 3 months ago

The version.json file looks exactly like that in a vanilla Minecraft 1.20.2 client jar, so that part is really not a Loom issue. I think release_target is just a field that's not there on all game versions.

Loader is also able to read the version from the other fields just fine: https://github.com/FabricMC/fabric-loader/blob/d69cb72d26497e3f387cf46f9b24340b402a4644/minecraft/src/main/java/net/fabricmc/loader/impl/game/minecraft/McVersionLookup.java#L222-L227

IsSkyfalls commented 3 months ago

Thank you for the quick response. It's indeed problem on my end. After comparing the code I realized that I was on an ancient version of loader. A few days back I thought that I can just go back to 0.14.1 since I needed to support 0.14.2x. The old dependencies probably got cached for a few days and didn't update until this afternoon, then it all broke. I also somehow pasted the old gradle.properties into the new repo when testing things, and thought I was going crazy(which I probably am). Sorry for my confusion.