001 package net.minecraft.src;
002
003 import cpw.mods.fml.common.Side;
004 import cpw.mods.fml.common.asm.SideOnly;
005
006 @SideOnly(Side.CLIENT)
007 public class ModelVillager extends ModelBase
008 {
009 /** The head box of the VillagerModel */
010 public ModelRenderer villagerHead;
011
012 /** The body of the VillagerModel */
013 public ModelRenderer villagerBody;
014
015 /** The arms of the VillagerModel */
016 public ModelRenderer villagerArms;
017
018 /** The right leg of the VillagerModel */
019 public ModelRenderer rightVillagerLeg;
020
021 /** The left leg of the VillagerModel */
022 public ModelRenderer leftVillagerLeg;
023
024 public ModelVillager(float par1)
025 {
026 this(par1, 0.0F);
027 }
028
029 public ModelVillager(float par1, float par2)
030 {
031 byte var3 = 64;
032 byte var4 = 64;
033 this.villagerHead = (new ModelRenderer(this)).setTextureSize(var3, var4);
034 this.villagerHead.setRotationPoint(0.0F, 0.0F + par2, 0.0F);
035 this.villagerHead.setTextureOffset(0, 0).addBox(-4.0F, -10.0F, -4.0F, 8, 10, 8, par1);
036 this.villagerHead.setTextureOffset(24, 0).addBox(-1.0F, -3.0F, -6.0F, 2, 4, 2, par1);
037 this.villagerBody = (new ModelRenderer(this)).setTextureSize(var3, var4);
038 this.villagerBody.setRotationPoint(0.0F, 0.0F + par2, 0.0F);
039 this.villagerBody.setTextureOffset(16, 20).addBox(-4.0F, 0.0F, -3.0F, 8, 12, 6, par1);
040 this.villagerBody.setTextureOffset(0, 38).addBox(-4.0F, 0.0F, -3.0F, 8, 18, 6, par1 + 0.5F);
041 this.villagerArms = (new ModelRenderer(this)).setTextureSize(var3, var4);
042 this.villagerArms.setRotationPoint(0.0F, 0.0F + par2 + 2.0F, 0.0F);
043 this.villagerArms.setTextureOffset(44, 22).addBox(-8.0F, -2.0F, -2.0F, 4, 8, 4, par1);
044 this.villagerArms.setTextureOffset(44, 22).addBox(4.0F, -2.0F, -2.0F, 4, 8, 4, par1);
045 this.villagerArms.setTextureOffset(40, 38).addBox(-4.0F, 2.0F, -2.0F, 8, 4, 4, par1);
046 this.rightVillagerLeg = (new ModelRenderer(this, 0, 22)).setTextureSize(var3, var4);
047 this.rightVillagerLeg.setRotationPoint(-2.0F, 12.0F + par2, 0.0F);
048 this.rightVillagerLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, par1);
049 this.leftVillagerLeg = (new ModelRenderer(this, 0, 22)).setTextureSize(var3, var4);
050 this.leftVillagerLeg.mirror = true;
051 this.leftVillagerLeg.setRotationPoint(2.0F, 12.0F + par2, 0.0F);
052 this.leftVillagerLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, par1);
053 }
054
055 /**
056 * Sets the models various rotation angles then renders the model.
057 */
058 public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7)
059 {
060 this.setRotationAngles(par2, par3, par4, par5, par6, par7);
061 this.villagerHead.render(par7);
062 this.villagerBody.render(par7);
063 this.rightVillagerLeg.render(par7);
064 this.leftVillagerLeg.render(par7);
065 this.villagerArms.render(par7);
066 }
067
068 /**
069 * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
070 * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
071 * "far" arms and legs can swing at most.
072 */
073 public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6)
074 {
075 this.villagerHead.rotateAngleY = par4 / (180F / (float)Math.PI);
076 this.villagerHead.rotateAngleX = par5 / (180F / (float)Math.PI);
077 this.villagerArms.rotationPointY = 3.0F;
078 this.villagerArms.rotationPointZ = -1.0F;
079 this.villagerArms.rotateAngleX = -0.75F;
080 this.rightVillagerLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.4F * par2 * 0.5F;
081 this.leftVillagerLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.4F * par2 * 0.5F;
082 this.rightVillagerLeg.rotateAngleY = 0.0F;
083 this.leftVillagerLeg.rotateAngleY = 0.0F;
084 }
085 }