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