@@ -73,19 +73,20 @@ public void onLoop(CallbackInfo ci) {
7373
7474 @ Inject (method = "init" , at = @ At ("RETURN" ))
7575 public void init (CallbackInfo ci ) {
76+ // Try and find the "client.json" config
7677 InputStream stream = this .getClass ().getResourceAsStream ("/client.json" );
7778
7879 if (stream == null )
7980 throw new ClientInitException ("Unable to locate the Client.json" );
8081
81- BufferedReader reader = new BufferedReader ( new InputStreamReader ( stream ));
82- ClientInfo clientInfo = new GsonBuilder ().setPrettyPrinting ().create ().fromJson (reader , ClientInfo .class );
82+ // Construct a ClientInfo object from the client json using GSON
83+ ClientInfo clientInfo = new GsonBuilder ().setPrettyPrinting ().create ().fromJson (new BufferedReader ( new InputStreamReader ( stream )) , ClientInfo .class );
8384
8485 if (clientInfo == null )
8586 throw new ClientInitException ("Unable to create ClientInfo from Client.json" );
8687
88+ // Attempt to instantiate the specified class from the ClientInfo
8789 Client client ;
88-
8990 try {
9091 Class <?> clientClass = Class .forName (clientInfo .getMain ());
9192 if (clientClass != null && clientClass .getSuperclass ().equals (Client .class )) {
@@ -101,10 +102,15 @@ public void init(CallbackInfo ci) {
101102 throw new ClientInitException ("Unable to find client class" );
102103 }
103104
105+ // Init GLUtils
104106 GlUtils .init ();
105- client . setInfo ( clientInfo );
107+
106108 ClientHandler handler = new ClientHandler ();
109+
110+ // Init client
111+ client .setInfo (clientInfo );
107112 client .onInit (handler );
113+
108114 ClientAPI .EVENT_BUS .subscribe (handler );
109115 }
110116
@@ -132,6 +138,7 @@ public GuiScreen displayGuiScreen(GuiScreen screen) {
132138
133139 @ Inject (method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V" , at = @ At ("HEAD" ))
134140 public void loadWorld (@ Nullable WorldClient worldClientIn , String loadingMessage , CallbackInfo ci ) {
141+ // If the world is null, then it must be unloading
135142 if (worldClientIn != null )
136143 ClientAPI .EVENT_BUS .post (new WorldEvent .Load (worldClientIn ));
137144 else
@@ -158,6 +165,7 @@ public void setSession(Session session) {
158165
159166 @ Override
160167 public void clickMouse (ClickEvent .MouseButton button ) {
168+ // IF statements are required because Mixin doesn't support SWITCH
161169 if (button == LEFT )
162170 clickMouse ();
163171 if (button == RIGHT )
0 commit comments