diff options
Diffstat (limited to 'src/main/java/makamys/neodymium')
-rw-r--r-- | src/main/java/makamys/neodymium/Compat.java | 15 | ||||
-rw-r--r-- | src/main/java/makamys/neodymium/Neodymium.java | 66 |
2 files changed, 57 insertions, 24 deletions
diff --git a/src/main/java/makamys/neodymium/Compat.java b/src/main/java/makamys/neodymium/Compat.java index 92bc190..56b5360 100644 --- a/src/main/java/makamys/neodymium/Compat.java +++ b/src/main/java/makamys/neodymium/Compat.java @@ -13,6 +13,9 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; public class Compat { + + private static boolean wasAdvancedOpenGLEnabled; + public static void applyCompatibilityTweaks() { if (Loader.isModLoaded("triangulator")) { disableTriangulator(); @@ -51,4 +54,16 @@ public class Compat { criticalWarns.add("OpenGL 3.3 is not supported."); } } + + public static boolean hasChanged() { + boolean changed = false; + + boolean advGL = Minecraft.getMinecraft().gameSettings.advancedOpengl; + if(advGL != wasAdvancedOpenGLEnabled) { + changed = true; + } + wasAdvancedOpenGLEnabled = advGL; + + return changed; + } } diff --git a/src/main/java/makamys/neodymium/Neodymium.java b/src/main/java/makamys/neodymium/Neodymium.java index 7026bd9..de06451 100644 --- a/src/main/java/makamys/neodymium/Neodymium.java +++ b/src/main/java/makamys/neodymium/Neodymium.java @@ -3,6 +3,7 @@ package makamys.neodymium; import java.util.ArrayList; import java.util.List; +import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -93,31 +94,10 @@ public class Neodymium destroyRenderer(); } if(Config.enabled && newWorld != null) { - List<String> warns = new ArrayList<>(); - List<String> criticalWarns = new ArrayList<>(); + Pair<List<String>, List<String>> warnsAndCriticalWarns = checkCompat(); + List<String> warns = warnsAndCriticalWarns.getLeft(); + List<String> criticalWarns = warnsAndCriticalWarns.getRight(); - Compat.getCompatibilityWarnings(warns, criticalWarns); - - if(!criticalWarns.isEmpty()) { - criticalWarns.add("Neodymium has been disabled due to a critical incompatibility."); - } - - if(!Config.ignoreIncompatibilities) { - for(String warn : warns) { - ChatUtil.showNeoChatMessage(warn, ChatUtil.MessageVerbosity.WARNING, true); - } - for(String fatalWarn : criticalWarns) { - ChatUtil.showNeoChatMessage(fatalWarn, ChatUtil.MessageVerbosity.ERROR, true); - } - } - - for(String warn : warns) { - LOGGER.warn(warn); - } - for(String criticalWarn : criticalWarns) { - LOGGER.warn("Critical: " + criticalWarn); - } - if(criticalWarns.isEmpty() || Config.ignoreIncompatibilities) { renderer = new NeoRenderer(newWorld); renderer.hasIncompatibilities = !warns.isEmpty() || !criticalWarns.isEmpty(); @@ -159,6 +139,15 @@ public class Neodymium } } } + + if(event.phase == TickEvent.Phase.START) { + if(Compat.hasChanged()) { + Pair<List<String>, List<String>> warns = checkCompat(); + if(renderer != null) { + renderer.hasIncompatibilities = !warns.getLeft().isEmpty() || !warns.getRight().isEmpty(); + } + } + } } @SubscribeEvent @@ -222,5 +211,34 @@ public class Neodymium } rendererWorld = null; } + + private static Pair<List<String>, List<String>> checkCompat() { + List<String> warns = new ArrayList<>(); + List<String> criticalWarns = new ArrayList<>(); + + Compat.getCompatibilityWarnings(warns, criticalWarns); + + if(!criticalWarns.isEmpty()) { + criticalWarns.add("Neodymium has been disabled due to a critical incompatibility."); + } + + if(!Config.ignoreIncompatibilities) { + for(String warn : warns) { + ChatUtil.showNeoChatMessage(warn, ChatUtil.MessageVerbosity.WARNING, true); + } + for(String fatalWarn : criticalWarns) { + ChatUtil.showNeoChatMessage(fatalWarn, ChatUtil.MessageVerbosity.ERROR, true); + } + } + + for(String warn : warns) { + LOGGER.warn(warn); + } + for(String criticalWarn : criticalWarns) { + LOGGER.warn("Critical: " + criticalWarn); + } + + return Pair.of(warns, criticalWarns); + } } |