Use the version ID from extra to run the game

Fixes the issue where forge 1.17+ would not get some of its libraries loaded
This commit is contained in:
artdeell 2022-11-22 16:59:29 +03:00
parent f5a96bdba5
commit ef36c96edc
2 changed files with 9 additions and 11 deletions

View file

@ -71,7 +71,7 @@ public class MainActivity extends BaseActivity {
public ArrayAdapter<String> ingameControlsEditorArrayAdapter;
public AdapterView.OnItemClickListener ingameControlsEditorListener;
protected volatile JMinecraftVersionList.Version mVersionInfo;
protected volatile String mVersionId;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -147,8 +147,8 @@ public class MainActivity extends BaseActivity {
String version = getIntent().getStringExtra(INTENT_MINECRAFT_VERSION);
version = version == null ? minecraftProfile.lastVersionId : version;
mVersionInfo = Tools.getVersionInfo(version);
isInputStackCall = mVersionInfo.arguments != null;
mVersionId = version;
isInputStackCall = Tools.getVersionInfo(mVersionId).arguments != null;
Tools.getDisplayMetrics(this);
windowWidth = Tools.getDisplayFriendlyRes(currentDisplayMetrics.widthPixels, scaleFactor);
@ -326,15 +326,13 @@ public class MainActivity extends BaseActivity {
checkJavaArgsIsLaunchable(JREUtils.jreReleaseList.get("JAVA_VERSION"));
// appendlnToLog("Info: Custom Java arguments: \"" + LauncherPreferences.PREF_CUSTOM_JAVA_ARGS + "\"");
Logger.getInstance().appendToLog("Info: Selected Minecraft version: " + mVersionInfo.id +
((mVersionInfo.inheritsFrom == null || mVersionInfo.inheritsFrom.equals(mVersionInfo.id)) ?
"" : " (" + mVersionInfo.inheritsFrom + ")"));
Logger.getInstance().appendToLog("Info: Selected Minecraft version: " + mVersionId);
JREUtils.redirectAndPrintJRELog();
LauncherProfiles.update();
Tools.launchMinecraft(this, mProfile, minecraftProfile, mVersionInfo);
Tools.launchMinecraft(this, mProfile, minecraftProfile, mVersionId);
}
private void checkJavaArgsIsLaunchable(String jreVersion) throws Throwable {

View file

@ -111,7 +111,7 @@ public final class Tools {
public static void launchMinecraft(final Activity activity, MinecraftAccount minecraftAccount,
MinecraftProfile minecraftProfile, JMinecraftVersionList.Version versionInfo) throws Throwable {
MinecraftProfile minecraftProfile, String versionId) throws Throwable {
ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
((ActivityManager)activity.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryInfo(mi);
if(LauncherPreferences.PREF_RAM_ALLOCATION > (mi.availMem/1048576L)) {
@ -127,7 +127,7 @@ public final class Tools {
memoryErrorLock.wait();
}
}
JMinecraftVersionList.Version versionInfo = Tools.getVersionInfo(versionId);
LauncherProfiles.update();
String gamedirPath = Tools.getGameDirPath(minecraftProfile);
@ -142,7 +142,7 @@ public final class Tools {
OldVersionsUtils.selectOpenGlVersion(versionInfo);
String launchClassPath = generateLaunchClassPath(versionInfo, versionInfo.id);
String launchClassPath = generateLaunchClassPath(versionInfo, versionId);
List<String> javaArgList = new ArrayList<String>();
@ -168,7 +168,7 @@ public final class Tools {
}
javaArgList.add("-Dlog4j.configurationFile=" + configFile);
}
javaArgList.addAll(Arrays.asList(getMinecraftJVMArgs(versionInfo.id, gamedirPath)));
javaArgList.addAll(Arrays.asList(getMinecraftJVMArgs(versionId, gamedirPath)));
javaArgList.add("-cp");
javaArgList.add(getLWJGL3ClassPath() + ":" + launchClassPath);