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.ModelIronGolem;
007import net.minecraft.client.renderer.OpenGlHelper;
008import net.minecraft.entity.Entity;
009import net.minecraft.entity.EntityLiving;
010import net.minecraft.entity.monster.EntityIronGolem;
011import org.lwjgl.opengl.GL11;
012import org.lwjgl.opengl.GL12;
013
014@SideOnly(Side.CLIENT)
015public class RenderIronGolem extends RenderLiving
016{
017    /** Iron Golem's Model. */
018    private ModelIronGolem ironGolemModel;
019
020    public RenderIronGolem()
021    {
022        super(new ModelIronGolem(), 0.5F);
023        this.ironGolemModel = (ModelIronGolem)this.mainModel;
024    }
025
026    /**
027     * Renders the Iron Golem.
028     */
029    public void doRenderIronGolem(EntityIronGolem par1EntityIronGolem, double par2, double par4, double par6, float par8, float par9)
030    {
031        super.doRenderLiving(par1EntityIronGolem, par2, par4, par6, par8, par9);
032    }
033
034    /**
035     * Rotates Iron Golem corpse.
036     */
037    protected void rotateIronGolemCorpse(EntityIronGolem par1EntityIronGolem, float par2, float par3, float par4)
038    {
039        super.rotateCorpse(par1EntityIronGolem, par2, par3, par4);
040
041        if ((double)par1EntityIronGolem.limbYaw >= 0.01D)
042        {
043            float f3 = 13.0F;
044            float f4 = par1EntityIronGolem.limbSwing - par1EntityIronGolem.limbYaw * (1.0F - par4) + 6.0F;
045            float f5 = (Math.abs(f4 % f3 - f3 * 0.5F) - f3 * 0.25F) / (f3 * 0.25F);
046            GL11.glRotatef(6.5F * f5, 0.0F, 0.0F, 1.0F);
047        }
048    }
049
050    /**
051     * Renders Iron Golem Equipped items.
052     */
053    protected void renderIronGolemEquippedItems(EntityIronGolem par1EntityIronGolem, float par2)
054    {
055        super.renderEquippedItems(par1EntityIronGolem, par2);
056
057        if (par1EntityIronGolem.getHoldRoseTick() != 0)
058        {
059            GL11.glEnable(GL12.GL_RESCALE_NORMAL);
060            GL11.glPushMatrix();
061            GL11.glRotatef(5.0F + 180.0F * this.ironGolemModel.ironGolemRightArm.rotateAngleX / (float)Math.PI, 1.0F, 0.0F, 0.0F);
062            GL11.glTranslatef(-0.6875F, 1.25F, -0.9375F);
063            GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
064            float f1 = 0.8F;
065            GL11.glScalef(f1, -f1, f1);
066            int i = par1EntityIronGolem.getBrightnessForRender(par2);
067            int j = i % 65536;
068            int k = i / 65536;
069            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F);
070            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
071            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
072            this.loadTexture("/terrain.png");
073            this.renderBlocks.renderBlockAsItem(Block.plantRed, 0, 1.0F);
074            GL11.glPopMatrix();
075            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
076        }
077    }
078
079    protected void renderEquippedItems(EntityLiving par1EntityLiving, float par2)
080    {
081        this.renderIronGolemEquippedItems((EntityIronGolem)par1EntityLiving, par2);
082    }
083
084    protected void rotateCorpse(EntityLiving par1EntityLiving, float par2, float par3, float par4)
085    {
086        this.rotateIronGolemCorpse((EntityIronGolem)par1EntityLiving, par2, par3, par4);
087    }
088
089    public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9)
090    {
091        this.doRenderIronGolem((EntityIronGolem)par1EntityLiving, par2, par4, par6, par8, par9);
092    }
093
094    /**
095     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
096     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
097     * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
098     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
099     */
100    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
101    {
102        this.doRenderIronGolem((EntityIronGolem)par1Entity, par2, par4, par6, par8, par9);
103    }
104}