From b30ad911fad8e8b7d45de4d9b32e3892b0d97899 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Wed, 29 Jun 2016 20:22:14 -0500 Subject: [PATCH] Reflect since trying to get around inlining isn't working --- src/main/java/vazkii/botania/common/Botania.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/vazkii/botania/common/Botania.java b/src/main/java/vazkii/botania/common/Botania.java index 8395d5053..d662eb974 100644 --- a/src/main/java/vazkii/botania/common/Botania.java +++ b/src/main/java/vazkii/botania/common/Botania.java @@ -79,8 +79,8 @@ public class Botania { @EventHandler public void preInit(FMLPreInitializationEvent event) { try { - // Prevent constant "1.9.4" from being inlined and messing up selection in 1.10 - String mcVersion = Loader.MC_VERSION.toString(); + // The constant is inlined at compile time, we want the real value. + String mcVersion = (String) Loader.class.getDeclaredField("MC_VERSION").get(null); if(!PROXY_MAP.containsKey(mcVersion)) throw new IllegalStateException("Botania couldn't find a cross version proxy!"); @@ -89,7 +89,7 @@ public class Botania { crossVersionProxy = (ICrossVersionProxy) clazz.newInstance(); Botania.LOGGER.info("Enabling proxy for Minecraft {}", mcVersion); - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) { + } catch (NoSuchFieldException | ClassNotFoundException | InstantiationException | IllegalAccessException ex) { throw new IllegalStateException("Botania couldn't find a cross version proxy!", ex); }