Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically detect the MC version for an instance #117

Open
Senth opened this issue Aug 14, 2021 · 3 comments
Open

Automatically detect the MC version for an instance #117

Senth opened this issue Aug 14, 2021 · 3 comments
Labels
enhancement New feature or request
Milestone

Comments

@Senth
Copy link
Owner

Senth commented Aug 14, 2021

By looking at the minecraft.jar or server.jar we should be able to determine the MC version that is in use, hopefully... That way, the user doesn't have to explicitly set the MC version for each instance.

@Senth Senth added enhancement New feature or request core labels Aug 14, 2021
@Senth Senth added this to the 2.0.0 milestone Aug 14, 2021
@Senth Senth added this to To Do in v2.x - The GUI Update Aug 14, 2021
@theofficialgman
Copy link

theofficialgman commented Sep 4, 2021

not sure how you plan on doing this but just wanted to give some input.
It seems like minecraft launchers handle the naming of the minecraft.jar differently.
the official launcher names it X.XX.X.jar, multimc uses minecraft-X.XX.X-client.jar and I bet the other launchers also do it differently. on top of that these files are located in different places as well

packed inside both these .jar files is a version.json which should have enough info

{
    "id": "1.17.1",
    "name": "1.17.1",
    "release_target": "1.17.1",
    "world_version": 2730,
    "protocol_version": 756,
    "pack_version": {
        "resource": 7,
        "data": 7
    },
    "build_time": "2021-07-06T11:59:45+00:00",
    "java_component": "java-runtime-alpha",
    "java_version": 16,
    "stable": true
}

@Senth
Copy link
Owner Author

Senth commented Sep 5, 2021

Thanks @theofficialgman 🙂

I had a hunch there might be some information inside the .jar, but I wasn't sure. So thanks for confirming 😃

I have to look into snapshots and server versions as well to see which one of id, name, or release_target should be used. It's also nice that there seems to be a stable flag, not sure if there will be any use of this, but maybe in the future.

@Senth Senth removed the core label Mar 19, 2022
@theofficialgman
Copy link

I should also note that multimc dumps all the minecraft-X.XX.X-client.jar files into its own folder structure libraries/com/mojang/minecraft/22w18a/minecraft-22w18a-client.jar separate from the .minecraft folder. so you can't really read from that since you don't know where it is.

a launcher specific way for multimc is just reading the mmc-pack.json where you can get the minecraft version and fabric/forge version if they are installed.

mc_version=$(jq -M -r '.components[] | "\(.uid)/\(.version)"' mmc-pack.json | sed -n -e 's/^.*net.minecraft\///p')
fabric_version=$(jq -M -r '.components[] | "\(.uid)/\(.version)"' mmc-pack.json | sed -n -e 's/^.*net.fabricmc.fabric-loader\///p')
forge_version=$(jq -M -r '.components[] | "\(.uid)/\(.version)"' mmc-pack.json | sed -n -e 's/^.*net.minecraftforge\///p')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Development

No branches or pull requests

2 participants