3333import com .mojang .blaze3d .vertex .Tessellator ;
3434import io .github .axolotlclient .AxolotlClientConfig .api .util .Colors ;
3535import io .github .axolotlclient .AxolotlClientConfig .impl .util .DrawUtil ;
36+ import io .github .axolotlclient .modules .freelook .Perspective ;
3637import io .github .axolotlclient .waypoints .AxolotlClientWaypoints ;
3738import io .github .axolotlclient .waypoints .mixin .GameRendererAccessor ;
3839import net .minecraft .client .Minecraft ;
3940import net .minecraft .client .gui .GuiElement ;
41+ import net .minecraft .client .render .Camera ;
4042import net .minecraft .client .render .Window ;
4143import net .minecraft .entity .Entity ;
4244import net .minecraft .util .math .Vec3d ;
@@ -66,11 +68,8 @@ public void render(float f) {
6668 GlStateManager .color3f (1 , 1 , 1 );
6769 GlStateManager .pushMatrix ();
6870
69- var camPos = cam .getEyePosition (f );
70- var cpos = camPos .subtract (0 , cam .getEyeHeight (), 0 );
71- //var camPos = new Vector3d(cam.x, cam.y, cam.z);
72- //var prevCamPos = new Vector3d(cam.prevTickX, cam.prevTickY, cam.prevTickZ);
73- //camPos.sub(prevCamPos).mul(f).add(prevCamPos);
71+ var camPos = Camera .getPos (cam , f );
72+ var cpos = cam .getEyePosition (f ).subtract (0 , cam .getEyeHeight (), 0 );
7473
7574 GlStateManager .depthMask (false );
7675 GlStateManager .disableDepthTest ();
@@ -109,7 +108,11 @@ private void renderWaypoint(Waypoint waypoint, Vec3d camPos, Vec3d camEyePos, fl
109108 GlStateManager .translated (waypoint .x () - camEyePos .x , waypoint .y () - camEyePos .y , waypoint .z () - camEyePos .z );
110109 var dispatcher = minecraft .getEntityRenderDispatcher ();
111110 GlStateManager .rotatef (-dispatcher .cameraYaw , 0.0F , 1.0F , 0.0F );
112- GlStateManager .rotatef (dispatcher .cameraPitch , 1.0F , 0.0F , 0.0F );
111+ if (Minecraft .getInstance ().options .perspective == Perspective .THIRD_PERSON_FRONT .ordinal ()) {
112+ GlStateManager .rotatef (-dispatcher .cameraPitch , 1.0F , 0.0F , 0.0F );
113+ } else {
114+ GlStateManager .rotatef (dispatcher .cameraPitch , 1.0F , 0.0F , 0.0F );
115+ }
113116 float scale = 0.04F ;
114117 GlStateManager .scalef (-scale , -scale , scale );
115118 GlStateManager .enableBlend ();
@@ -165,7 +168,7 @@ public void renderWaypoints(float tick) {
165168
166169 private Matrix4f getProjectionMatrix (float fov ) {
167170 Matrix4f matrix4f = new Matrix4f ();
168- return matrix4f .perspective (fov * ((float ) Math .PI / 180F ), (float ) this .minecraft .width / (float ) this .minecraft .height , 0.05F , minecraft .options .viewDistance * 4 );
171+ return matrix4f .perspective (fov * ((float ) Math .PI / 180F ), (float ) this .minecraft .width / (float ) this .minecraft .height , 0.05F , minecraft .options .viewDistance * 2 );
169172 }
170173
171174 private void renderWaypoint (Waypoint waypoint , float tick , Entity camera , List <Runnable > positionDrawn , int guiWidth , int guiHeight ) {
@@ -175,7 +178,7 @@ private void renderWaypoint(Waypoint waypoint, float tick, Entity camera, List<R
175178 int width = textWidth + Waypoint .displayXOffset () * 2 ;
176179 int textHeight = minecraft .textRenderer .fontHeight ;
177180 int height = textHeight + Waypoint .displayYOffset () * 2 ;
178- var camPos = camera . getEyePosition ( tick );
181+ var camPos = Camera . getPos ( camera , tick );
179182
180183 var displayStart = projectToScreen (guiWidth , guiHeight , camPos , fov , width , height , waypoint .x (), waypoint .y (), waypoint .z (), new Vector2f (-(width / 2f * 0.04f ), (height / 2f * 0.04f )));
181184 var displayEnd = projectToScreen (guiWidth , guiHeight , camPos , fov , width , height , waypoint .x (), waypoint .y (), waypoint .z (), new Vector2f ((width / 2f * 0.04f ), -(height / 2f * 0.04f )));
@@ -248,10 +251,11 @@ private void renderWaypoint(Waypoint waypoint, float tick, Entity camera, List<R
248251 private @ Nullable Result projectToScreen (int guiWidth , int guiHeight , Vec3d camPos , float fov , int width , int height , double x , double y , double z , Vector2f orthoOffset ) {
249252 viewProj .set (x , y , z , 1 );
250253 var dispatcher = minecraft .getEntityRenderDispatcher ();
254+ var pitch = Minecraft .getInstance ().options .perspective == Perspective .THIRD_PERSON_FRONT .ordinal () ? -dispatcher .cameraPitch : dispatcher .cameraPitch ;
251255 if (orthoOffset != null ) {
252256 var vec = new Matrix4f ();
253257 var camRot = new Quaternionf ()
254- .rotationYXZ (-dispatcher .cameraYaw * (float ) (Math .PI / 180.0 ), dispatcher . cameraPitch * (float ) (Math .PI / 180.0 ), 0.0F )
258+ .rotationYXZ (-dispatcher .cameraYaw * (float ) (Math .PI / 180.0 ), pitch * (float ) (Math .PI / 180.0 ), 0.0F )
255259 .rotateY ((float ) -(Math .PI )).invert ();
256260 vec .rotate (camRot .invert (new Quaternionf ()));
257261 vec .translate (orthoOffset .x (), orthoOffset .y (), 0 );
@@ -260,7 +264,7 @@ private void renderWaypoint(Waypoint waypoint, float tick, Entity camera, List<R
260264 }
261265
262266 view .rotation (new Quaternionf ()
263- .rotationYXZ (-dispatcher .cameraYaw * (float ) (Math .PI / 180.0 ), dispatcher . cameraPitch * (float ) (Math .PI / 180.0 ), 0.0F )
267+ .rotationYXZ (-dispatcher .cameraYaw * (float ) (Math .PI / 180.0 ), pitch * (float ) (Math .PI / 180.0 ), 0.0F )
264268 .rotateY ((float ) -(Math .PI )).invert ()).translate ((float ) -camPos .x , (float ) -camPos .y , (float ) -camPos .z );
265269
266270 Matrix4f projection = getProjectionMatrix (fov );
0 commit comments