package hmggirlfront.render.tile;


import java.awt.Color;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

import gvclib.mod_GVCLib;
import hmggirlfront.block.tile.TileEntityM_Supplies;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.BlockSand;
import net.minecraft.block.BlockStone;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import objmodel.AdvancedModelLoader;
import objmodel.IModelCustom;

@SideOnly(Side.CLIENT)
public class TileRender_M_Supplies extends TileEntitySpecialRenderer<TileEntityM_Supplies>
{
    
    private static final ResourceLocation tex0 = new ResourceLocation("hmggirlfront:textures/blocks/model/supplies.png");
    private static final IModelCustom model0 = AdvancedModelLoader.loadModel(new ResourceLocation("hmggirlfront:textures/blocks/model/supplies.mqo"));
    
    
    private ResourceLocation texture;

    public TileRender_M_Supplies()
    {
    }

    public void render(TileEntityM_Supplies te, double x, double y, double z, float partialTicks, int destroyStage, float alpha)
    {
    	Minecraft minecraft = Minecraft.getMinecraft();
    	
        GL11.glPushMatrix();
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        GL11.glTranslatef((float)x + 0.5F, (float)y + 0F, (float)z + 0.5F);
        GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
        
        if(te.facing == 1) {
        	GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
        }
        else  if(te.facing == 2) {
        	GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
        }
        else  if(te.facing == 3) {
        	GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
        }
        else {
        	//GL11.glRotatef(0.0F, 0.0F, 1.0F, 0.0F);
        }
        
        {
			GL11.glEnable(GL12.GL_RESCALE_NORMAL);
			{
				if(!te.can_view) {
					GlStateManager.depthFunc(519);
					GlStateManager.disableFog();
					RenderHelper.disableStandardItemLighting();
					
					GlStateManager.enableColorMaterial();
					// GlStateManager.enableOutlineMode(this.getTeamColor(entity));//16777215
					GlStateManager.enableOutlineMode(Color.YELLOW.getRGB());// 16777215
					//RenderHelper.disableStandardItemLighting();
				}
				this.bindTexture(tex0);
				model0.renderPart("mat1");
				if(!te.can_view) {
					GlStateManager.disableOutlineMode();
					GlStateManager.disableColorMaterial();
					
					RenderHelper.enableStandardItemLighting();
					GlStateManager.depthMask(false);
					GlStateManager.enableLighting();
					GlStateManager.depthMask(true);
					GlStateManager.enableFog();
					GlStateManager.enableBlend();
					GlStateManager.enableColorMaterial();
					GlStateManager.depthFunc(515);
					GlStateManager.enableDepth();
					GlStateManager.enableAlpha();
				}
			}
			GL11.glDisable(GL12.GL_RESCALE_NORMAL);
		}
        
        
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        GL11.glPopMatrix();
        
    }
}