    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.Minecraft;
    007import net.minecraft.client.model.ModelWitch;
    008import net.minecraft.client.renderer.RenderBlocks;
    009import net.minecraft.entity.Entity;
    010import net.minecraft.entity.EntityLiving;
    011import net.minecraft.entity.monster.EntityWitch;
    012import net.minecraft.item.Item;
    013import net.minecraft.item.ItemStack;
    014import org.lwjgl.opengl.GL11;
    015
    016@SideOnly(Side.CLIENT)
    017public class RenderWitch extends RenderLiving
    018{
    019    private ModelWitch field_82414_a;
    020    private int field_82413_f;
    021
    022    public RenderWitch()
    023    {
    024        super(new ModelWitch(0.0F), 0.5F);
    025        this.field_82414_a = (ModelWitch)this.mainModel;
    026        this.field_82413_f = this.field_82414_a.func_82899_a();
    027    }
    028
    029    public void func_82412_a(EntityWitch par1EntityWitch, double par2, double par4, double par6, float par8, float par9)
    030    {
    031        ItemStack itemstack = par1EntityWitch.getHeldItem();
    032
    033        if (this.field_82414_a.func_82899_a() != this.field_82413_f)
    034        {
    035            Minecraft.getMinecraft().getLogAgent().logInfo("Loaded new witch model");
    036            this.mainModel = this.field_82414_a = new ModelWitch(0.0F);
    037            this.field_82413_f = this.field_82414_a.func_82899_a();
    038        }
    039
    040        this.field_82414_a.field_82900_g = itemstack != null;
    041        super.doRenderLiving(par1EntityWitch, par2, par4, par6, par8, par9);
    042    }
    043
    044    protected void func_82411_a(EntityWitch par1EntityWitch, float par2)
    045    {
    046        float f1 = 1.0F;
    047        GL11.glColor3f(f1, f1, f1);
    048        super.renderEquippedItems(par1EntityWitch, par2);
    049        ItemStack itemstack = par1EntityWitch.getHeldItem();
    050
    051        if (itemstack != null)
    052        {
    053            GL11.glPushMatrix();
    054            float f2;
    055
    056            if (this.mainModel.isChild)
    057            {
    058                f2 = 0.5F;
    059                GL11.glTranslatef(0.0F, 0.625F, 0.0F);
    060                GL11.glRotatef(-20.0F, -1.0F, 0.0F, 0.0F);
    061                GL11.glScalef(f2, f2, f2);
    062            }
    063
    064            this.field_82414_a.field_82898_f.postRender(0.0625F);
    065            GL11.glTranslatef(-0.0625F, 0.53125F, 0.21875F);
    066
    067            if (itemstack.itemID < 256 && RenderBlocks.renderItemIn3d(Block.blocksList[itemstack.itemID].getRenderType()))
    068            {
    069                f2 = 0.5F;
    070                GL11.glTranslatef(0.0F, 0.1875F, -0.3125F);
    071                f2 *= 0.75F;
    072                GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F);
    073                GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
    074                GL11.glScalef(f2, -f2, f2);
    075            }
    076            else if (itemstack.itemID == Item.bow.itemID)
    077            {
    078                f2 = 0.625F;
    079                GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
    080                GL11.glRotatef(-20.0F, 0.0F, 1.0F, 0.0F);
    081                GL11.glScalef(f2, -f2, f2);
    082                GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
    083                GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
    084            }
    085            else if (Item.itemsList[itemstack.itemID].isFull3D())
    086            {
    087                f2 = 0.625F;
    088
    089                if (Item.itemsList[itemstack.itemID].shouldRotateAroundWhenRendering())
    090                {
    091                    GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
    092                    GL11.glTranslatef(0.0F, -0.125F, 0.0F);
    093                }
    094
    095                this.func_82410_b();
    096                GL11.glScalef(f2, -f2, f2);
    097                GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
    098                GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
    099            }
    100            else
    101            {
    102                f2 = 0.375F;
    103                GL11.glTranslatef(0.25F, 0.1875F, -0.1875F);
    104                GL11.glScalef(f2, f2, f2);
    105                GL11.glRotatef(60.0F, 0.0F, 0.0F, 1.0F);
    106                GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F);
    107                GL11.glRotatef(20.0F, 0.0F, 0.0F, 1.0F);
    108            }
    109
    110            GL11.glRotatef(-15.0F, 1.0F, 0.0F, 0.0F);
    111            GL11.glRotatef(40.0F, 0.0F, 0.0F, 1.0F);
    112            this.renderManager.itemRenderer.renderItem(par1EntityWitch, itemstack, 0);
    113
    114            if (itemstack.getItem().requiresMultipleRenderPasses())
    115            {
    116                this.renderManager.itemRenderer.renderItem(par1EntityWitch, itemstack, 1);
    117            }
    118
    119            GL11.glPopMatrix();
    120        }
    121    }
    122
    123    protected void func_82410_b()
    124    {
    125        GL11.glTranslatef(0.0F, 0.1875F, 0.0F);
    126    }
    127
    128    protected void func_82409_b(EntityWitch par1EntityWitch, float par2)
    129    {
    130        float f1 = 0.9375F;
    131        GL11.glScalef(f1, f1, f1);
    132    }
    133
    134    /**
    135     * Allows the render to do any OpenGL state modifications necessary before the model is rendered. Args:
    136     * entityLiving, partialTickTime
    137     */
    138    protected void preRenderCallback(EntityLiving par1EntityLiving, float par2)
    139    {
    140        this.func_82409_b((EntityWitch)par1EntityLiving, par2);
    141    }
    142
    143    protected void renderEquippedItems(EntityLiving par1EntityLiving, float par2)
    144    {
    145        this.func_82411_a((EntityWitch)par1EntityLiving, par2);
    146    }
    147
    148    public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9)
    149    {
    150        this.func_82412_a((EntityWitch)par1EntityLiving, par2, par4, par6, par8, par9);
    151    }
    152
    153    /**
    154     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
    155     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
    156     * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
    157     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
    158     */
    159    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
    160    {
    161        this.func_82412_a((EntityWitch)par1Entity, par2, par4, par6, par8, par9);
    162    }
    163}