    001package net.minecraft.client.renderer.entity;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import net.minecraft.block.Block;
    006import net.minecraft.client.model.ModelSnowMan;
    007import net.minecraft.client.renderer.RenderBlocks;
    008import net.minecraft.entity.EntityLiving;
    009import net.minecraft.entity.monster.EntitySnowman;
    010import net.minecraft.item.ItemBlock;
    011import net.minecraft.item.ItemStack;
    012import org.lwjgl.opengl.GL11;
    013
    014import net.minecraftforge.client.IItemRenderer;
    015import static net.minecraftforge.client.IItemRenderer.ItemRenderType.*;
    016import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.*;
    017import net.minecraftforge.client.MinecraftForgeClient;
    018
    019@SideOnly(Side.CLIENT)
    020public class RenderSnowMan extends RenderLiving
    021{
    022    /** A reference to the Snowman model in RenderSnowMan. */
    023    private ModelSnowMan snowmanModel;
    024
    025    public RenderSnowMan()
    026    {
    027        super(new ModelSnowMan(), 0.5F);
    028        this.snowmanModel = (ModelSnowMan)super.mainModel;
    029        this.setRenderPassModel(this.snowmanModel);
    030    }
    031
    032    /**
    033     * Renders this snowman's pumpkin.
    034     */
    035    protected void renderSnowmanPumpkin(EntitySnowman par1EntitySnowman, float par2)
    036    {
    037        super.renderEquippedItems(par1EntitySnowman, par2);
    038        ItemStack itemstack = new ItemStack(Block.pumpkin, 1);
    039
    040        if (itemstack != null && itemstack.getItem() instanceof ItemBlock)
    041        {
    042            GL11.glPushMatrix();
    043            this.snowmanModel.head.postRender(0.0625F);
    044
    045            IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack, EQUIPPED);
    046            boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack, BLOCK_3D));
    047
    048            if (is3D || RenderBlocks.renderItemIn3d(Block.blocksList[itemstack.itemID].getRenderType()))
    049            {
    050                float f1 = 0.625F;
    051                GL11.glTranslatef(0.0F, -0.34375F, 0.0F);
    052                GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
    053                GL11.glScalef(f1, -f1, f1);
    054            }
    055
    056            this.renderManager.itemRenderer.renderItem(par1EntitySnowman, itemstack, 0);
    057            GL11.glPopMatrix();
    058        }
    059    }
    060
    061    protected void renderEquippedItems(EntityLiving par1EntityLiving, float par2)
    062    {
    063        this.renderSnowmanPumpkin((EntitySnowman)par1EntityLiving, par2);
    064    }
    065}