Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix chest flickering when a barrel is in sight #33

Merged
merged 2 commits into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package mcp.mobius.betterbarrels.client.render;

import java.nio.FloatBuffer;

import net.minecraft.client.renderer.GLAllocation;

import org.lwjgl.opengl.GL11;

/**
* RenderHelper but no directional light setting
*/
public class SurfaceItemRenderHelper {

private static final FloatBuffer ambientColorBuffer = (FloatBuffer) GLAllocation.createDirectFloatBuffer(16)
.put(0.4f).put(0.4f).put(0.4f).put(1.0f).flip();
private static final FloatBuffer cachedAmbientColor = GLAllocation.createDirectFloatBuffer(16);

public static void disableStandardItemLighting() {
GL11.glDisable(GL11.GL_COLOR_MATERIAL);
GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, cachedAmbientColor);
}

public static void enableStandardItemLighting() {
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
GL11.glColorMaterial(GL11.GL_FRONT_AND_BACK, GL11.GL_AMBIENT_AND_DIFFUSE);
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glGetFloat(GL11.GL_LIGHT_MODEL_AMBIENT, cachedAmbientColor);
GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, ambientColorBuffer);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.texture.TextureManager;
Expand Down Expand Up @@ -142,7 +141,7 @@ private void renderGlint(int x, int y, int w, int h) {

private void renderItemIntoGUIBlock(FontRenderer fontRenderer, TextureManager texManager, ItemStack itemStack,
int x, int y, boolean renderEffect) {
RenderHelper.enableGUIStandardItemLighting();
SurfaceItemRenderHelper.enableStandardItemLighting();
GL11.glDisable(GL11.GL_LIGHTING);

texManager.bindTexture(TextureMap.locationBlocksTexture);
Expand Down Expand Up @@ -186,6 +185,6 @@ private void renderItemIntoGUIBlock(FontRenderer fontRenderer, TextureManager te

GL11.glPopMatrix();

RenderHelper.disableStandardItemLighting();
SurfaceItemRenderHelper.disableStandardItemLighting();
}
}
Loading