package net.minecraft.client.renderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.nio.FloatBuffer; import net.minecraft.util.Vec3; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class RenderHelper { /** Float buffer used to set OpenGL material colors */ private static FloatBuffer colorBuffer = GLAllocation.createDirectFloatBuffer(16); private static final Vec3 field_82884_b = Vec3.createVectorHelper(0.20000000298023224D, 1.0D, -0.699999988079071D).normalize(); private static final Vec3 field_82885_c = Vec3.createVectorHelper(-0.20000000298023224D, 1.0D, 0.699999988079071D).normalize(); private static final String __OBFID = "CL_00000629"; /** * Disables the OpenGL lighting properties enabled by enableStandardItemLighting */ public static void disableStandardItemLighting() { GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_LIGHT0); GL11.glDisable(GL11.GL_LIGHT1); GL11.glDisable(GL11.GL_COLOR_MATERIAL); } /** * Sets the OpenGL lighting properties to the values used when rendering blocks as items */ public static void enableStandardItemLighting() { GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); GL11.glEnable(GL11.GL_LIGHT1); GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glColorMaterial(GL11.GL_FRONT_AND_BACK, GL11.GL_AMBIENT_AND_DIFFUSE); float f = 0.4F; float f1 = 0.6F; float f2 = 0.0F; GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, setColorBuffer(field_82884_b.xCoord, field_82884_b.yCoord, field_82884_b.zCoord, 0.0D)); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, setColorBuffer(f1, f1, f1, 1.0F)); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F)); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, setColorBuffer(f2, f2, f2, 1.0F)); GL11.glLight(GL11.GL_LIGHT1, GL11.GL_POSITION, setColorBuffer(field_82885_c.xCoord, field_82885_c.yCoord, field_82885_c.zCoord, 0.0D)); GL11.glLight(GL11.GL_LIGHT1, GL11.GL_DIFFUSE, setColorBuffer(f1, f1, f1, 1.0F)); GL11.glLight(GL11.GL_LIGHT1, GL11.GL_AMBIENT, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F)); GL11.glLight(GL11.GL_LIGHT1, GL11.GL_SPECULAR, setColorBuffer(f2, f2, f2, 1.0F)); GL11.glShadeModel(GL11.GL_FLAT); GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, setColorBuffer(f, f, f, 1.0F)); } /** * Update and return colorBuffer with the RGBA values passed as arguments */ private static FloatBuffer setColorBuffer(double p_74517_0_, double p_74517_2_, double p_74517_4_, double p_74517_6_) { /** * Update and return colorBuffer with the RGBA values passed as arguments */ return setColorBuffer((float)p_74517_0_, (float)p_74517_2_, (float)p_74517_4_, (float)p_74517_6_); } /** * Update and return colorBuffer with the RGBA values passed as arguments */ private static FloatBuffer setColorBuffer(float p_74521_0_, float p_74521_1_, float p_74521_2_, float p_74521_3_) { colorBuffer.clear(); colorBuffer.put(p_74521_0_).put(p_74521_1_).put(p_74521_2_).put(p_74521_3_); colorBuffer.flip(); /** Float buffer used to set OpenGL material colors */ return colorBuffer; } /** * Sets OpenGL lighting for rendering blocks as items inside GUI screens (such as containers). */ public static void enableGUIStandardItemLighting() { GL11.glPushMatrix(); GL11.glRotatef(-30.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(165.0F, 1.0F, 0.0F, 0.0F); enableStandardItemLighting(); GL11.glPopMatrix(); } }