From b0dfaa2b81067fd48e08f5f4ae1231245fad5194 Mon Sep 17 00:00:00 2001 From: Ben Staddon Date: Tue, 20 Jun 2017 23:22:14 +0100 Subject: [PATCH] Remove Java 8 warnings now that Minecraft requires it --- .../client/gui/GuiMainMenu.java.patch | 9 -- .../client/ForgeHooksClient.java | 32 ----- .../common/ForgeModContainer.java | 15 -- .../fml/client/FMLClientHandler.java | 23 +-- .../fml/client/GuiJava8Error.java | 136 ------------------ .../fml/common/Java8VersionException.java | 50 ------- .../net/minecraftforge/fml/common/Loader.java | 28 ---- .../common/discovery/asm/ASMModParser.java | 6 +- .../resources/assets/forge/lang/en_US.lang | 12 -- 9 files changed, 2 insertions(+), 309 deletions(-) delete mode 100644 src/main/java/net/minecraftforge/fml/client/GuiJava8Error.java delete mode 100644 src/main/java/net/minecraftforge/fml/common/Java8VersionException.java diff --git a/patches/minecraft/net/minecraft/client/gui/GuiMainMenu.java.patch b/patches/minecraft/net/minecraft/client/gui/GuiMainMenu.java.patch index 70670bfd2a..f12c53cb42 100644 --- a/patches/minecraft/net/minecraft/client/gui/GuiMainMenu.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/GuiMainMenu.java.patch @@ -73,12 +73,3 @@ } protected void func_73864_a(int p_73864_1_, int p_73864_2_, int p_73864_3_) throws IOException -@@ -562,6 +583,8 @@ - { - this.field_146297_k.func_147108_a(new GuiWinGame(false, Runnables.doNothing())); - } -+ -+ net.minecraftforge.client.ForgeHooksClient.mainMenuMouseClick(p_73864_1_, p_73864_2_, p_73864_3_, this.field_146289_q, this.field_146294_l); - } - - public void func_146281_b() diff --git a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java index 57ce4b1a7d..bc2e442a4c 100644 --- a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java +++ b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java @@ -29,7 +29,6 @@ import java.awt.image.BufferedImage; import java.io.File; import java.nio.ByteBuffer; import java.nio.FloatBuffer; -import java.util.Collections; import java.util.Map; import javax.annotation.Nonnull; @@ -115,12 +114,8 @@ 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; @@ -314,17 +309,6 @@ 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) { @@ -345,22 +329,6 @@ public class ForgeHooksClient 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.emptyList()))); - } - } - } - } - public static ISound playSound(SoundManager manager, ISound sound) { PlaySoundEvent e = new PlaySoundEvent(manager, sound); diff --git a/src/main/java/net/minecraftforge/common/ForgeModContainer.java b/src/main/java/net/minecraftforge/common/ForgeModContainer.java index 42f14ee7d0..b27400c296 100644 --- a/src/main/java/net/minecraftforge/common/ForgeModContainer.java +++ b/src/main/java/net/minecraftforge/common/ForgeModContainer.java @@ -36,7 +36,6 @@ import java.security.cert.Certificate; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -121,7 +120,6 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC public static boolean forgeLightPipelineEnabled = true; public static boolean replaceVanillaBucketModel = true; public static boolean zoomInMissingModelTextInGui = false; - public static long java8Reminder = 0; public static boolean disableStairSlabCulling = false; // Also known as the "DontCullStairsBecauseIUseACrappyTexturePackThatBreaksBasicBlockShapesSoICantTrustBasicBlockCulling" flag public static boolean alwaysSetupTerrainOffThread = false; // In RenderGlobal.setupTerrain, always force the chunk render updates to be queued to the thread public static int dimensionUnloadQueueDelay = 0; @@ -322,12 +320,6 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC prop.setLanguageKey("forge.configgui.zoomInMissingModelTextInGui"); propOrder.add(prop.getName()); - prop = config.get(Configuration.CATEGORY_CLIENT, "java8Reminder", 0, - "The timestamp of the last reminder to update to Java 8 in number of milliseconds since January 1, 1970, 00:00:00 GMT. Nag will show only once every 24 hours. To disable it set this to some really high number."); - java8Reminder = prop.getLong(0); - prop.setLanguageKey("forge.configgui.java8Reminder"); - propOrder.add(prop.getName()); - prop = config.get(Configuration.CATEGORY_CLIENT, "disableStairSlabCulling", false, "Disable culling of hidden faces next to stairs and slabs. Causes extra rendering, but may fix some resource packs that exploit this vanilla mechanic."); disableStairSlabCulling = prop.getBoolean(false); @@ -349,13 +341,6 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC } } - public static void updateNag() - { - Property prop = config.get(Configuration.CATEGORY_CLIENT, "java8Reminder", java8Reminder); - prop.set((new Date()).getTime()); - config.save(); - } - /** * By subscribing to the OnConfigChangedEvent we are able to execute code when our config screens are closed. * This implementation uses the optional configID string to handle multiple Configurations using one event handler. diff --git a/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java b/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java index 2d8725df87..2a2e2e1833 100644 --- a/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java +++ b/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java @@ -26,7 +26,6 @@ import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Date; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -81,7 +80,6 @@ import net.minecraft.world.WorldSettings; import net.minecraft.world.storage.WorldSummary; import net.minecraft.world.storage.SaveFormatOld; import net.minecraftforge.client.event.ModelRegistryEvent; -import net.minecraftforge.common.ForgeModContainer; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.ConfigManager; import net.minecraftforge.common.util.CompoundDataFixer; @@ -92,7 +90,6 @@ import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.FMLContainerHolder; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.IFMLSidedHandler; -import net.minecraftforge.fml.common.Java8VersionException; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.LoaderException; import net.minecraftforge.fml.common.MetadataCollection; @@ -179,8 +176,6 @@ public class FMLClientHandler implements IFMLSidedHandler private boolean loading = true; - private Java8VersionException j8onlymods; - private WrongMinecraftVersionException wrongMC; private CustomModLoadingErrorDisplayException customError; @@ -240,10 +235,6 @@ public class FMLClientHandler implements IFMLSidedHandler { dupesFound = dupes; } - catch (Java8VersionException j8mods) - { - j8onlymods = j8mods; - } catch (MissingModsException missing) { modsMissing = missing; @@ -338,7 +329,7 @@ public class FMLClientHandler implements IFMLSidedHandler public boolean hasError() { - return modsMissing != null || wrongMC != null || customError != null || dupesFound != null || modSorting != null || j8onlymods != null || multipleModsErrored != null; + return modsMissing != null || wrongMC != null || customError != null || dupesFound != null || modSorting != null || multipleModsErrored != null; } /** @@ -440,10 +431,6 @@ public class FMLClientHandler implements IFMLSidedHandler { showGuiScreen(new GuiWrongMinecraft(wrongMC)); } - else if (j8onlymods != null) - { - showGuiScreen(new GuiJava8Error(j8onlymods)); - } else if (modsMissing != null) { showGuiScreen(new GuiModsMissing(modsMissing)); @@ -467,14 +454,6 @@ public class FMLClientHandler implements IFMLSidedHandler else { logMissingTextureErrors(); - if (!Loader.instance().java8) - { - if ((new Date()).getTime() >= ForgeModContainer.java8Reminder + (1000 * 60 * 60 * 24)) - { - showGuiScreen(new GuiJava8Error(new Java8VersionException(Collections.emptyList()))); - ForgeModContainer.updateNag(); - } - } } } /** diff --git a/src/main/java/net/minecraftforge/fml/client/GuiJava8Error.java b/src/main/java/net/minecraftforge/fml/client/GuiJava8Error.java deleted file mode 100644 index d986948f81..0000000000 --- a/src/main/java/net/minecraftforge/fml/client/GuiJava8Error.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.client; - -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.resources.I18n; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fml.common.FMLCommonHandler; -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.logging.log4j.Level; - -import com.google.common.collect.Lists; - -import java.awt.Desktop; -import java.net.URI; -import java.util.List; - -public class GuiJava8Error extends GuiErrorBase -{ - private Java8VersionException java8VersionException; - public GuiJava8Error(Java8VersionException java8VersionException) - { - this.java8VersionException = java8VersionException; - } - - @Override - public void initGui() - { - super.initGui(); - this.buttonList.remove(1); - if (java8VersionException.getMods().isEmpty()) - { - this.buttonList.remove(0); - this.buttonList.add(new GuiButton(1, 50, this.height -38, this.width / 2 - 55, 20, I18n.format("fml.button.continue"))); - } - this.buttonList.add(new GuiButton(2, this.width / 2 + 5, this.height -38, this.width/2 -55, 20, I18n.format("fml.button.visitjavadownloads"))); - } - - @Override - protected void actionPerformed(GuiButton button) - { - if (button.id == 1) - { - FMLClientHandler.instance().showGuiScreen(null); - } - else if (button.id == 2) - { - try - { - Desktop.getDesktop().browse(new URI("http://www.oracle.com/technetwork/java/javase/downloads/index.html")); - } - catch (Exception e) - { - FMLLog.log.error("Problem launching browser", e); - } - } - else - { - super.actionPerformed(button); - } - } - - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) - { - this.drawDefaultBackground(); - int offset = 25; - if (!java8VersionException.getMods().isEmpty()) - { - this.drawCenteredString(this.fontRenderer, I18n.format("fml.messages.java8problem", TextFormatting.RED, TextFormatting.BOLD, TextFormatting.RESET), this.width / 2, offset, 0xFFFFFF); - } - else - { - this.drawCenteredString(this.fontRenderer, I18n.format("fml.messages.java8recommended", TextFormatting.RED, TextFormatting.BOLD, TextFormatting.RESET), this.width / 2, offset, 0xFFFFFF); - } - offset+=15; - this.drawCenteredString(this.fontRenderer, I18n.format("fml.messages.javaversion", System.getProperty("java.version").split("\\.")[1], System.getProperty("java.version")), this.width / 2, offset, 0xFFFFFF); - offset += 10; - if (!java8VersionException.getMods().isEmpty()) - { - this.drawCenteredString(this.fontRenderer, I18n.format("fml.messages.upgradejavaorremove", TextFormatting.RED,TextFormatting.BOLD, TextFormatting.RESET), this.width / 2, offset, 0xFFFFFF); - offset += 15; - this.drawCenteredString(this.fontRenderer, I18n.format("fml.messages.modslistedbelow", I18n.format("fml.messages.requirejava8")), this.width / 2, offset, 0xFFFFFF); - offset += 10; - this.drawCenteredString(this.fontRenderer, I18n.format("fml.messages.countbadandgood", java8VersionException.getMods().size(), Loader.instance().getActiveModList().size()), this.width / 2, offset, 0xFFFFFF); - offset += 5; - for (ModContainer mc : java8VersionException.getMods()) - { - offset += 10; - this.drawCenteredString(this.fontRenderer, String.format("%s (%s)", mc.getName(), mc.getModId()), this.width / 2, offset, 0xEEEEEE); - } - } - else - { - String text = I18n.format("fml.messages.upgradejava", TextFormatting.RED,TextFormatting.BOLD, TextFormatting.RESET).replaceAll("\\\\n", "\n"); - List lines = Lists.newArrayList(); - for (String line : text.split("\n")) - { - lines.addAll(this.fontRenderer.listFormattedStringToWidth(line, this.width - this.fontRenderer.FONT_HEIGHT * 4)); - } - - int maxWidth = 0; - for (String line : lines) - { - maxWidth = Math.max(maxWidth, this.fontRenderer.getStringWidth(line)); - } - - for (String line : lines) - { - this.drawString(this.fontRenderer, line, (this.width - maxWidth) / 2, offset, 0xFFFFFF); - offset += this.fontRenderer.FONT_HEIGHT + 2; - } - } - super.drawScreen(mouseX, mouseY, partialTicks); - } -} diff --git a/src/main/java/net/minecraftforge/fml/common/Java8VersionException.java b/src/main/java/net/minecraftforge/fml/common/Java8VersionException.java deleted file mode 100644 index 56dad337c3..0000000000 --- a/src/main/java/net/minecraftforge/fml/common/Java8VersionException.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.common; - -import java.util.List; - -public class Java8VersionException extends EnhancedRuntimeException -{ - private static final long serialVersionUID = 1L; - private final List mods; - - public Java8VersionException(List mods) - { - super("Mods require Java 8"); - this.mods = mods; - } - - @Override - protected void printStackTrace(WrappedPrintStream stream) - { - stream.println("Mods requiring Java 8:"); - for (ModContainer mc : mods) - { - stream.println(String.format("\t%s : %s", mc.getName(), mc.getModId())); - } - stream.println(""); - } - - public List getMods() - { - return mods; - } -} diff --git a/src/main/java/net/minecraftforge/fml/common/Loader.java b/src/main/java/net/minecraftforge/fml/common/Loader.java index 6ffb7888cc..5a5f628a1e 100644 --- a/src/main/java/net/minecraftforge/fml/common/Loader.java +++ b/src/main/java/net/minecraftforge/fml/common/Loader.java @@ -174,7 +174,6 @@ public class Loader private File forcedModFile; private ModDiscoverer discoverer; private ProgressBar progressBar; - public final boolean java8; public static Loader instance() { @@ -201,14 +200,6 @@ public class Loader private Loader() { - String[] ver = System.getProperty("java.version").split("\\."); - int major = Integer.parseInt(ver[1]); - java8 = major > 7; - if (!java8) - { - FMLLog.log.fatal("The game is not running with Java 8. Forge recommends Java 8 for maximum compatibility with mods"); - } - modClassLoader = new ModClassLoader(getClass().getClassLoader()); if (mccversion !=null && !mccversion.equals(MC_VERSION)) { @@ -555,7 +546,6 @@ public class Loader ModAPIManager.INSTANCE.manageAPI(modClassLoader, discoverer); disableRequestedMods(); modController.distributeStateMessage(FMLLoadEvent.class); - checkJavaCompatibility(); sortModList(); ModAPIManager.INSTANCE.cleanupAPIContainers(modController.getActiveModList()); ModAPIManager.INSTANCE.cleanupAPIContainers(mods); @@ -613,24 +603,6 @@ public class Loader modController.transition(LoaderState.PREINITIALIZATION, false); } - - private void checkJavaCompatibility() - { - if (java8) return; - List j8mods = Lists.newArrayList(); - for (ModContainer mc : getActiveModList()) - { - if (mc.getClassVersion() >= 52) - { - j8mods.add(mc); - } - } - if (!j8mods.isEmpty()) - { - throw new Java8VersionException(j8mods); - } - } - public void preinitializeMods() { if (!modController.isInState(LoaderState.PREINITIALIZATION)) diff --git a/src/main/java/net/minecraftforge/fml/common/discovery/asm/ASMModParser.java b/src/main/java/net/minecraftforge/fml/common/discovery/asm/ASMModParser.java index dde3ca07a1..8385a50257 100644 --- a/src/main/java/net/minecraftforge/fml/common/discovery/asm/ASMModParser.java +++ b/src/main/java/net/minecraftforge/fml/common/discovery/asm/ASMModParser.java @@ -131,11 +131,7 @@ public class ASMModParser public void validate() { -// if (classVersion > 50.0) -// { -// -// throw new LoaderException(new RuntimeException("Mod compiled for Java 7 detected")); -// } + } public boolean isBaseMod(List rememberedTypes) diff --git a/src/main/resources/assets/forge/lang/en_US.lang b/src/main/resources/assets/forge/lang/en_US.lang index 16c4ed4ec9..ad8e613ff6 100644 --- a/src/main/resources/assets/forge/lang/en_US.lang +++ b/src/main/resources/assets/forge/lang/en_US.lang @@ -49,7 +49,6 @@ forge.configgui.zombieBaseSummonChance=Zombie Summon Chance forge.configgui.stencilbits=Enable GL Stencil Bits forge.configgui.replaceBuckets=Use Forge's bucket model forge.configgui.forgeLightPipelineEnabled=Forge Light Pipeline Enabled -forge.configgui.java8Reminder=Java 8 Reminder timestamp forge.configgui.disableStairSlabCulling=Disable Stair/Slab culling. forge.configgui.zoomInMissingModelTextInGui=Zoom in Missing model text in the GUI forge.configgui.disableStairSlabCulling.tooltip=Enable this if you see through blocks touching stairs/slabs with your resource pack. @@ -167,16 +166,6 @@ fml.menu.modoptions=Mod Options... item.forge.bucketFilled.name=%s Bucket -fml.messages.java8problem=%s%sJava Update Required%s -fml.messages.java8recommended=%s%sJava Update Recommended%s -fml.messages.modslistedbelow=The mods listed below %s -fml.messages.requirejava8=require Java 8 -fml.messages.java8warning.1=%sJAVA VERSION WARNING%s UPDATE JAVA! -fml.messages.java8warning.2=You need to update Java -fml.messages.javaversion=Your Java version is Java %s (version string %s) -fml.messages.upgradejavaorremove=%s%sUpdate Java%s or remove these mods to play -fml.messages.upgradejava=\n\nPros of updating to Java 8\n- Better Performance\n- Better Security\n- Better Compatibility with newer mods -fml.messages.countbadandgood=%s of %s mods have this problem fml.messages.mod.missing.dependencies=%s is missing mods it depends on. fml.messages.mod.missing.dependencies.fix=Include the following mods or remove %s. fml.messages.mod.missing.dependencies.see.log=See '%s' for technical information. @@ -193,7 +182,6 @@ fml.messages.version.restriction.upper.inclusive=%s or below fml.messages.version.restriction.upper.exclusive=below %s fml.messages.version.restriction.bounded=between %s and %s -fml.button.visitjavadownloads=Oracle Java SE Downloads fml.button.continue=Continue fml.button.open.mods.folder=Open Mods Folder fml.button.open.file=Open %s