22
22
23
23
package com .falsepattern .lib .internal .config ;
24
24
25
- import com .falsepattern .lib .internal .FPLog ;
26
25
import lombok .NoArgsConstructor ;
27
- import lombok .val ;
28
26
29
27
import net .minecraft .client .Minecraft ;
30
- import net .minecraft .client .gui .GuiScreen ;
31
28
import net .minecraftforge .client .event .GuiOpenEvent ;
32
29
import net .minecraftforge .common .MinecraftForge ;
33
- import cpw .mods .fml .client .FMLClientHandler ;
34
30
import cpw .mods .fml .client .GuiIngameModOptions ;
35
31
import cpw .mods .fml .client .GuiModList ;
36
- import cpw .mods .fml .common .ModContainer ;
37
32
import cpw .mods .fml .common .eventhandler .SubscribeEvent ;
38
33
39
- import java .lang .reflect .Field ;
40
- import java .util .ArrayList ;
41
- import java .util .Collections ;
42
- import java .util .List ;
43
-
44
34
import static lombok .AccessLevel .PRIVATE ;
45
35
46
36
@ NoArgsConstructor (access = PRIVATE )
47
37
public final class InGameModOptionsFix {
48
38
private static boolean isInitialized = false ;
49
39
50
- private static Field MODS_FIELD ;
51
-
52
40
public static void init () {
53
41
if (isInitialized )
54
42
return ;
55
-
56
- try {
57
- MODS_FIELD = GuiModList .class .getDeclaredField ("mods" );
58
- MODS_FIELD .setAccessible (true );
59
- } catch (NoSuchFieldException e ) {
60
- MODS_FIELD = null ;
61
- FPLog .LOG .error ("Failed to get field: cpw.mods.fml.client.GuiModList.mods,"
62
- + " In-Game Mod Options Fix will not work" , e );
63
- return ;
64
- }
65
43
MinecraftForge .EVENT_BUS .register (new InGameModOptionsFix ());
66
44
isInitialized = true ;
67
45
}
@@ -74,36 +52,6 @@ public void onGuiOpen(final GuiOpenEvent event) {
74
52
return ;
75
53
76
54
if (event .gui instanceof GuiIngameModOptions )
77
- event .gui = new GuiModConfigList (Minecraft .getMinecraft ().currentScreen );
78
- }
79
-
80
- private static class GuiModConfigList extends GuiModList {
81
- private GuiModConfigList (GuiScreen screen ) {
82
- super (screen );
83
- val mods = new ArrayList <ModContainer >();
84
- for (val mod : getModsFromPrivateField ()) {
85
- val guiFactory = FMLClientHandler .instance ().getGuiFactoryFor (mod );
86
- if (guiFactory == null )
87
- continue ;
88
- if (guiFactory .mainConfigGuiClass () != null )
89
- mods .add (mod );
90
- }
91
- setModsToPrivateField (mods );
92
- }
93
-
94
- private List <ModContainer > getModsFromPrivateField () {
95
- try {
96
- return (List <ModContainer >) MODS_FIELD .get (this );
97
- } catch (Exception e ) {
98
- return Collections .emptyList ();
99
- }
100
- }
101
-
102
- private void setModsToPrivateField (List <ModContainer > mods ) {
103
- try {
104
- MODS_FIELD .set (this , mods );
105
- } catch (Exception ignored ) {
106
- }
107
- }
55
+ event .gui = new GuiModList (Minecraft .getMinecraft ().currentScreen );
108
56
}
109
57
}
0 commit comments