Skip to content

Commit fa269f6

Browse files
committed
fix more somewhat fov-related bugs
1 parent 9d2c6ed commit fa269f6

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

1.20/src/main/java/io/github/axolotlclient/waypoints/waypoints/WaypointRenderer.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ public void render(PoseStack stack, MultiBufferSource.BufferSource source, float
5757
stack.pushPose();
5858
var cam = minecraft.gameRenderer.getMainCamera();
5959
var camPos = cam.getPosition();
60-
minecraft.gameRenderer.resetProjectionMatrix(minecraft.gameRenderer.getProjectionMatrix(((GameRendererAccessor) minecraft.gameRenderer).invokeGetFov(cam, 0, false)));
61-
RenderSystem.enableBlend();
6260
float fov = (float) ((GameRendererAccessor) minecraft.gameRenderer).invokeGetFov(cam, tick, true);
61+
RenderSystem.enableBlend();
6362
worldRendererWaypoints.clear();
6463

6564
for (Waypoint waypoint : AxolotlClientWaypoints.getCurrentWaypoints()) {
@@ -97,22 +96,23 @@ private void renderWaypoint(Waypoint waypoint, PoseStack stack, Vec3 camPos, Cam
9796
stack.mulPose(cam.rotation());
9897
float scale = 0.04F;
9998
stack.scale(-scale, -scale, scale);
100-
//fillRect(stack, bufferSource, -width / 2f, -height / 2f, 0f, width / 2f, height / 2f, waypoint.color().toInt());
101-
drawFontBatch(waypoint.display(), -textWidth / 2f, -textHeight / 2f, stack.last().pose(), bufferSource, waypoint.color().toInt());
99+
drawFontBatch(waypoint.display(), -textWidth / 2f, -textHeight / 2f, stack.last().pose(), bufferSource);
100+
fillRect(stack, bufferSource, -width / 2f, -height / 2f, 0.001f, width / 2f, height / 2f, waypoint.color().toInt());
102101
stack.popPose();
103102
}
104103

105104
private void fillRect(PoseStack stack, MultiBufferSource.BufferSource source, float x, float y, float z, float x2, float y2, int color) {
106-
var buf = source.getBuffer(RenderType.textBackgroundSeeThrough());
105+
var buf = source.getBuffer(RenderType.gui());
107106
var matrix = stack.last().pose();
108107
buf.vertex(matrix, x, y, z).color(color).uv2(0xF000F0).endVertex();
109108
buf.vertex(matrix, x, y2, z).color(color).uv2(0xF000F0).endVertex();
110109
buf.vertex(matrix, x2, y2, z).color(color).uv2(0xF000F0).endVertex();
111110
buf.vertex(matrix, x2, y, z).color(color).uv2(0xF000F0).endVertex();
111+
source.endBatch();
112112
}
113113

114-
private void drawFontBatch(String text, float x, float y, Matrix4f matrix, MultiBufferSource bufferSource, int bgColor) {
115-
minecraft.font.drawInBatch(text, x, y, -1, false, matrix, bufferSource, Font.DisplayMode.NORMAL, bgColor, 0xF000F0);
114+
private void drawFontBatch(String text, float x, float y, Matrix4f matrix, MultiBufferSource bufferSource) {
115+
minecraft.font.drawInBatch(text, x, y, -1, false, matrix, bufferSource, Font.DisplayMode.NORMAL, 0, 0xF000F0);
116116
}
117117

118118
public void renderWaypoints(GuiGraphics graphics, float delta) {
@@ -182,7 +182,7 @@ private void renderWaypoint(Waypoint waypoint, GuiGraphics graphics, float tick,
182182
maxX > 0 && minY > 0 && maxX < guiWidth && minY < guiHeight ||
183183
minX < guiWidth && maxX > 0 && minY < guiHeight && maxY > 0;
184184
} else {
185-
_3dOnScreen = false;
185+
_3dOnScreen = false;
186186
}
187187
boolean displayX = Math.abs(result.x() - graphics.guiWidth() / 2f) < (_3dOnScreen ? Math.max(projWidth, width) : width) / 2f + graphics.guiWidth() / 4f;
188188
boolean displayY = Math.abs(result.y() - graphics.guiHeight() / 2f) < (_3dOnScreen ? Math.max(height, projHeight) : height) / 2f + graphics.guiHeight() / 4f;
@@ -235,7 +235,6 @@ private void renderWaypoint(Waypoint waypoint, GuiGraphics graphics, float tick,
235235
projection.mul(view);
236236
viewProj.mul(projection);
237237

238-
239238
if (orthoOffset == null && AxolotlClientWaypoints.renderOutOfViewWaypointsOnScreenEdge.get()) {
240239
viewProj.w = Math.max(Math.abs(viewProj.x()), Math.max(Math.abs(viewProj.y()), viewProj.w()));
241240
}
@@ -251,7 +250,7 @@ private void renderWaypoint(Waypoint waypoint, GuiGraphics graphics, float tick,
251250
//float x = (graphics.guiWidth()/2f) + ((graphics.guiWidth() - width) * (viewProj.x() / 2f));
252251
float resultX = 0.5f * (minecraft.getWindow().getGuiScaledWidth() * (projX + 1) - width * projX);
253252
//float y = graphics.guiHeight() - (graphics.guiHeight()/2f + (graphics.guiHeight()-height) * (viewProj.y() / 2f));
254-
float resultY = minecraft.getWindow().getGuiScaledWidth() * (0.5f - projY / 2) + (height * projY) / 2f;
253+
float resultY = minecraft.getWindow().getGuiScaledHeight() * (0.5f - projY / 2) + (height * projY) / 2f;
255254
return new Result(resultX, resultY);
256255
}
257256

1.21/src/main/java/io/github/axolotlclient/waypoints/waypoints/WaypointRenderer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public void render(DeltaTracker deltaTracker) {
6666
stack.mulPose(cam.rotation().invert());
6767
var camPos = minecraft.gameRenderer.getMainCamera().getPosition();
6868
float fov = (float) ((GameRendererAccessor) minecraft.gameRenderer).invokeGetFov(cam, deltaTracker.getGameTimeDeltaPartialTick(true), true);
69+
minecraft.gameRenderer.resetProjectionMatrix(minecraft.gameRenderer.getProjectionMatrix(fov));
6970
worldRendererWaypoints.clear();
7071

7172
for (Waypoint waypoint : AxolotlClientWaypoints.getCurrentWaypoints()) {

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Changelog
22

3+
### 0.0.1-beta.17
4+
5+
- fix more somewhat fov-related bugs
6+
37
### 0.0.1-beta.16
48

59
- fix waypoints being rendered wrong on changed FoVs (<=1.21.1)

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ org.gradle.parallel=true
66
axolotlclient.modules.all=true
77

88
# Mod Properties
9-
version=0.0.1-beta.16+3.1.5
9+
version=0.0.1-beta.17+3.1.5
1010

1111
maven_group=io.github.axolotlclient.waypoints
1212

0 commit comments

Comments
 (0)