    001package net.minecraft.client.renderer.entity;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import net.minecraft.client.model.ModelBat;
    006import net.minecraft.entity.Entity;
    007import net.minecraft.entity.EntityLiving;
    008import net.minecraft.entity.passive.EntityBat;
    009import net.minecraft.util.MathHelper;
    010import org.lwjgl.opengl.GL11;
    011
    012@SideOnly(Side.CLIENT)
    013public class RenderBat extends RenderLiving
    014{
    015    /**
    016     * not actually sure this is size, is not used as of now, but the model would be recreated if the value changed and
    017     * it seems a good match for a bats size
    018     */
    019    private int renderedBatSize;
    020
    021    public RenderBat()
    022    {
    023        super(new ModelBat(), 0.25F);
    024        this.renderedBatSize = ((ModelBat)this.mainModel).getBatSize();
    025    }
    026
    027    public void func_82443_a(EntityBat par1EntityBat, double par2, double par4, double par6, float par8, float par9)
    028    {
    029        int var10 = ((ModelBat)this.mainModel).getBatSize();
    030
    031        if (var10 != this.renderedBatSize)
    032        {
    033            this.renderedBatSize = var10;
    034            this.mainModel = new ModelBat();
    035        }
    036
    037        super.doRenderLiving(par1EntityBat, par2, par4, par6, par8, par9);
    038    }
    039
    040    protected void func_82442_a(EntityBat par1EntityBat, float par2)
    041    {
    042        GL11.glScalef(0.35F, 0.35F, 0.35F);
    043    }
    044
    045    protected void func_82445_a(EntityBat par1EntityBat, double par2, double par4, double par6)
    046    {
    047        super.renderLivingAt(par1EntityBat, par2, par4, par6);
    048    }
    049
    050    protected void func_82444_a(EntityBat par1EntityBat, float par2, float par3, float par4)
    051    {
    052        if (!par1EntityBat.getIsBatHanging())
    053        {
    054            GL11.glTranslatef(0.0F, MathHelper.cos(par2 * 0.3F) * 0.1F, 0.0F);
    055        }
    056        else
    057        {
    058            GL11.glTranslatef(0.0F, -0.1F, 0.0F);
    059        }
    060
    061        super.rotateCorpse(par1EntityBat, par2, par3, par4);
    062    }
    063
    064    /**
    065     * Allows the render to do any OpenGL state modifications necessary before the model is rendered. Args:
    066     * entityLiving, partialTickTime
    067     */
    068    protected void preRenderCallback(EntityLiving par1EntityLiving, float par2)
    069    {
    070        this.func_82442_a((EntityBat)par1EntityLiving, par2);
    071    }
    072
    073    protected void rotateCorpse(EntityLiving par1EntityLiving, float par2, float par3, float par4)
    074    {
    075        this.func_82444_a((EntityBat)par1EntityLiving, par2, par3, par4);
    076    }
    077
    078    /**
    079     * Sets a simple glTranslate on a LivingEntity.
    080     */
    081    protected void renderLivingAt(EntityLiving par1EntityLiving, double par2, double par4, double par6)
    082    {
    083        this.func_82445_a((EntityBat)par1EntityLiving, par2, par4, par6);
    084    }
    085
    086    public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9)
    087    {
    088        this.func_82443_a((EntityBat)par1EntityLiving, par2, par4, par6, par8, par9);
    089    }
    090
    091    /**
    092     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
    093     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
    094     * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
    095     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
    096     */
    097    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
    098    {
    099        this.func_82443_a((EntityBat)par1Entity, par2, par4, par6, par8, par9);
    100    }
    101}