Skip to content

Commit

Permalink
Merge pull request #52 from r8420/50-1-19-3-Render-issue-faboulous
Browse files Browse the repository at this point in the history
[1.19.3] Bugfix for fabulous! render issue
  • Loading branch information
r8420 authored Jan 19, 2023
2 parents e769b03 + 4ff6ea5 commit ce74a60
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import at.ridgo8.moreoverlays.MoreOverlays;
import at.ridgo8.moreoverlays.config.Config;
import at.ridgo8.moreoverlays.lightoverlay.LightOverlayHandler;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
import org.joml.Matrix4f;
Expand All @@ -11,6 +12,7 @@
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import org.joml.Quaternionf;

import static net.minecraft.client.CameraType.THIRD_PERSON_FRONT;

Expand All @@ -31,13 +33,21 @@ public static void renderOverlays(PoseStack matrixstack) {
RenderSystem.lineWidth((float) (double) Config.render_chunkLineWidth.get());
RenderSystem.setShader(GameRenderer::getPositionColorShader);

Quaternionf cameraRotation = Minecraft.getInstance().gameRenderer.getMainCamera().rotation();

if (Minecraft.getInstance().options.graphicsMode().get() != GraphicsStatus.FABULOUS) {
// Use old renderer
RenderSystem.depthMask(false);
RenderSystem.enableCull();
} else {
// Use new renderer
matrixstack.pushPose();

// Rotate yaw by 180 degrees.
cameraRotation.rotateY((float) Math.toRadians(180 % 360));
Matrix4f translateMatrix = new Matrix4f().rotation(cameraRotation);

matrixstack.mulPoseMatrix(translateMatrix);
}


Expand Down Expand Up @@ -116,6 +126,14 @@ public static void renderOverlays(PoseStack matrixstack) {
RenderSystem.lineWidth(1.0F);
RenderSystem.enableBlend();

if(!LightOverlayHandler.isEnabled()) {
// Rotate yaw by 180 degrees.
cameraRotation.rotateY((float) Math.toRadians(-180 % 360));
Matrix4f translateMatrix = new Matrix4f().rotation(cameraRotation);

matrixstack.mulPoseMatrix(translateMatrix);
}

matrixstack.popPose();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import at.ridgo8.moreoverlays.MoreOverlays;
import at.ridgo8.moreoverlays.api.lightoverlay.ILightRenderer;
import at.ridgo8.moreoverlays.api.lightoverlay.ILightScanner;
import at.ridgo8.moreoverlays.chunkbounds.ChunkBoundsHandler;
import at.ridgo8.moreoverlays.config.Config;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
Expand All @@ -17,6 +18,8 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.BlockPos;
import org.apache.commons.lang3.tuple.Pair;
import org.joml.Quaternionf;

import static net.minecraft.client.CameraType.THIRD_PERSON_FRONT;


Expand Down Expand Up @@ -95,13 +98,23 @@ public void renderOverlays(ILightScanner scanner, PoseStack matrixstack) {
RenderSystem.lineWidth((float) (double) Config.render_chunkLineWidth.get());
RenderSystem.setShader(GameRenderer::getPositionColorShader);

Quaternionf cameraRotation = Minecraft.getInstance().gameRenderer.getMainCamera().rotation();

if (Minecraft.getInstance().options.graphicsMode().get() != GraphicsStatus.FABULOUS) {
// Use old renderer
RenderSystem.depthMask(false);
RenderSystem.enableCull();
} else {
// Use new renderer
matrixstack.pushPose();

// Only rotate when pose is not already rotated by ChunkBoundsRenderer
if(ChunkBoundsHandler.getMode() == ChunkBoundsHandler.RenderMode.NONE) {
// Rotate yaw by 180 degrees.
cameraRotation.rotateY((float) Math.toRadians(180 % 360));
}
Matrix4f translateMatrix = new Matrix4f().rotation(cameraRotation);
matrixstack.mulPoseMatrix(translateMatrix);
}

float ar = ((float) ((Config.render_spawnAColor.get() >> 16) & 0xFF)) / 255F;
Expand Down Expand Up @@ -132,6 +145,14 @@ else if (mode == 2)
RenderSystem.lineWidth(1.0F);
RenderSystem.enableBlend();

// Only rotate when pose is not already rotated by ChunkBoundsRenderer
if(ChunkBoundsHandler.getMode() == ChunkBoundsHandler.RenderMode.NONE) {
// Rotate yaw by 180 degrees.
cameraRotation.rotateY((float) Math.toRadians(-180 % 360));
}
Matrix4f translateMatrix = new Matrix4f().rotation(cameraRotation);
matrixstack.mulPoseMatrix(translateMatrix);

matrixstack.popPose();
}
}
Expand Down

0 comments on commit ce74a60

Please sign in to comment.