Add a java version detection and nag system for users on Java 7 or below.

Added detection of mods that rely on Java 8 and a graceful error screen.
The nag screen will be shown once a day. It can be disabled by editing the forge.cfg.
However it is HIGHLY recomended that user update to Java 8.
This commit is contained in:
LexManos committed 2016-05-03 18:26:52 -07:00
1 parent 4d27393c91
commit d8249b7886
15 files changed
+416 -18

No files matched your search

@@ -8,6 +8,7 @@ import static org.lwjgl.opengl.GL20.*;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.util.Collections;
import java.util.Map;
import javax.vecmath.Matrix3f;
@@ -89,8 +90,12 @@ import net.minecraftforge.common.model.IModelPart;
import net.minecraftforge.common.model.ITransformation;
import net.minecraftforge.common.model.TRSRTransformation;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.client.GuiJava8Error;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.Java8VersionException;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModContainer;
import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.BufferUtils;
@@ -266,7 +271,8 @@ public class ForgeHooksClient
//RenderingRegistry.registerBlockHandler(RenderBlockFluid.instance);
}
public static void renderMainMenu(GuiMainMenu gui, FontRenderer font, int width, int height)
private static int updatescrollcounter = 0;
public static String renderMainMenu(GuiMainMenu gui, FontRenderer font, int width, int height, String splashText)
{
Status status = ForgeVersion.getStatus();
if (status == BETA || status == BETA_OUTDATED)
@@ -278,6 +284,17 @@ public class ForgeHooksClient
gui.drawString(font, line, (width - font.getStringWidth(line)) / 2, 4 + (1 * (font.FONT_HEIGHT + 1)), -1);
}
if (!Loader.instance().java8)
{
String line = I18n.format("fml.messages.java8warning.1", TextFormatting.RED, TextFormatting.RESET);
gui.drawString(font, line, (width - font.getStringWidth(line)) / 2, 4 + (8 * (font.FONT_HEIGHT + 1)), -1);
line = I18n.format("fml.messages.java8warning.2");
gui.drawString(font, line, (width - font.getStringWidth(line)) / 2, 4 + (9 * (font.FONT_HEIGHT + 1)), -1);
splashText = updatescrollcounter < 50 ? "UPDATE!" : "JAVA!";
updatescrollcounter+=1;
updatescrollcounter%=100;
}
String line = null;
switch(status)
{
@@ -294,6 +311,24 @@ public class ForgeHooksClient
// if we have a line, render it in the bottom right, above Mojang's copyright line
gui.drawString(font, line, width - font.getStringWidth(line) - 2, height - (2 * (font.FONT_HEIGHT + 1)), -1);
}
return splashText;
}
public static void mainMenuMouseClick(int mouseX, int mouseY, int mouseButton, FontRenderer font, int width)
{
if (!Loader.instance().java8)
{
if (mouseY >= (4 + (8 * 10)) && mouseY < (4 + (10 * 10)))
{
int w = font.getStringWidth(I18n.format("fml.messages.java8warning.1", TextFormatting.RED, TextFormatting.RESET));
w = Math.max(w, font.getStringWidth(I18n.format("fml.messages.java8warning.2")));
if (mouseX >= ((width - w) / 2) && mouseX <= ((width + w) / 2))
{
FMLClientHandler.instance().showGuiScreen(new GuiJava8Error(new Java8VersionException(Collections.<ModContainer>emptyList())));
}
}
}
}
public static ISound playSound(SoundManager manager, ISound sound)