1111
1212import com .llamalad7 .mixinextras .sugar .Share ;
1313import com .llamalad7 .mixinextras .sugar .ref .LocalFloatRef ;
14+ import com .minecrafttas .mctcommon .events .EventListenerRegistry ;
1415import com .minecrafttas .tasmod .TASmodClient ;
16+ import com .minecrafttas .tasmod .events .EventClient .EventDrawHotbarAlways ;
1517import com .minecrafttas .tasmod .util .Ducks .SubtickDuck ;
1618import com .minecrafttas .tasmod .virtual .VirtualInput ;
1719
1820import net .minecraft .client .Minecraft ;
1921import net .minecraft .client .entity .EntityPlayerSP ;
22+ import net .minecraft .client .gui .ScaledResolution ;
2023import net .minecraft .client .renderer .EntityRenderer ;
2124import net .minecraft .client .renderer .GlStateManager ;
2225
@@ -114,11 +117,18 @@ public void runUpdate(float partialTicks) {
114117 Float newPitch = TASmodClient .virtual .CAMERA_ANGLE .getCurrentPitch ();
115118 Float newYaw = TASmodClient .virtual .CAMERA_ANGLE .getCurrentYaw ();
116119
117- // If the pitch or yaw is null (usually on initialize or when the player joins the world),
118- // set nextCameraAngle to the current absolute camera coordinates.
119- // This ensures that the camera position is loaded correctly
120+ /*
121+ * If the pitch or yaw is null,
122+ * usually on initialize or when the player joins the world),
123+ * do not update the camera angle.
124+ *
125+ * This is called during the loading screen for 2 game loops,
126+ * at which point the player is not initialized,
127+ * hence we do not have the correct camera angle yet.
128+ *
129+ * The angle is instead initialized in LoadingScreenHandler#onDoneLoadingPlayer.
130+ */
120131 if (newPitch == null || newYaw == null ) {
121- // TASmod.LOGGER.warn("Pitch and Yaw is null! This is not good!");
122132// TASmodClient.virtual.CAMERA_ANGLE.setCamera(prevPitch, prevYaw);
123133 return ;
124134 }
@@ -139,7 +149,7 @@ public void runUpdate(float partialTicks) {
139149 * @return 0f for disabeling this method
140150 */
141151 @ ModifyArg (method = "orientCamera" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/renderer/GlStateManager;rotate(FFFF)V" , ordinal = 8 ), index = 0 )
142- public float redirect_orientCameraPitch (float pitch , @ Share ("pitch" ) LocalFloatRef sharedPitch ) {
152+ public float playback_orientCameraPitch (float pitch , @ Share ("pitch" ) LocalFloatRef sharedPitch ) {
143153 sharedPitch .set (pitch );
144154 return 0f ;
145155 }
@@ -151,7 +161,7 @@ public float redirect_orientCameraPitch(float pitch, @Share("pitch") LocalFloatR
151161 * @return The redirected yaw
152162 */
153163 @ ModifyArg (method = "orientCamera" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/renderer/GlStateManager;rotate(FFFF)V" , ordinal = 9 ), index = 0 )
154- public float redirect_orientCameraYawAnimal (float yawAnimal , @ Share ("pitch" ) LocalFloatRef sharedPitch ) {
164+ public float playback_orientCameraYawAnimal (float yawAnimal , @ Share ("pitch" ) LocalFloatRef sharedPitch ) {
155165 return redirectCam (sharedPitch .get (), yawAnimal );
156166 }
157167
@@ -162,10 +172,27 @@ public float redirect_orientCameraYawAnimal(float yawAnimal, @Share("pitch") Loc
162172 * @return The redirected yaw
163173 */
164174 @ ModifyArg (method = "orientCamera" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/renderer/GlStateManager;rotate(FFFF)V" , ordinal = 10 ), index = 0 )
165- public float redirect_orientCameraYaw (float yaw , @ Share ("pitch" ) LocalFloatRef sharedPitch ) {
175+ public float playback_orientCameraYaw (float yaw , @ Share ("pitch" ) LocalFloatRef sharedPitch ) {
166176 return redirectCam (sharedPitch .get (), yaw );
167177 }
168178
179+ /**
180+ * Updates the game overlay and adds an event
181+ * @param ci CallBackInfo
182+ */
183+ @ Inject (method = "updateCameraAndRender" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/profiler/Profiler;endStartSection(Ljava/lang/String;)V" ))
184+ public void playback_updateOverlay (CallbackInfo ci ) {
185+ ScaledResolution scaledResolution = new ScaledResolution (this .mc );
186+ GlStateManager .clear (256 );
187+ GlStateManager .matrixMode (5889 );
188+ GlStateManager .loadIdentity ();
189+ GlStateManager .ortho (0.0 , scaledResolution .getScaledWidth_double (), scaledResolution .getScaledHeight_double (), 0.0 , 1000.0 , 3000.0 );
190+ GlStateManager .matrixMode (5888 );
191+ GlStateManager .loadIdentity ();
192+ GlStateManager .translate (0.0F , 0.0F , -2000.0F );
193+ EventListenerRegistry .fireEvent (EventDrawHotbarAlways .class );
194+ }
195+
169196 /**
170197 * Turns the camera via GLStateManager
171198 * @param pitch The pi
0 commit comments