Skip to content

Commit

Permalink
fix gui cursor being offset
Browse files Browse the repository at this point in the history
bump to 1.2.3
  • Loading branch information
fayer3 committed Jan 13, 2025
1 parent dd6e5ef commit ed87708
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.mojang.math.Axis;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.LightTexture;
Expand Down Expand Up @@ -322,22 +323,13 @@ public static void drawMouseMenuQuad(PoseStack poseStack, int mouseX, int mouseY

float size = 15.0F * Math.max(ClientDataHolderVR.getInstance().vrSettings.menuCrosshairScale,
1.0F / (float) MC.getWindow().getGuiScale());
float halfSize = size * 0.5F;

int x = (int) (mouseX - size * 0.5F + 1);
int y = (int) (mouseY - size * 0.5F + 1);

RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderTexture(0, Gui.GUI_ICONS_LOCATION);

BufferBuilder bufferBuilder = Tesselator.getInstance().getBuilder();
bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
bufferBuilder.vertex(x - halfSize, y - halfSize, 0).uv(0, 0).endVertex();
bufferBuilder.vertex(x - halfSize, y + halfSize, 0).uv(0, 15F / 265F).endVertex();
bufferBuilder.vertex(x + halfSize, y + halfSize, 0).uv(15F / 265F, 15F / 265F).endVertex();
bufferBuilder.vertex(x + halfSize, y - halfSize, 0).uv(15F / 265F, 0).endVertex();
BufferUploader.drawWithShader(bufferBuilder.end());
GuiComponent.blit(poseStack, x, y, (int) size, (int) size, 0, 0, 15, 15, 256, 256);

RenderSystem.defaultBlendFunc();
RenderSystem.enableDepthTest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public static void renderAndSubmit(boolean renderLevel, long nanoTime, float act
MC.mouseHandler.ypos() * (double) MC.getWindow().getGuiScaledHeight() /
(double) MC.getWindow().getScreenHeight()
);
RenderHelper.drawMouseMenuQuad(poseStack, x, y);
RenderHelper.drawMouseMenuQuad(new PoseStack(), x, y);

poseStack.popPose();
RenderSystem.applyModelViewMatrix();
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ minecraft_version=1.19.4
enabled_platforms=fabric,forge

archives_base_name=vivecraft
mod_version=1.2.2
mod_version=1.2.3
maven_group=org.vivecraft

lwjgl_version=3.3.2
Expand Down

0 comments on commit ed87708

Please sign in to comment.