2424package com .falsepattern .falsetweaks ;
2525
2626import com .falsepattern .falsetweaks .proxy .CommonProxy ;
27- import lombok .val ;
2827
29- import net .minecraft .client .gui .FontRenderer ;
30- import net .minecraft .client .gui .GuiErrorScreen ;
31- import cpw .mods .fml .client .CustomModLoadingErrorDisplayException ;
3228import cpw .mods .fml .common .Loader ;
3329import cpw .mods .fml .common .Mod ;
3430import cpw .mods .fml .common .SidedProxy ;
3733import cpw .mods .fml .common .event .FMLLoadCompleteEvent ;
3834import cpw .mods .fml .common .event .FMLPostInitializationEvent ;
3935import cpw .mods .fml .common .event .FMLPreInitializationEvent ;
36+ import cpw .mods .fml .relauncher .FMLLaunchHandler ;
4037
4138@ Mod (modid = Tags .MOD_ID ,
4239 version = Tags .MOD_VERSION ,
@@ -61,21 +58,21 @@ public void construct(FMLConstructionEvent e) {
6158 proxy .construct (e );
6259 }
6360
64- private static CustomModLoadingErrorDisplayException builtinMod (String modname ) {
65- return new MultiLineLoadingException ("Remove " + modname + " from your mods directory.\n It has been merged into FalseTweaks!" );
61+ private static void builtinMod (String modname ) {
62+ createSidedException ("Remove " + modname + " from your mods directory.\n It has been merged into FalseTweaks!" );
6663 }
6764
6865 @ Mod .EventHandler
6966 public void preInit (FMLPreInitializationEvent e ) {
7067 proxy .preInit (e );
7168 if (Loader .isModLoaded ("animfix" )) {
72- throw builtinMod ("animfix" );
69+ builtinMod ("animfix" );
7370 }
7471 if (Loader .isModLoaded ("triangulator" )) {
75- throw builtinMod ("triangulator" );
72+ builtinMod ("triangulator" );
7673 }
7774 if (Loader .isModLoaded ("DynamicLights" )) {
78- throw new MultiLineLoadingException ("Remove the DynamicLights mod and restart the game!\n FalseTweaks has built-in dynamic lights support." );
75+ createSidedException ("Remove the DynamicLights mod and restart the game!\n FalseTweaks has built-in dynamic lights support." );
7976 }
8077 }
8178
@@ -94,25 +91,17 @@ public void loadComplete(FMLLoadCompleteEvent e) {
9491 proxy .loadComplete (e );
9592 }
9693
97- private static class MultiLineLoadingException extends CustomModLoadingErrorDisplayException {
98- private final String [] lines ;
99- public MultiLineLoadingException (String text ) {
100- lines = text .split ("\n " );
101- }
102-
103- @ Override
104- public void initGui (GuiErrorScreen errorScreen , FontRenderer fontRenderer ) {
105-
94+ private static void createSidedException (String text ) {
95+ if (FMLLaunchHandler .side ().isClient ()) {
96+ throw ClientHelper .createException (text );
97+ } else {
98+ throw new Error (text );
10699 }
100+ }
107101
108- @ Override
109- public void drawScreen (GuiErrorScreen errorScreen , FontRenderer fontRenderer , int mouseRelX , int mouseRelY , float tickTime ) {
110- int offset = errorScreen .height / 2 - (lines .length * 5 );
111- int x = errorScreen .width / 2 ;
112- for (val line : lines ) {
113- errorScreen .drawCenteredString (fontRenderer , line , x , offset , 0xFFFFFF );
114- offset += 10 ;
115- }
102+ private static class ClientHelper {
103+ private static RuntimeException createException (String text ) {
104+ return new MultiLineLoadingException (text );
116105 }
117106 }
118107}
0 commit comments