Skip to content

Commit 71b7262

Browse files
committed
fix gamescene bug
1 parent 99440f8 commit 71b7262

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

src/main/java/com/hfstudio/guidenh/guide/scene/LytGuidebookScene.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77
import java.util.Map;
88
import java.util.function.Consumer;
99

10-
import org.jetbrains.annotations.Nullable;
11-
1210
import net.minecraft.block.Block;
1311
import net.minecraft.client.Minecraft;
1412
import net.minecraft.client.gui.Gui;
1513
import net.minecraft.client.renderer.OpenGlHelper;
14+
import net.minecraft.client.renderer.RenderHelper;
1615
import net.minecraft.client.renderer.Tessellator;
1716
import net.minecraft.entity.Entity;
1817
import net.minecraft.init.Blocks;
@@ -21,6 +20,7 @@
2120
import net.minecraft.util.ResourceLocation;
2221
import net.minecraft.util.Vec3;
2322

23+
import org.jetbrains.annotations.Nullable;
2424
import org.joml.Vector3f;
2525
import org.lwjgl.input.Mouse;
2626
import org.lwjgl.opengl.GL11;
@@ -949,6 +949,7 @@ public void render(RenderContext context) {
949949
}
950950
}
951951

952+
restoreGuiRenderState();
952953
drawBottomControls(context, outerRect);
953954

954955
// Draw border AFTER the 3D content so border pixels always sit on top.
@@ -981,6 +982,23 @@ public static LytRect updateCachedRect(@Nullable LytRect current, int x, int y,
981982
return new LytRect(x, y, w, h);
982983
}
983984

985+
private static void restoreGuiRenderState() {
986+
// Scene overlays can temporarily change alpha/depth state. Restore the standard GUI state
987+
// before the document continues rendering blocks below this scene.
988+
GL11.glMatrixMode(GL11.GL_MODELVIEW);
989+
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
990+
GL11.glEnable(GL11.GL_TEXTURE_2D);
991+
GL11.glEnable(GL11.GL_BLEND);
992+
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
993+
GL11.glEnable(GL11.GL_ALPHA_TEST);
994+
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1f);
995+
GL11.glDisable(GL11.GL_LIGHTING);
996+
GL11.glDisable(GL11.GL_DEPTH_TEST);
997+
GL11.glDepthMask(true);
998+
GL11.glColor4f(1f, 1f, 1f, 1f);
999+
RenderHelper.disableStandardItemLighting();
1000+
}
1001+
9841002
private void drawSceneButtons(int drawX, int drawY, int w, int h, int absX, int absY) {
9851003
this.lastAbsX = absX;
9861004
this.lastAbsY = absY;

0 commit comments

Comments
 (0)