Posted September 24, 20169 yr Hello, I am using analytics for a mod of mine, and I need to get launched Minecraft version (e.g. "1.8", "1.10.2"). When using Minecraft.getMinecraft().getVersion() , it returns (in the case of Forge) for example 1.10.2-forge1.10.2-[forge_version] . This is useful, as I can extract the version number out of this using Regex or equivalent. However, there are modloaders, such as MultiMC5. When playing Minecraft via MultiMC5, it sets the Minecraft version to "MultiMC5", and you can't extract data out of that. There is another way, and that is using either MinecraftForge.MC_VERSION or Loader.MC_VERSION (they are the same thing). But here is the problem, this variable is not present at the FMLInitializationEvent That variable is present, but incorrect. Read "EDIT 2", and I need this variable to be set/accessible when it is initializing. Due to other reasons, (EDIT 2) the detection has to be done before messages can be send to the player. Is there another way to get the launched Minecraft version? Or is there another event that happens between the initialization and the player joining a server/world? I tried to use FMLPostInitializationEvent, but that crashed the entire client for some reason. Read "EDIT 2". Thanks in advance, Semx EDIT This also happens when I am in-game: EDIT 2 Might as well add the (most likely) reason why this happens: I am trying to make a universal mod, so one that supports 1.8 to 1.10.2. Some classes and functions change with the Minecraft Forge version, but I got that covered using reflection. When it fails to detect what version it is, it breaks down. EDIT 3 I am positive that there is a way to get the Minecraft version. Even the debug menu has it right: Keep in mind that this is the same version/instance as the screenshot above.
September 24, 20169 yr The ForgeVersion.mcVersion field contains the Minecraft version that the current version of Forge was built for. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
September 24, 20169 yr Author Be careful however: as this is a true constant the compiler will inline this field into your code, so your code will continue to run with the value that was there when you built your mod. If you e.g. compile your mod with 1.9.4 and then run it on 1.10.2 (yes, that works most of the time) your mod will still see 1.9.4 as the value for that field. You have to resort to reading the value via reflection (or a classfile written by something other than javac) if you want the true runtime value. In what class can I find the 'true runtime value'? I'm not sure where to look, and I can use reflection. EDIT: I found the GuiOverlayDebug.class in net.minecraft.client.gui , and it looks like such: This means that in the Minecraft version, the version is hardcoded. This should not be a problem, as I can use Reflection to call this protected call() method. Is this the right way to do it, or might there be an easier way? Thanks in advance. EDIT 2: I don't have any experience with creating core-mods, so how can I find out what the call() method gets mapped to? Any tutorial?
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.