aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2022-06-30 14:13:06 +0200
committermakamys <makamys@outlook.com>2022-06-30 16:58:09 +0200
commit4f747447be852d91ac794c9d09357cdb153cb5ff (patch)
tree873c9ffd486dec8e74dac4d3830ba08afecbad89 /src
parent66ffe390a8b62b0d56db99f831b1dea60feaa225 (diff)
downloadNeodymium-4f747447be852d91ac794c9d09357cdb153cb5ff.tar.gz
Neodymium-4f747447be852d91ac794c9d09357cdb153cb5ff.tar.bz2
Neodymium-4f747447be852d91ac794c9d09357cdb153cb5ff.zip
Warn if incompatibilities are detected
Diffstat (limited to 'src')
-rw-r--r--src/main/java/makamys/neodymium/Compat.java37
-rw-r--r--src/main/java/makamys/neodymium/Config.java2
-rw-r--r--src/main/java/makamys/neodymium/Neodymium.java35
-rw-r--r--src/main/java/makamys/neodymium/renderer/NeoRenderer.java6
4 files changed, 79 insertions, 1 deletions
diff --git a/src/main/java/makamys/neodymium/Compat.java b/src/main/java/makamys/neodymium/Compat.java
index 7410928..92bc190 100644
--- a/src/main/java/makamys/neodymium/Compat.java
+++ b/src/main/java/makamys/neodymium/Compat.java
@@ -1,7 +1,15 @@
package makamys.neodymium;
+import static makamys.neodymium.Neodymium.LOGGER;
+
+import java.util.List;
+
+import org.lwjgl.opengl.GLContext;
+
import com.falsepattern.triangulator.api.ToggleableTessellator;
import cpw.mods.fml.common.Loader;
+import makamys.neodymium.util.OFUtil;
+import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
public class Compat {
@@ -14,4 +22,33 @@ public class Compat {
private static void disableTriangulator() {
((ToggleableTessellator)Tessellator.instance).disableTriangulator();
}
+
+ public static void getCompatibilityWarnings(List<String> warns, List<String> criticalWarns){
+ if(Minecraft.getMinecraft().gameSettings.advancedOpengl) {
+ warns.add("Advanced OpenGL is enabled, performance may be poor.");
+ }
+
+ if(Loader.isModLoaded("FastCraft") && !OFUtil.isOptiFinePresent()) {
+ criticalWarns.add("FastCraft is present without OptiFine, this is not supported.");
+ }
+
+ try {
+ Class<?> shaders = Class.forName("shadersmod.client.Shaders");
+ try {
+ String shaderPack = (String)shaders.getMethod("getShaderPackName").invoke(null);
+ if(shaderPack != null) {
+ criticalWarns.add("A shader pack is enabled, this is not supported.");
+ }
+ } catch(Exception e) {
+ LOGGER.warn("Failed to get shader pack name");
+ e.printStackTrace();
+ }
+ } catch (ClassNotFoundException e) {
+
+ }
+
+ if(!GLContext.getCapabilities().OpenGL33) {
+ criticalWarns.add("OpenGL 3.3 is not supported.");
+ }
+ }
}
diff --git a/src/main/java/makamys/neodymium/Config.java b/src/main/java/makamys/neodymium/Config.java
index 4237099..86aade3 100644
--- a/src/main/java/makamys/neodymium/Config.java
+++ b/src/main/java/makamys/neodymium/Config.java
@@ -57,6 +57,8 @@ public class Config {
@ConfigBoolean(cat="misc", def=true, com="Replace splash that says 'OpenGL 1.2!' with 'OpenGL 3.3!'. Just for fun.")
public static boolean replaceOpenGLSplash;
+ @ConfigBoolean(cat="misc", def=false, com="Don't warn about incompatibilities in chat, and activate renderer even in spite of critical ones.")
+ public static boolean ignoreIncompatibilities;
@ConfigInt(cat="debug", def=-1, min=-1, max=Integer.MAX_VALUE)
public static int maxMeshesPerFrame;
diff --git a/src/main/java/makamys/neodymium/Neodymium.java b/src/main/java/makamys/neodymium/Neodymium.java
index ba79e1c..fc036a5 100644
--- a/src/main/java/makamys/neodymium/Neodymium.java
+++ b/src/main/java/makamys/neodymium/Neodymium.java
@@ -2,6 +2,9 @@ package makamys.neodymium;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import cpw.mods.fml.common.FMLCommonHandler;
@@ -18,6 +21,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import makamys.mclib.core.MCLib;
import makamys.mclib.core.MCLibModules;
import makamys.neodymium.renderer.NeoRenderer;
+import makamys.neodymium.util.ChatUtil;
import makamys.neodymium.util.OFUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
@@ -68,6 +72,7 @@ public class Neodymium
public void onServerAboutToStart(FMLServerAboutToStartEvent event)
{
Config.reloadConfig();
+ ChatUtil.resetShownChatMessages();
}
private void onPlayerWorldChanged(World newWorld) {
@@ -79,7 +84,35 @@ public class Neodymium
renderer = null;
}
if(Config.enabled && newWorld != null) {
- renderer = new NeoRenderer(newWorld);
+ 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);
+ }
+
+ if(criticalWarns.isEmpty() || Config.ignoreIncompatibilities) {
+ renderer = new NeoRenderer(newWorld);
+ renderer.hasIncompatibilities = !warns.isEmpty() || !criticalWarns.isEmpty();
+ }
}
}
diff --git a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java
index 048b9a2..e669ff9 100644
--- a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java
+++ b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java
@@ -56,6 +56,7 @@ public class NeoRenderer {
private boolean showMemoryDebugger;
public boolean forceRenderFog;
+ public boolean hasIncompatibilities;
private static int MAX_MESHES = 100000;
@@ -596,6 +597,11 @@ public class NeoRenderer {
EnumChatFormatting.YELLOW + "(!) Renderer speedup active"
));
}
+ if(hasIncompatibilities) {
+ text.addAll(Arrays.asList(
+ EnumChatFormatting.YELLOW + "(!) Incompatibilities"
+ ));
+ }
return text;
}