Skip to content

Commit

Permalink
fix: topLayer tooltips background rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Dec 8, 2023
1 parent 675e83c commit a8c4043
Showing 1 changed file with 27 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package org.violetmoon.zeta.client;

import com.mojang.blaze3d.platform.Window;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexSorting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import org.joml.Matrix4f;
import org.violetmoon.zeta.client.event.play.ZRenderTick;
import org.violetmoon.zeta.event.bus.PlayEvent;

Expand All @@ -23,25 +27,36 @@ public void renderTick(ZRenderTick event) {
Minecraft mc = Minecraft.getInstance();
Screen screen = mc.screen;

Window window = mc.getWindow();
Matrix4f projectionMatrix = RenderSystem.getProjectionMatrix();
VertexSorting vertexSorting = RenderSystem.getVertexSorting();

//fixme & make sure this works, if not replace event with ZEarlyRender - IThundxr
// -------------------------- Cursed Code!!! --------------------------
// fixme: Switch to a different event called earlier inside of Minecraft#runTick
// Matrix4f matrix4f = (new Matrix4f()).setOrtho(0.0F, (float)((double) window.getWidth() / window.getGuiScale()), (float)((double) window.getHeight() / window.getGuiScale()), 0.0F, 1000.0F, net.minecraftforge.client.ForgeHooksClient.getGuiFarPlane());
// RenderSystem.setProjectionMatrix(matrix4f, VertexSorting.ORTHOGRAPHIC_Z);
// PoseStack posestack = RenderSystem.getModelViewStack();
// posestack.pushPose();
// posestack.setIdentity();
// posestack.translate(0.0D, 0.0D, 1000F - net.minecraftforge.client.ForgeHooksClient.getGuiFarPlane());
// RenderSystem.applyModelViewMatrix();
// --------------------------------------------------------------------
// Set correct projection matrix
Window window = mc.getWindow();
Matrix4f matrix4f = new Matrix4f().setOrtho(
0.0F,
(float) ((double) window.getWidth() / window.getGuiScale()),
(float) ((double) window.getHeight() / window.getGuiScale()),
0.0F,
1000.0F,
net.minecraftforge.client.ForgeHooksClient.getGuiFarPlane()
);
RenderSystem.setProjectionMatrix(matrix4f, VertexSorting.ORTHOGRAPHIC_Z);
PoseStack posestack = RenderSystem.getModelViewStack();
posestack.pushPose();
posestack.setIdentity();
posestack.translate(0.0D, 0.0D, 1000F - net.minecraftforge.client.ForgeHooksClient.getGuiFarPlane());
RenderSystem.applyModelViewMatrix();
// End

GuiGraphics guiGraphics = new GuiGraphics(mc, mc.renderBuffers().bufferSource());

if(screen != null)
guiGraphics.renderTooltip(mc.font, tooltip, Optional.empty(), tooltipX, tooltipY);

// Reset projection matrix
RenderSystem.setProjectionMatrix(projectionMatrix, vertexSorting);
// End

tooltip = null;
}
}
Expand Down

0 comments on commit a8c4043

Please sign in to comment.