2020import net .minecraft .client .Minecraft ;
2121import net .minecraft .client .gui .GuiMainMenu ;
2222import net .minecraft .client .gui .GuiScreen ;
23- import net .minecraft .client .gui .ScaledResolution ;
2423import net .minecraft .client .multiplayer .WorldClient ;
25- import net .minecraft .client .renderer .GlStateManager ;
2624import net .minecraft .util .Session ;
2725import net .minecraft .util .Timer ;
2826import org .apache .commons .lang3 .JavaVersion ;
3937import uk .co .hexeption .darkforge .DarkForge ;
4038import uk .co .hexeption .darkforge .MC ;
4139import uk .co .hexeption .darkforge .event .Event ;
42- import uk .co .hexeption .darkforge .event .events .EventRenderScreen ;
4340import uk .co .hexeption .darkforge .event .events .EventTick ;
4441import uk .co .hexeption .darkforge .event .events .EventWorld ;
4542import uk .co .hexeption .darkforge .gui .screen .DarkForgeMainMenu ;
43+ import uk .co .hexeption .darkforge .hook .HGuiInGame ;
4644import uk .co .hexeption .darkforge .managers .EventManager ;
4745import uk .co .hexeption .darkforge .mixin .imp .IMixinMinecraft ;
4846import uk .co .hexeption .darkforge .utils .InputHandler ;
@@ -60,9 +58,11 @@ public abstract class MixinMinecraft implements IMixinMinecraft, MC {
6058 @ Shadow
6159 @ Nullable
6260 public GuiScreen currentScreen ;
61+
6362 @ Shadow
6463 @ Final
6564 private Timer timer ;
65+
6666 @ Mutable
6767 @ Shadow
6868 @ Final
@@ -77,6 +77,7 @@ public abstract class MixinMinecraft implements IMixinMinecraft, MC {
7777
7878 @ Inject (method = "init" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/Minecraft;checkGLError(Ljava/lang/String;)V" , ordinal = 2 , shift = At .Shift .AFTER ))
7979 private void IstartGame (CallbackInfo callback ) {
80+
8081 if (SystemUtils .isJavaVersionAtLeast (JavaVersion .JAVA_1_8 )) {
8182 DarkForge .INSTANCE .start ();
8283 } else {
@@ -86,37 +87,31 @@ private void IstartGame(CallbackInfo callback) {
8687
8788 @ Inject (method = "runGameLoop" , at = @ At (value = "INVOKE_STRING" , target = "Lnet/minecraft/profiler/Profiler;startSection(Ljava/lang/String;)V" , args = "ldc=tick" , shift = At .Shift .AFTER ))
8889 private void IrunGameLoop (CallbackInfo callback ) {
90+
8991 EventTick event = new EventTick (Event .Type .PRE );
9092 EventManager .handleEvent (event );
9193 }
9294
9395 @ Inject (method = "runTickKeyboard" , at = @ At (value = "INVOKE" , remap = false , target = "Lorg/lwjgl/input/Keyboard;getEventKey()I" , ordinal = 0 , shift = At .Shift .BEFORE ))
9496 public void IrunTickKeyboard (CallbackInfo callback ) {
97+
9598 if (Keyboard .getEventKeyState ()) {
9699 InputHandler .handleKeyboard ();
97100 }
98101 }
99102
100103 @ Inject (method = "runTickMouse" , at = @ At (value = "INVOKE" , remap = false , target = "Lorg/lwjgl/input/Mouse;getEventButton()I" , ordinal = 0 , shift = At .Shift .BEFORE ))
101104 public void IrunTickMouse (CallbackInfo callback ) {
105+
102106 if (Mouse .getEventButtonState ()) {
103107 InputHandler .handleMouse ();
104108 }
105109 }
106110
107- @ Inject (method = "runGameLoop" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/renderer/EntityRenderer;updateCameraAndRender(FJ)V" , shift = At .Shift .AFTER ))
108- private void IrenderScreenPost (CallbackInfo callback ) {
109- if (!((Minecraft ) (Object ) this ).skipRenderWorld ) {
110- GlStateManager .pushMatrix ();
111- ScaledResolution res = new ScaledResolution ((Minecraft ) (Object ) this );
112- EventRenderScreen event = new EventRenderScreen (Event .Type .POST , res .getScaledWidth (), res .getScaledHeight ());
113- EventManager .handleEvent (event );
114- GlStateManager .popMatrix ();
115- }
116- }
117-
118111 @ Inject (method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V" , at = @ At ("HEAD" ))
119112 public void loadWorld (@ Nullable WorldClient worldClientIn , String loadingMessage , CallbackInfo callback ) {
113+
114+ mc .ingameGUI = new HGuiInGame (mc );
120115 Event event ;
121116 if (worldClientIn != null ) {
122117 event = new EventWorld .Load (Event .Type .PRE , worldClientIn );
@@ -137,16 +132,19 @@ public void runTick(CallbackInfo callbackInfo) {
137132
138133 @ Override
139134 public Session getSession () {
135+
140136 return session ;
141137 }
142138
143139 @ Override
144140 public void setSession (Session session ) {
141+
145142 this .session = session ;
146143 }
147144
148145 @ Override
149146 public Timer getTimer () {
147+
150148 return timer ;
151149 }
152150}
0 commit comments