From 84ef6c23bbfa9f3d4905059f6a5d69518002b14d Mon Sep 17 00:00:00 2001 From: Brandon Garvin Date: Thu, 5 Feb 2026 00:16:28 -0900 Subject: [PATCH 1/2] setup render state before rendering vbo --- src/main/java/cam72cam/mod/render/opengl/VBO.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/cam72cam/mod/render/opengl/VBO.java b/src/main/java/cam72cam/mod/render/opengl/VBO.java index d80456b4..a242d1c0 100644 --- a/src/main/java/cam72cam/mod/render/opengl/VBO.java +++ b/src/main/java/cam72cam/mod/render/opengl/VBO.java @@ -10,7 +10,9 @@ import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.VertexFormatElement; import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.ShaderInstance; +import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.resources.ResourceLocation; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL32; @@ -189,6 +191,8 @@ protected Binding(RenderState state, boolean wait) { shader = GameRenderer.getRendertypeEntityCutoutShader(); } RenderSystem.setShader(() -> shader); + + RenderType.entityCutout(TextureAtlas.LOCATION_BLOCKS).setupRenderState(); GL32.glBindVertexArray(vao); GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, vbo); @@ -247,6 +251,8 @@ protected Binding(RenderState state, boolean wait) { this.restore = RenderContext.apply(state, true).and(() -> { RenderContext.checkError(); + + RenderType.entityCutout(TextureAtlas.LOCATION_BLOCKS).clearRenderState(); shader.getVertexFormat().clearBufferState(); RenderContext.checkError(); From 7bc33f26d433e5342174a60cc15d6509addc949c Mon Sep 17 00:00:00 2001 From: Brandon Garvin Date: Thu, 5 Feb 2026 00:41:38 -0900 Subject: [PATCH 2/2] cleanup: handle non-cutout render types --- .../java/cam72cam/mod/render/opengl/VBO.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/cam72cam/mod/render/opengl/VBO.java b/src/main/java/cam72cam/mod/render/opengl/VBO.java index a242d1c0..6f852b5b 100644 --- a/src/main/java/cam72cam/mod/render/opengl/VBO.java +++ b/src/main/java/cam72cam/mod/render/opengl/VBO.java @@ -12,8 +12,8 @@ import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.ShaderInstance; -import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.inventory.InventoryMenu; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL32; @@ -177,6 +177,8 @@ protected Binding(RenderState state, boolean wait) { } else { GL32.glDisableClientState(GL32.GL_NORMAL_ARRAY); }*/ + + RenderType renderType; ShaderInstance shader; if (state.stage != null) { shader = switch (state.stage) { @@ -187,12 +189,22 @@ protected Binding(RenderState state, boolean wait) { ? GameRenderer.getRendertypeEntityCutoutShader() : RenderContext.UMC_CORE; }; + + renderType = switch (state.stage) { + case GUI -> null; + default -> RenderType.entityCutout(InventoryMenu.BLOCK_ATLAS); + }; } else { shader = GameRenderer.getRendertypeEntityCutoutShader(); + renderType = RenderType.entityCutout(InventoryMenu.BLOCK_ATLAS); + } + + if (renderType != null) { + renderType.setupRenderState(); } + RenderSystem.setShader(() -> shader); - RenderType.entityCutout(TextureAtlas.LOCATION_BLOCKS).setupRenderState(); GL32.glBindVertexArray(vao); GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, vbo); @@ -252,7 +264,10 @@ protected Binding(RenderState state, boolean wait) { this.restore = RenderContext.apply(state, true).and(() -> { RenderContext.checkError(); - RenderType.entityCutout(TextureAtlas.LOCATION_BLOCKS).clearRenderState(); + if (renderType != null) { + renderType.clearRenderState(); + } + shader.getVertexFormat().clearBufferState(); RenderContext.checkError();