Skip to content

Commit 2fb1e58

Browse files
committed
fix gui bugs
(1.8.9) fix waypoint rendering more
1 parent 99b45e0 commit 2fb1e58

File tree

9 files changed

+41
-19
lines changed

9 files changed

+41
-19
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ private void renderWaypoint(Waypoint waypoint, PoseStack stack, Vec3 camPos, Cam
104104
private void fillRect(PoseStack stack, MultiBufferSource.BufferSource source, float x, float y, float z, float x2, float y2, int color) {
105105
var buf = source.getBuffer(RenderType.gui());
106106
var matrix = stack.last().pose();
107-
buf.vertex(matrix, x, y, z).color(color).uv2(0xF000F0).endVertex();
108-
buf.vertex(matrix, x, y2, z).color(color).uv2(0xF000F0).endVertex();
109-
buf.vertex(matrix, x2, y2, z).color(color).uv2(0xF000F0).endVertex();
110-
buf.vertex(matrix, x2, y, z).color(color).uv2(0xF000F0).endVertex();
107+
buf.vertex(matrix, x, y, z).color(color).endVertex();
108+
buf.vertex(matrix, x, y2, z).color(color).endVertex();
109+
buf.vertex(matrix, x2, y2, z).color(color).endVertex();
110+
buf.vertex(matrix, x2, y, z).color(color).endVertex();
111111
source.endBatch();
112112
}
113113

1.20/src/main/java/io/github/axolotlclient/waypoints/waypoints/gui/WaypointsScreen.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ protected void init() {
7474

7575
@Override
7676
public void onClose() {
77+
AxolotlClientWaypoints.WAYPOINT_STORAGE.save();
7778
minecraft.setScreen(parent);
7879
}
7980

@@ -157,8 +158,8 @@ public void updateSize(int width, HeaderAndFooterLayout layout) {
157158
}
158159

159160
@Override
160-
protected void renderList(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
161-
super.renderList(guiGraphics, mouseX, mouseY, partialTick);
161+
protected int getScrollbarPosition() {
162+
return getRowRight()+10;
162163
}
163164

164165
private class Entry extends ContainerObjectSelectionList.Entry<Entry> {

1.21.8/src/main/java/io/github/axolotlclient/waypoints/waypoints/gui/WaypointsScreen.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ protected void init() {
7777

7878
@Override
7979
public void onClose() {
80+
AxolotlClientWaypoints.WAYPOINT_STORAGE.save();
8081
minecraft.setScreen(parent);
8182
}
8283

1.21/src/main/java/io/github/axolotlclient/waypoints/waypoints/gui/WaypointsScreen.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ protected void init() {
7777

7878
@Override
7979
public void onClose() {
80+
AxolotlClientWaypoints.WAYPOINT_STORAGE.save();
8081
minecraft.setScreen(parent);
8182
}
8283

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@
3333
import com.mojang.blaze3d.vertex.Tessellator;
3434
import io.github.axolotlclient.AxolotlClientConfig.api.util.Colors;
3535
import io.github.axolotlclient.AxolotlClientConfig.impl.util.DrawUtil;
36+
import io.github.axolotlclient.modules.freelook.Perspective;
3637
import io.github.axolotlclient.waypoints.AxolotlClientWaypoints;
3738
import io.github.axolotlclient.waypoints.mixin.GameRendererAccessor;
3839
import net.minecraft.client.Minecraft;
3940
import net.minecraft.client.gui.GuiElement;
41+
import net.minecraft.client.render.Camera;
4042
import net.minecraft.client.render.Window;
4143
import net.minecraft.entity.Entity;
4244
import 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);

1.8.9/src/main/java/io/github/axolotlclient/waypoints/waypoints/gui/EditWaypointScreen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public void drawWidget(int mouseX, int mouseY, float partialTick) {
161161

162162
int footerY = height - 33 / 2 - 20 / 2;
163163
save = addDrawableChild(new VanillaButtonWidget(width / 2 - 2 - 150, footerY, 150, 20, I18n.translate("gui.done"), btn -> {
164-
AxolotlClientWaypoints.WAYPOINT_STORAGE.create(new Waypoint(dimension.getText(), this.x, this.y, this.z, color.getOriginal(), name.getText(), display.getText()));
164+
AxolotlClientWaypoints.WAYPOINT_STORAGE.replace(toEdit, new Waypoint(dimension.getText(), this.x, this.y, this.z, color.getOriginal(), name.getText(), display.getText()));
165165
minecraft.openScreen(parent);
166166
}));
167167
addDrawableChild(new VanillaButtonWidget(width / 2 + 20, footerY, 150, 20, I18n.translate("gui.cancel"), btn -> minecraft.openScreen(parent)));

1.8.9/src/main/java/io/github/axolotlclient/waypoints/waypoints/gui/WaypointsScreen.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ public void onClose() {
6767
minecraft.openScreen(parent);
6868
}
6969

70+
@Override
71+
public void removed() {
72+
AxolotlClientWaypoints.WAYPOINT_STORAGE.save();
73+
}
74+
7075
@Override
7176
public void render(int mouseX, int mouseY, float delta) {
7277
super.render(mouseX, mouseY, delta);
@@ -99,6 +104,11 @@ public int getRowWidth() {
99104
return 300;
100105
}
101106

107+
@Override
108+
protected int getScrollbarPositionX() {
109+
return getRowRight()+10;
110+
}
111+
102112
private class Entry extends ElementListWidget.Entry<Entry> {
103113

104114
private final List<ClickableWidget> children = new ArrayList<>();

CHANGELOG.md

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

3+
### 0.0.1-beta.19
4+
5+
- fix some gui bugs
6+
- (1.8.9) fix more waypoint rendering bugs
7+
38
### 0.0.1-beta.18
49

510
- (1.8.9) fix waypoint name display positioning

gradle.properties

Lines changed: 2 additions & 2 deletions
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.18+3.1.5
9+
version=0.0.1-beta.19+3.1.5
1010

1111
maven_group=io.github.axolotlclient.waypoints
1212

@@ -18,5 +18,5 @@ osl=0.16.3
1818

1919
legacy_lwgjl3=1.2.9+1.8.9
2020

21-
config=3.0.19-beta.1
21+
config=3.0.19
2222
axolotlclient=3.1.5

0 commit comments

Comments
 (0)