Skip to content

Commit

Permalink
Pleasing that Intel HD Graphics even more
Browse files Browse the repository at this point in the history
i went too far, too good
  • Loading branch information
Moresteck committed Feb 25, 2024
1 parent 106545f commit c158a78
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/betacraft/launcher/BC.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class BC {
public static PropertyFile SETTINGS;

// TODO better check this before release
public static boolean prerelease = false;
public static boolean prerelease = true;
public static boolean nightly = false;

public static boolean portable = false;
Expand Down
42 changes: 33 additions & 9 deletions src/main/java/org/betacraft/launcher/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

/** Main class */
public class Launcher {
public static String VERSION = "1.09_16"; // TODO Always update this
public static String VERSION = "1.09_17-rc1"; // TODO Always update this

public static Instance currentInstance;
public static boolean forceUpdate = false;
Expand Down Expand Up @@ -483,26 +483,50 @@ public static boolean initStartup() {

String report = (new String(Files.readAllBytes(reportFile.toPath()), "UTF-8")).toLowerCase();

reportFile.delete();

report = report.substring(report.indexOf("card name:") + "card name:".length());
report = report.substring(0, report.indexOf("\n"));

if (!report.contains("intel(r) hd graphics family"))
return true; // can return true here as it's the last check

String javaver = Util.getFullJavaVersion(Launcher.currentInstance.javaPath);
if (report.contains("intel(r) hd graphics family")) {
if (javaver == null || !javaver.equals("1.8.0_51")) {
JOptionPane.showMessageDialog(Window.mainWindow,
String.format(Lang.JAVA_INTEL_GRAPHICS, javaver) + "\n" + Lang.JAVA_INTEL_GRAPHICS_WIKI,
"", JOptionPane.INFORMATION_MESSAGE);
return false;
if (javaver == null || !javaver.equals("1.8.0_51")) {

File u51loc = Util.getJava8u51Location();
if (u51loc != null) {
Launcher.currentInstance.javaPath = u51loc.getAbsolutePath();
Launcher.currentInstance.isJavaPathNew = false;
Launcher.currentInstance.saveInstance();
} else {
if (!Util.downloadJava8u51()) {
JOptionPane.showMessageDialog(Window.mainWindow,
String.format(Lang.JAVA_INTEL_GRAPHICS, javaver) + "\n" + Lang.JAVA_INTEL_GRAPHICS_WIKI,
"", JOptionPane.INFORMATION_MESSAGE);
return false;
}

File u51zip = new File(BC.get(), "jre-8u51-windows-x64.zip");
File u51dir = new File(BC.get(), "java-8u51/");
u51dir.mkdir();

Thread t = Util.unzip(u51zip, u51dir, true);
totalThreads.add(t);
while (t.isAlive()); // wait for it to unzip

File u51javaexe = new File(u51dir, "bin/java.exe");
Launcher.currentInstance.isJavaPathNew = false;
Launcher.currentInstance.javaPath = u51javaexe.getAbsolutePath();
Launcher.currentInstance.saveInstance();
}
} else {
Launcher.currentInstance.isJavaPathNew = false;
Launcher.currentInstance.saveInstance();
}
} catch (Throwable t) {
t.printStackTrace();
}

reportFile.delete();
}
return true;
}
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/org/betacraft/launcher/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@
import uk.betacraft.auth.Authenticator;
import uk.betacraft.auth.Credentials;
import uk.betacraft.auth.Credentials.AccountType;
import uk.betacraft.auth.CustomRequest;
import uk.betacraft.auth.CustomResponse;
import uk.betacraft.auth.DownloadRequest;
import uk.betacraft.auth.DownloadResponse;
import uk.betacraft.auth.MicrosoftAuth;
import uk.betacraft.auth.NoAuth;
import uk.betacraft.auth.RequestUtil;
import uk.betacraft.json.lib.MouseFixMacOSJson;

public class Util {
Expand Down Expand Up @@ -496,6 +499,43 @@ public static boolean installMacOSFix(MouseFixMacOSJson json, boolean force) {
return false;
}
}

public static boolean downloadJava8u51() {
String mirror1 = "https://archive.org/download/Java_8_update_51/jre-8u51-windows-x64.zip";
String dest = new File(BC.get(), "jre-8u51-windows-x64.zip").getAbsolutePath();
DownloadResponse res = new DownloadRequest(mirror1, dest, null, false).perform();
if (res.result == DownloadResult.FAILED_WITHOUT_BACKUP) {
// get alternative mirror
CustomResponse cres = new CustomRequest("http://files.betacraft.uk/launcher/assets/java-8u51-url.txt").perform();
if (cres.response == null) {
return false;
}

res = new DownloadRequest(cres.response, dest, null, false).perform();
if (res.result == DownloadResult.FAILED_WITHOUT_BACKUP) {
return false;
}
}

return true;
}

public static File getJava8u51Location() {
// paths where java 8u51 is stored by the official mc launcher
String[] expectedPaths = new String[] {
"C:\\Program Files\\Java\\jre1.8.0_51\\bin\\java.exe",
"C:\\Program Files (x86)\\Minecraft Launcher\\runtime\\jre-legacy\\windows-x64\\jre-legacy\\bin\\java.exe",
System.getenv("USERPROFILE") + "\\AppData\\Local\\Packages\\Microsoft.4297127D64EC6_8wekyb3d8bbwe\\LocalCache\\Local\\runtime\\jre-legacy\\windows-x64\\jre-legacy\\bin\\java.exe"
};

for (String expectedPath : expectedPaths) {
File expectedFile = new File(expectedPath);
if (expectedFile.exists() && expectedFile.isFile()) {
return expectedFile;
}
}
return null;
}

public static String getExpectedJavaLocation() {
String expectedPath;
Expand Down

0 comments on commit c158a78

Please sign in to comment.