Skip to content

Commit

Permalink
Fix rotating the main camera (#7976)
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian Hartte <shartte@users.noreply.github.com>
  • Loading branch information
mysticdrew and shartte committed Jun 27, 2024
1 parent 9d1bcdd commit 450703b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/java/appeng/client/render/overlay/OverlayManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

import com.mojang.blaze3d.vertex.PoseStack;

import org.joml.Quaternionf;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource.BufferSource;
import net.minecraft.world.phys.Vec3;
Expand Down Expand Up @@ -52,14 +54,20 @@ public void renderWorldLastEvent(RenderLevelStageEvent event) {
return;
}

if (overlayHandlers.isEmpty()) {
return;
}

Minecraft minecraft = Minecraft.getInstance();
BufferSource buffer = minecraft.renderBuffers().bufferSource();
PoseStack poseStack = event.getPoseStack();

poseStack.pushPose();

Vec3 projectedView = minecraft.gameRenderer.getMainCamera().getPosition();
poseStack.mulPose(minecraft.gameRenderer.getMainCamera().rotation().invert());
Quaternionf rotation = new Quaternionf(minecraft.gameRenderer.getMainCamera().rotation());
rotation.invert();
poseStack.mulPose(rotation);
poseStack.translate(-projectedView.x, -projectedView.y, -projectedView.z);

for (var handler : overlayHandlers.entrySet().stream()
Expand Down

0 comments on commit 450703b

Please sign in to comment.