Skip to content

Commit

Permalink
[1.20.4] Fix GUI far plane calculation to match vanilla (#507)
Browse files Browse the repository at this point in the history
  • Loading branch information
XFactHD authored Jan 16, 2024
1 parent ce7e8de commit 39661d9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
posestack.pushPose();
posestack.setIdentity();
- posestack.translate(0.0F, 0.0F, -11000.0F);
+ posestack.translate(0.0D, 0.0D, 1000F - net.neoforged.neoforge.client.ClientHooks.getGuiFarPlane());
+ posestack.translate(0.0D, 0.0D, 10000F - net.neoforged.neoforge.client.ClientHooks.getGuiFarPlane());
RenderSystem.applyModelViewMatrix();
Lighting.setupFor3DItems();
GuiGraphics guigraphics = new GuiGraphics(this.minecraft, this.renderBuffers.bufferSource());
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/neoforged/neoforge/client/ClientHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@ public static void popGuiLayer(Minecraft minecraft) {
}

public static float getGuiFarPlane() {
// 1000 units for the overlay background,
// 11000 units for the overlay background,
// and 10000 units for each layered Screen,

return 1000.0F + 10000.0F * (1 + guiLayers.size());
return 11000.0F + 10000.0F * (1 + guiLayers.size());
}

public static String getArmorTexture(Entity entity, ItemStack armor, String _default, EquipmentSlot slot, String type) {
Expand Down Expand Up @@ -376,7 +376,7 @@ public static void drawScreen(Screen screen, GuiGraphics guiGraphics, int mouseX
guiLayers.forEach(layer -> {
// Prevent the background layers from thinking the mouse is over their controls and showing them as highlighted.
drawScreenInternal(layer, guiGraphics, Integer.MAX_VALUE, Integer.MAX_VALUE, partialTick);
guiGraphics.pose().translate(0, 0, 2000);
guiGraphics.pose().translate(0, 0, 10000);
});
drawScreenInternal(screen, guiGraphics, mouseX, mouseY, partialTick);
guiGraphics.pose().popPose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ protected TestLayer(Component titleIn) {
}

@Override
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
this.renderTransparentBackground(graphics);
public void renderBackground(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
super.renderBackground(graphics, mouseX, mouseY, partialTicks);
graphics.drawString(this.font, this.title, this.width / 2, 15, 0xFFFFFF);
super.render(graphics, mouseX, mouseY, partialTicks);
}

@Override
Expand Down

0 comments on commit 39661d9

Please sign in to comment.