001 package net.minecraft.src; 002 003 import cpw.mods.fml.common.Side; 004 import cpw.mods.fml.common.asm.SideOnly; 005 import org.lwjgl.opengl.GL11; 006 007 @SideOnly(Side.CLIENT) 008 public class ModelOcelot extends ModelBase 009 { 010 /** The back left leg model for the Ocelot. */ 011 ModelRenderer ocelotBackLeftLeg; 012 013 /** The back right leg model for the Ocelot. */ 014 ModelRenderer ocelotBackRightLeg; 015 016 /** The front left leg model for the Ocelot. */ 017 ModelRenderer ocelotFrontLeftLeg; 018 019 /** The front right leg model for the Ocelot. */ 020 ModelRenderer ocelotFrontRightLeg; 021 022 /** The tail model for the Ocelot. */ 023 ModelRenderer ocelotTail; 024 025 /** The second part of tail model for the Ocelot. */ 026 ModelRenderer ocelotTail2; 027 028 /** The head model for the Ocelot. */ 029 ModelRenderer ocelotHead; 030 031 /** The body model for the Ocelot. */ 032 ModelRenderer ocelotBody; 033 int field_78163_i = 1; 034 035 public ModelOcelot() 036 { 037 this.setTextureOffset("head.main", 0, 0); 038 this.setTextureOffset("head.nose", 0, 24); 039 this.setTextureOffset("head.ear1", 0, 10); 040 this.setTextureOffset("head.ear2", 6, 10); 041 this.ocelotHead = new ModelRenderer(this, "head"); 042 this.ocelotHead.addBox("main", -2.5F, -2.0F, -3.0F, 5, 4, 5); 043 this.ocelotHead.addBox("nose", -1.5F, 0.0F, -4.0F, 3, 2, 2); 044 this.ocelotHead.addBox("ear1", -2.0F, -3.0F, 0.0F, 1, 1, 2); 045 this.ocelotHead.addBox("ear2", 1.0F, -3.0F, 0.0F, 1, 1, 2); 046 this.ocelotHead.setRotationPoint(0.0F, 15.0F, -9.0F); 047 this.ocelotBody = new ModelRenderer(this, 20, 0); 048 this.ocelotBody.addBox(-2.0F, 3.0F, -8.0F, 4, 16, 6, 0.0F); 049 this.ocelotBody.setRotationPoint(0.0F, 12.0F, -10.0F); 050 this.ocelotTail = new ModelRenderer(this, 0, 15); 051 this.ocelotTail.addBox(-0.5F, 0.0F, 0.0F, 1, 8, 1); 052 this.ocelotTail.rotateAngleX = 0.9F; 053 this.ocelotTail.setRotationPoint(0.0F, 15.0F, 8.0F); 054 this.ocelotTail2 = new ModelRenderer(this, 4, 15); 055 this.ocelotTail2.addBox(-0.5F, 0.0F, 0.0F, 1, 8, 1); 056 this.ocelotTail2.setRotationPoint(0.0F, 20.0F, 14.0F); 057 this.ocelotBackLeftLeg = new ModelRenderer(this, 8, 13); 058 this.ocelotBackLeftLeg.addBox(-1.0F, 0.0F, 1.0F, 2, 6, 2); 059 this.ocelotBackLeftLeg.setRotationPoint(1.1F, 18.0F, 5.0F); 060 this.ocelotBackRightLeg = new ModelRenderer(this, 8, 13); 061 this.ocelotBackRightLeg.addBox(-1.0F, 0.0F, 1.0F, 2, 6, 2); 062 this.ocelotBackRightLeg.setRotationPoint(-1.1F, 18.0F, 5.0F); 063 this.ocelotFrontLeftLeg = new ModelRenderer(this, 40, 0); 064 this.ocelotFrontLeftLeg.addBox(-1.0F, 0.0F, 0.0F, 2, 10, 2); 065 this.ocelotFrontLeftLeg.setRotationPoint(1.2F, 13.8F, -5.0F); 066 this.ocelotFrontRightLeg = new ModelRenderer(this, 40, 0); 067 this.ocelotFrontRightLeg.addBox(-1.0F, 0.0F, 0.0F, 2, 10, 2); 068 this.ocelotFrontRightLeg.setRotationPoint(-1.2F, 13.8F, -5.0F); 069 } 070 071 /** 072 * Sets the models various rotation angles then renders the model. 073 */ 074 public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) 075 { 076 this.setRotationAngles(par2, par3, par4, par5, par6, par7); 077 078 if (this.isChild) 079 { 080 float var8 = 2.0F; 081 GL11.glPushMatrix(); 082 GL11.glScalef(1.5F / var8, 1.5F / var8, 1.5F / var8); 083 GL11.glTranslatef(0.0F, 10.0F * par7, 4.0F * par7); 084 this.ocelotHead.render(par7); 085 GL11.glPopMatrix(); 086 GL11.glPushMatrix(); 087 GL11.glScalef(1.0F / var8, 1.0F / var8, 1.0F / var8); 088 GL11.glTranslatef(0.0F, 24.0F * par7, 0.0F); 089 this.ocelotBody.render(par7); 090 this.ocelotBackLeftLeg.render(par7); 091 this.ocelotBackRightLeg.render(par7); 092 this.ocelotFrontLeftLeg.render(par7); 093 this.ocelotFrontRightLeg.render(par7); 094 this.ocelotTail.render(par7); 095 this.ocelotTail2.render(par7); 096 GL11.glPopMatrix(); 097 } 098 else 099 { 100 this.ocelotHead.render(par7); 101 this.ocelotBody.render(par7); 102 this.ocelotTail.render(par7); 103 this.ocelotTail2.render(par7); 104 this.ocelotBackLeftLeg.render(par7); 105 this.ocelotBackRightLeg.render(par7); 106 this.ocelotFrontLeftLeg.render(par7); 107 this.ocelotFrontRightLeg.render(par7); 108 } 109 } 110 111 /** 112 * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms 113 * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how 114 * "far" arms and legs can swing at most. 115 */ 116 public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6) 117 { 118 this.ocelotHead.rotateAngleX = par5 / (180F / (float)Math.PI); 119 this.ocelotHead.rotateAngleY = par4 / (180F / (float)Math.PI); 120 121 if (this.field_78163_i != 3) 122 { 123 this.ocelotBody.rotateAngleX = ((float)Math.PI / 2F); 124 125 if (this.field_78163_i == 2) 126 { 127 this.ocelotBackLeftLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.0F * par2; 128 this.ocelotBackRightLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + 0.3F) * 1.0F * par2; 129 this.ocelotFrontLeftLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI + 0.3F) * 1.0F * par2; 130 this.ocelotFrontRightLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.0F * par2; 131 this.ocelotTail2.rotateAngleX = 1.7278761F + ((float)Math.PI / 10F) * MathHelper.cos(par1) * par2; 132 } 133 else 134 { 135 this.ocelotBackLeftLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.0F * par2; 136 this.ocelotBackRightLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.0F * par2; 137 this.ocelotFrontLeftLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.0F * par2; 138 this.ocelotFrontRightLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.0F * par2; 139 140 if (this.field_78163_i == 1) 141 { 142 this.ocelotTail2.rotateAngleX = 1.7278761F + ((float)Math.PI / 4F) * MathHelper.cos(par1) * par2; 143 } 144 else 145 { 146 this.ocelotTail2.rotateAngleX = 1.7278761F + 0.47123894F * MathHelper.cos(par1) * par2; 147 } 148 } 149 } 150 } 151 152 /** 153 * Used for easily adding entity-dependent animations. The second and third float params here are the same second 154 * and third as in the setRotationAngles method. 155 */ 156 public void setLivingAnimations(EntityLiving par1EntityLiving, float par2, float par3, float par4) 157 { 158 EntityOcelot var5 = (EntityOcelot)par1EntityLiving; 159 this.ocelotBody.rotationPointY = 12.0F; 160 this.ocelotBody.rotationPointZ = -10.0F; 161 this.ocelotHead.rotationPointY = 15.0F; 162 this.ocelotHead.rotationPointZ = -9.0F; 163 this.ocelotTail.rotationPointY = 15.0F; 164 this.ocelotTail.rotationPointZ = 8.0F; 165 this.ocelotTail2.rotationPointY = 20.0F; 166 this.ocelotTail2.rotationPointZ = 14.0F; 167 this.ocelotFrontLeftLeg.rotationPointY = this.ocelotFrontRightLeg.rotationPointY = 13.8F; 168 this.ocelotFrontLeftLeg.rotationPointZ = this.ocelotFrontRightLeg.rotationPointZ = -5.0F; 169 this.ocelotBackLeftLeg.rotationPointY = this.ocelotBackRightLeg.rotationPointY = 18.0F; 170 this.ocelotBackLeftLeg.rotationPointZ = this.ocelotBackRightLeg.rotationPointZ = 5.0F; 171 this.ocelotTail.rotateAngleX = 0.9F; 172 173 if (var5.isSneaking()) 174 { 175 ++this.ocelotBody.rotationPointY; 176 this.ocelotHead.rotationPointY += 2.0F; 177 ++this.ocelotTail.rotationPointY; 178 this.ocelotTail2.rotationPointY += -4.0F; 179 this.ocelotTail2.rotationPointZ += 2.0F; 180 this.ocelotTail.rotateAngleX = ((float)Math.PI / 2F); 181 this.ocelotTail2.rotateAngleX = ((float)Math.PI / 2F); 182 this.field_78163_i = 0; 183 } 184 else if (var5.isSprinting()) 185 { 186 this.ocelotTail2.rotationPointY = this.ocelotTail.rotationPointY; 187 this.ocelotTail2.rotationPointZ += 2.0F; 188 this.ocelotTail.rotateAngleX = ((float)Math.PI / 2F); 189 this.ocelotTail2.rotateAngleX = ((float)Math.PI / 2F); 190 this.field_78163_i = 2; 191 } 192 else if (var5.isSitting()) 193 { 194 this.ocelotBody.rotateAngleX = ((float)Math.PI / 4F); 195 this.ocelotBody.rotationPointY += -4.0F; 196 this.ocelotBody.rotationPointZ += 5.0F; 197 this.ocelotHead.rotationPointY += -3.3F; 198 ++this.ocelotHead.rotationPointZ; 199 this.ocelotTail.rotationPointY += 8.0F; 200 this.ocelotTail.rotationPointZ += -2.0F; 201 this.ocelotTail2.rotationPointY += 2.0F; 202 this.ocelotTail2.rotationPointZ += -0.8F; 203 this.ocelotTail.rotateAngleX = 1.7278761F; 204 this.ocelotTail2.rotateAngleX = 2.670354F; 205 this.ocelotFrontLeftLeg.rotateAngleX = this.ocelotFrontRightLeg.rotateAngleX = -0.15707964F; 206 this.ocelotFrontLeftLeg.rotationPointY = this.ocelotFrontRightLeg.rotationPointY = 15.8F; 207 this.ocelotFrontLeftLeg.rotationPointZ = this.ocelotFrontRightLeg.rotationPointZ = -7.0F; 208 this.ocelotBackLeftLeg.rotateAngleX = this.ocelotBackRightLeg.rotateAngleX = -((float)Math.PI / 2F); 209 this.ocelotBackLeftLeg.rotationPointY = this.ocelotBackRightLeg.rotationPointY = 21.0F; 210 this.ocelotBackLeftLeg.rotationPointZ = this.ocelotBackRightLeg.rotationPointZ = 1.0F; 211 this.field_78163_i = 3; 212 } 213 else 214 { 215 this.field_78163_i = 1; 216 } 217 } 218 }