mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2026-09-14 07:09:54 -04:00
fix(MioLibPatcher): Only enable patches if needed
This commit is contained in:
1 parent
3ecc0b5721
commit
7d851fba2f
2 files changed
+22
-5
No files matched your search
@@ -152,6 +152,7 @@ public final class Tools {
|
||||
public static int iLwjglVersion = 0;
|
||||
public static String sLwjglVersion = null;
|
||||
public static String lwjglNativesDir = null;
|
||||
public static String[] sAsmVersion = null;
|
||||
|
||||
|
||||
private static File getPojavStorageRoot(Context ctx) {
|
||||
@@ -1168,11 +1169,12 @@ public final class Tools {
|
||||
public static void preProcessLibraries(DependentLibrary[] libraries) {
|
||||
for (int i = 0; i < libraries.length; i++) {
|
||||
DependentLibrary libItem = libraries[i];
|
||||
String[] version = libItem.name.split(":")[2].split("\\.");
|
||||
String libraryVersion = libItem.name.split(":")[2];
|
||||
String[] libraryVersionArray = libraryVersion.split("\\.");
|
||||
if (libItem.name.startsWith("net.java.dev.jna:jna:")) {
|
||||
// Special handling for LabyMod 1.8.9, Forge 1.12.2(?) and oshi
|
||||
// we have libjnidispatch 5.13.0 in jniLibs directory
|
||||
if (Integer.parseInt(version[0]) >= 5 && Integer.parseInt(version[1]) >= 13) continue;
|
||||
if (Integer.parseInt(libraryVersionArray[0]) >= 5 && Integer.parseInt(libraryVersionArray[1]) >= 13) continue;
|
||||
Log.d(APP_NAME, "Library " + libItem.name + " has been changed to version 5.13.0");
|
||||
createLibraryInfo(libItem);
|
||||
libItem.name = "net.java.dev.jna:jna:5.13.0";
|
||||
@@ -1183,7 +1185,7 @@ public final class Tools {
|
||||
//if (Integer.parseInt(version[0]) >= 6 && Integer.parseInt(version[1]) >= 3) return;
|
||||
// FIXME: ensure compatibility
|
||||
|
||||
if (Integer.parseInt(version[0]) != 6 || Integer.parseInt(version[1]) != 2) continue;
|
||||
if (Integer.parseInt(libraryVersionArray[0]) != 6 || Integer.parseInt(libraryVersionArray[1]) != 2) continue;
|
||||
Log.d(APP_NAME, "Library " + libItem.name + " has been changed to version 6.3.0");
|
||||
createLibraryInfo(libItem);
|
||||
libItem.name = "com.github.oshi:oshi-core:6.3.0";
|
||||
@@ -1194,7 +1196,7 @@ public final class Tools {
|
||||
// Early versions of the ASM library get repalced with 5.0.4 because Pojav's LWJGL is compiled for
|
||||
// Java 8, which is not supported by old ASM versions. Mod loaders like Forge, which depend on this
|
||||
// library, often include lwjgl in their class transformations, which causes errors with old ASM versions.
|
||||
if(Integer.parseInt(version[0]) >= 5) continue;
|
||||
if(Integer.parseInt(libraryVersionArray[0]) >= 5) continue;
|
||||
Log.d(APP_NAME, "Library " + libItem.name + " has been changed to version 5.0.4");
|
||||
createLibraryInfo(libItem);
|
||||
libItem.name = "org.ow2.asm:asm-all:5.0.4";
|
||||
@@ -1203,6 +1205,10 @@ public final class Tools {
|
||||
libItem.downloads.artifact.sha1 = "e6244859997b3d4237a552669279780876228909";
|
||||
libItem.downloads.artifact.url = "https://repo1.maven.org/maven2/org/ow2/asm/asm-all/5.0.4/asm-all-5.0.4.jar";
|
||||
}
|
||||
if (sAsmVersion == null && libItem.name.startsWith("org.ow2.asm:asm")) {
|
||||
// TODO: Extract logic for iLwjglVersion and copy it here
|
||||
sAsmVersion = libraryVersionArray;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -386,7 +386,18 @@ public class JREUtils {
|
||||
userArgs.add("-XX:ActiveProcessorCount=" + java.lang.Runtime.getRuntime().availableProcessors());
|
||||
// Adds/changes methods for compatibility
|
||||
userArgs.add("-javaagent:"+new File(Tools.DIR_DATA,"MioLibPatcher/MioLibPatcher.jar").getAbsolutePath());
|
||||
userArgs.add("-Dmiolibpatcher.alc10=true");
|
||||
// Only needed for lwjglx
|
||||
if (Tools.iLwjglVersion <= 299) userArgs.add("-Dmiolibpatcher.alc10=true");
|
||||
|
||||
if (Tools.sAsmVersion != null) {
|
||||
// We override it with 5.0.4 and no forge version ever used 5.0.4, only 5.0.3
|
||||
// This exists for AE1. If any other buggy mods come up, let's enable it for them too.
|
||||
if (Integer.parseInt(Tools.sAsmVersion[0]) == 5 &&
|
||||
Integer.parseInt(Tools.sAsmVersion[1]) == 0 &&
|
||||
Integer.parseInt(Tools.sAsmVersion[2]) == 4) {
|
||||
userArgs.add("-Dmiolibpatcher.asmBackport=true");
|
||||
}
|
||||
}
|
||||
|
||||
userArgs.addAll(JVMArgs);
|
||||
activity.runOnUiThread(() -> Toast.makeText(activity, activity.getString(R.string.autoram_info_msg,LauncherPreferences.PREF_RAM_ALLOCATION), Toast.LENGTH_SHORT).show());
|
||||
|
||||
Reference in new issue
Block a user