package net.minecraft.client.renderer.entity;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.model.ModelSnowMan;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntitySnowman;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import net.minecraftforge.client.IItemRenderer;
import static net.minecraftforge.client.IItemRenderer.ItemRenderType.*;
import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.*;
import net.minecraftforge.client.MinecraftForgeClient;

@SideOnly(Side.CLIENT)
public class RenderSnowMan extends RenderLiving
{
	private static final ResourceLocation snowManTextures = new ResourceLocation("textures/entity/snowman.png");
	private ModelSnowMan snowmanModel;
	private static final String __OBFID = "CL_00001025";

	public RenderSnowMan()
	{
		super(new ModelSnowMan(), 0.5F);
		this.snowmanModel = (ModelSnowMan)super.mainModel;
		this.setRenderPassModel(this.snowmanModel);
	}

	protected void renderEquippedItems(EntitySnowman par1EntitySnowman, float par2)
	{
		super.renderEquippedItems(par1EntitySnowman, par2);
		ItemStack itemstack = new ItemStack(Blocks.pumpkin, 1);

		if (itemstack.getItem() instanceof ItemBlock)
		{
			GL11.glPushMatrix();
			this.snowmanModel.head.postRender(0.0625F);

			IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack, EQUIPPED);
			boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack, BLOCK_3D));

			if (is3D || RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack.getItem()).getRenderType()))
			{
				float f1 = 0.625F;
				GL11.glTranslatef(0.0F, -0.34375F, 0.0F);
				GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
				GL11.glScalef(f1, -f1, f1);
			}

			this.renderManager.itemRenderer.renderItem(par1EntitySnowman, itemstack, 0);
			GL11.glPopMatrix();
		}
	}

	protected ResourceLocation getEntityTexture(EntitySnowman par1EntitySnowman)
	{
		return snowManTextures;
	}

	protected void renderEquippedItems(EntityLivingBase par1EntityLivingBase, float par2)
	{
		this.renderEquippedItems((EntitySnowman)par1EntityLivingBase, par2);
	}

	protected ResourceLocation getEntityTexture(Entity par1Entity)
	{
		return this.getEntityTexture((EntitySnowman)par1Entity);
	}
}