Merge pull request #57 from AngelAuraMC/fix/HolyRendererString

fix(Renderer/Default): Check asset ID instead of mcver
This commit is contained in:
alexytomi
2025-07-31 10:02:27 +08:00
committed by GitHub
3 changed files with 48 additions and 6 deletions

View File

@@ -73,6 +73,8 @@ import org.lwjgl.glfw.CallbackBridge;
import java.io.File;
import java.io.IOException;
import java.util.Objects;
public class MainActivity extends BaseActivity implements ControlButtonMenuListener, EditorExitable, ServiceConnection {
public static volatile ClipboardManager GLOBAL_CLIPBOARD;
public static final String INTENT_MINECRAFT_VERSION = "intent_version";
@@ -356,11 +358,50 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
}
private void runCraft(String versionId, JMinecraftVersionList.Version version) throws Throwable {
if(Tools.LOCAL_RENDERER == null) {
Integer iSelectedMcVer = Tools.mcVersiontoInt(Tools.getSelectedVanillaMcVer());
if (iSelectedMcVer >= 1021005) {
Tools.LOCAL_RENDERER = "opengles_mobileglues";
} else Tools.LOCAL_RENDERER = "opengles2";
// Autoselect renderer
if (Tools.LOCAL_RENDERER == null) {
String assetVersion;
if (version.inheritsFrom != null) { // We are almost definitely modded if this runs
File vanillaJsonFile = new File(Tools.DIR_HOME_VERSION + "/" + version.inheritsFrom + "/" + version.inheritsFrom + ".json");
JMinecraftVersionList.Version vanillaJson;
try { // Get the vanilla json from modded instance
vanillaJson = Tools.GLOBAL_GSON.fromJson(Tools.read(vanillaJsonFile.getAbsolutePath()), JMinecraftVersionList.Version.class);
} catch (IOException ignored) { // Should never happen, we check for this in MinecraftDownloader().start()
throw new RuntimeException(getString(R.string.error_vanilla_json_corrupt));
}
// Something went wrong if this is somehow not the case anymore
if (!Objects.equals(vanillaJson.assets, vanillaJson.assetIndex.id))
Tools.showErrorRemote(new RuntimeException(getString(R.string.error_vanilla_json_corrupt)));
assetVersion = vanillaJson.assets;
} else {
// Else assume we are vanilla
if (!Objects.equals(version.assets, version.assetIndex.id))
Tools.showErrorRemote(new RuntimeException(getString(R.string.error_vanilla_json_corrupt)));
assetVersion = version.assets;
}
// 25w09a is when HolyGL4ES starts showing a black screen upon world load.
// There is no way to consistently check for that without breaking mod loaders
// for old versions like legacy fabric so we start from 25w07a instead
// 25w07a assets and assetIndex.id is set to 23, 25w08a and 25w09a is 24.
// 1.19.3 snapshots and all future versions restarted assets and assetsIndex.id
// to 1 and started counting up from there
// Previous versions had "1.19" and "1.18" and such, with April Fools versions
// being even more inconsistent like "3D Shareware v1.34" for the 2019 April Fools
// or 1.RV-Pre1 for 2016, thankfully now they don't seem to do that anymore and just
// use the incrementing system they now have
// I could probably read the manifest itself then check which position the `id` field is
// and count from there since its ordered latest to oldest but that uses way more code
// for basically 3 peoples benefit
try {
int assetID = Integer.parseInt(assetVersion);
// Check if below 25w08a
Tools.LOCAL_RENDERER = (assetID <= 23) ? "opengles2" : "opengles_mobileglues";
// Then assume 1.19.2 and below
} catch (NumberFormatException e) { Tools.LOCAL_RENDERER = "opengles2"; }
}
if(!Tools.checkRendererCompatible(this, Tools.LOCAL_RENDERER)) {
Tools.RenderersList renderersList = Tools.getCompatibleRenderers(this);

View File

@@ -926,7 +926,7 @@ public final class Tools {
insertSafety(inheritsVer, customVer,
"assetIndex", "assets", "id",
"mainClass", "minecraftArguments",
"releaseTime", "time", "type"
"releaseTime", "time", "type", "inheritsFrom"
);
// Go through the libraries, remove the ones overridden by the custom version

View File

@@ -469,4 +469,5 @@
<string name="preference_force_enable_touchcontroller_description">Force enable TouchController integration, even if mod file is not found.</string>
<string name="preference_touchcontroller_vibrate_length_title">TouchController vibrate length</string>
<string name="preference_touchcontroller_vibrate_length_description">Set the length of the vibration when using TouchController.</string>
<string name="error_vanilla_json_corrupt">Vanilla json seems to be corrupt. Please send a bug report on github or discord.</string>
</resources>