    001    package net.minecraft.client.renderer.entity;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import net.minecraft.block.Block;
    006    import net.minecraft.client.model.ModelIronGolem;
    007    import net.minecraft.client.renderer.OpenGlHelper;
    008    import net.minecraft.entity.Entity;
    009    import net.minecraft.entity.EntityLiving;
    010    import net.minecraft.entity.monster.EntityIronGolem;
    011    import org.lwjgl.opengl.GL11;
    012    import org.lwjgl.opengl.GL12;
    013
    014    @SideOnly(Side.CLIENT)
    015    public 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.legYaw >= 0.01D)
    042            {
    043                float var5 = 13.0F;
    044                float var6 = par1EntityIronGolem.legSwing - par1EntityIronGolem.legYaw * (1.0F - par4) + 6.0F;
    045                float var7 = (Math.abs(var6 % var5 - var5 * 0.5F) - var5 * 0.25F) / (var5 * 0.25F);
    046                GL11.glRotatef(6.5F * var7, 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 var3 = 0.8F;
    065                GL11.glScalef(var3, -var3, var3);
    066                int var4 = par1EntityIronGolem.getBrightnessForRender(par2);
    067                int var5 = var4 % 65536;
    068                int var6 = var4 / 65536;
    069                OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)var5 / 1.0F, (float)var6 / 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    }