diff --git a/src/main/java/com/enderio/core/client/gui/bettermodlist/GuiEnhancedModList.java b/src/main/java/com/enderio/core/client/gui/bettermodlist/GuiEnhancedModList.java index 8c2f4cc..42d3911 100644 --- a/src/main/java/com/enderio/core/client/gui/bettermodlist/GuiEnhancedModList.java +++ b/src/main/java/com/enderio/core/client/gui/bettermodlist/GuiEnhancedModList.java @@ -144,7 +144,10 @@ public class GuiEnhancedModList extends GuiModList { @Override public void initGui() { // Super code reinitializes the mod list every time, need to preserve scroll state - float scroll = getGuiModListScroll(); + float scroll = 0; + if (getGuiModList() != null) { + scroll = getGuiModListScroll(); + } super.initGui(); diff --git a/src/main/java/com/enderio/core/common/Handlers.java b/src/main/java/com/enderio/core/common/Handlers.java index 08cd2a1..1511883 100644 --- a/src/main/java/com/enderio/core/common/Handlers.java +++ b/src/main/java/com/enderio/core/common/Handlers.java @@ -123,7 +123,13 @@ public class Handlers { * The handler should be grabbed from the static {@code instance()} method * of the class */ - METHOD; + METHOD, + + /** + * Added for scala compat, not necessary to set explicitly ({@link #AUTO} + * will find this). + */ + SCALA_OBJECT; boolean matches(Inst other) { return this == AUTO || other == AUTO || other == this; @@ -279,6 +285,15 @@ public class Handlers { } catch (Exception e) { } } + + if (pref.matches(SCALA_OBJECT)) { + try { + Field inst = Class.forName(c.getName()+ "$").getDeclaredField("MODULE$"); + inst.setAccessible(true); + return inst.get(null); + } catch (Exception e) { + } + } throw new RuntimeException("Could not instantiate @Handler class " + c.getName() + " or access INSTANCE field or instance() method."); }