aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys/neodymium
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2022-06-30 17:45:43 +0200
committermakamys <makamys@outlook.com>2022-06-30 17:45:43 +0200
commita005dbd2989664c5443c43e97692635d54d7de8c (patch)
tree6ca743605484552bfa278404f7b2c57e6a6360cb /src/main/java/makamys/neodymium
parent7d481267fb8a5a3a466fde9bfe38cb64379e1409 (diff)
downloadNeodymium-a005dbd2989664c5443c43e97692635d54d7de8c.tar.gz
Neodymium-a005dbd2989664c5443c43e97692635d54d7de8c.tar.bz2
Neodymium-a005dbd2989664c5443c43e97692635d54d7de8c.zip
Update warnings immediately when Advanced OpenGL setting is changed
Diffstat (limited to 'src/main/java/makamys/neodymium')
-rw-r--r--src/main/java/makamys/neodymium/Compat.java15
-rw-r--r--src/main/java/makamys/neodymium/Neodymium.java66
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);
+ }
}