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 public ModelRenderer field_82898_f; 024 025 public ModelVillager(float par1) 026 { 027 this(par1, 0.0F, 64, 64); 028 } 029 030 public ModelVillager(float par1, float par2, int par3, int par4) 031 { 032 this.villagerHead = (new ModelRenderer(this)).setTextureSize(par3, par4); 033 this.villagerHead.setRotationPoint(0.0F, 0.0F + par2, 0.0F); 034 this.villagerHead.setTextureOffset(0, 0).addBox(-4.0F, -10.0F, -4.0F, 8, 10, 8, par1); 035 this.field_82898_f = (new ModelRenderer(this)).setTextureSize(par3, par4); 036 this.field_82898_f.setRotationPoint(0.0F, par2 - 2.0F, 0.0F); 037 this.field_82898_f.setTextureOffset(24, 0).addBox(-1.0F, -1.0F, -6.0F, 2, 4, 2, par1); 038 this.villagerHead.addChild(this.field_82898_f); 039 this.villagerBody = (new ModelRenderer(this)).setTextureSize(par3, par4); 040 this.villagerBody.setRotationPoint(0.0F, 0.0F + par2, 0.0F); 041 this.villagerBody.setTextureOffset(16, 20).addBox(-4.0F, 0.0F, -3.0F, 8, 12, 6, par1); 042 this.villagerBody.setTextureOffset(0, 38).addBox(-4.0F, 0.0F, -3.0F, 8, 18, 6, par1 + 0.5F); 043 this.villagerArms = (new ModelRenderer(this)).setTextureSize(par3, par4); 044 this.villagerArms.setRotationPoint(0.0F, 0.0F + par2 + 2.0F, 0.0F); 045 this.villagerArms.setTextureOffset(44, 22).addBox(-8.0F, -2.0F, -2.0F, 4, 8, 4, par1); 046 this.villagerArms.setTextureOffset(44, 22).addBox(4.0F, -2.0F, -2.0F, 4, 8, 4, par1); 047 this.villagerArms.setTextureOffset(40, 38).addBox(-4.0F, 2.0F, -2.0F, 8, 4, 4, par1); 048 this.rightVillagerLeg = (new ModelRenderer(this, 0, 22)).setTextureSize(par3, par4); 049 this.rightVillagerLeg.setRotationPoint(-2.0F, 12.0F + par2, 0.0F); 050 this.rightVillagerLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, par1); 051 this.leftVillagerLeg = (new ModelRenderer(this, 0, 22)).setTextureSize(par3, par4); 052 this.leftVillagerLeg.mirror = true; 053 this.leftVillagerLeg.setRotationPoint(2.0F, 12.0F + par2, 0.0F); 054 this.leftVillagerLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, par1); 055 } 056 057 /** 058 * Sets the models various rotation angles then renders the model. 059 */ 060 public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) 061 { 062 this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); 063 this.villagerHead.render(par7); 064 this.villagerBody.render(par7); 065 this.rightVillagerLeg.render(par7); 066 this.leftVillagerLeg.render(par7); 067 this.villagerArms.render(par7); 068 } 069 070 /** 071 * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms 072 * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how 073 * "far" arms and legs can swing at most. 074 */ 075 public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) 076 { 077 this.villagerHead.rotateAngleY = par4 / (180F / (float)Math.PI); 078 this.villagerHead.rotateAngleX = par5 / (180F / (float)Math.PI); 079 this.villagerArms.rotationPointY = 3.0F; 080 this.villagerArms.rotationPointZ = -1.0F; 081 this.villagerArms.rotateAngleX = -0.75F; 082 this.rightVillagerLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.4F * par2 * 0.5F; 083 this.leftVillagerLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.4F * par2 * 0.5F; 084 this.rightVillagerLeg.rotateAngleY = 0.0F; 085 this.leftVillagerLeg.rotateAngleY = 0.0F; 086 } 087 }