001package net.minecraft.client.model;
002
003import cpw.mods.fml.relauncher.Side;
004import cpw.mods.fml.relauncher.SideOnly;
005import java.util.Random;
006import net.minecraft.entity.Entity;
007import net.minecraft.util.MathHelper;
008import org.lwjgl.opengl.GL11;
009
010@SideOnly(Side.CLIENT)
011public class ModelGhast extends ModelBase
012{
013    ModelRenderer body;
014    ModelRenderer[] tentacles = new ModelRenderer[9];
015
016    public ModelGhast()
017    {
018        byte b0 = -16;
019        this.body = new ModelRenderer(this, 0, 0);
020        this.body.addBox(-8.0F, -8.0F, -8.0F, 16, 16, 16);
021        this.body.rotationPointY += (float)(24 + b0);
022        Random random = new Random(1660L);
023
024        for (int i = 0; i < this.tentacles.length; ++i)
025        {
026            this.tentacles[i] = new ModelRenderer(this, 0, 0);
027            float f = (((float)(i % 3) - (float)(i / 3 % 2) * 0.5F + 0.25F) / 2.0F * 2.0F - 1.0F) * 5.0F;
028            float f1 = ((float)(i / 3) / 2.0F * 2.0F - 1.0F) * 5.0F;
029            int j = random.nextInt(7) + 8;
030            this.tentacles[i].addBox(-1.0F, 0.0F, -1.0F, 2, j, 2);
031            this.tentacles[i].rotationPointX = f;
032            this.tentacles[i].rotationPointZ = f1;
033            this.tentacles[i].rotationPointY = (float)(31 + b0);
034        }
035    }
036
037    /**
038     * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
039     * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
040     * "far" arms and legs can swing at most.
041     */
042    public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity)
043    {
044        for (int i = 0; i < this.tentacles.length; ++i)
045        {
046            this.tentacles[i].rotateAngleX = 0.2F * MathHelper.sin(par3 * 0.3F + (float)i) + 0.4F;
047        }
048    }
049
050    /**
051     * Sets the models various rotation angles then renders the model.
052     */
053    public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7)
054    {
055        this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity);
056        GL11.glPushMatrix();
057        GL11.glTranslatef(0.0F, 0.6F, 0.0F);
058        this.body.render(par7);
059        ModelRenderer[] amodelrenderer = this.tentacles;
060        int i = amodelrenderer.length;
061
062        for (int j = 0; j < i; ++j)
063        {
064            ModelRenderer modelrenderer = amodelrenderer[j];
065            modelrenderer.render(par7);
066        }
067
068        GL11.glPopMatrix();
069    }
070}