ModelHat.java 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package me.km.items;
  2. import static net.minecraft.client.model.ModelBase.copyModelAngles;
  3. import net.minecraft.client.model.ModelBiped;
  4. import net.minecraft.client.model.ModelRenderer;
  5. import net.minecraft.entity.Entity;
  6. import net.minecraft.entity.item.EntityArmorStand;
  7. import net.minecraftforge.fml.relauncher.Side;
  8. import net.minecraftforge.fml.relauncher.SideOnly;
  9. @SideOnly(Side.CLIENT)
  10. public class ModelHat extends ModelBiped
  11. {
  12. private final ModelRenderer firstHeadPart;
  13. private final ModelRenderer secHeadPart;
  14. public ModelHat(float scale)
  15. {
  16. super(scale, 0, 64, 64);
  17. firstHeadPart = new ModelRenderer(this, 0, 32);
  18. firstHeadPart.addBox(-5, -8.6f, -5, 10, 1, 10);
  19. firstHeadPart.setRotationPoint(0F, 0F, 0F);
  20. firstHeadPart.setTextureSize(64, 64);
  21. firstHeadPart.mirror = true;
  22. setRotation(firstHeadPart, 0, 0, 0);
  23. secHeadPart = new ModelRenderer(this, 0, 43);
  24. secHeadPart.addBox(-3, -11.6f, -3, 6, 3, 6);
  25. secHeadPart.setRotationPoint(0F, 0F, 0F);
  26. secHeadPart.setTextureSize(64, 64);
  27. secHeadPart.mirror = true;
  28. setRotation(secHeadPart, 0, 0, 0);
  29. bipedHead.addChild(firstHeadPart);
  30. bipedHead.addChild(secHeadPart);
  31. }
  32. @Override
  33. public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)
  34. {
  35. if (entityIn instanceof EntityArmorStand)
  36. {
  37. EntityArmorStand entityarmorstand = (EntityArmorStand)entityIn;
  38. this.bipedHead.rotateAngleX = 0.017453292F * entityarmorstand.getHeadRotation().getX();
  39. this.bipedHead.rotateAngleY = 0.017453292F * entityarmorstand.getHeadRotation().getY();
  40. this.bipedHead.rotateAngleZ = 0.017453292F * entityarmorstand.getHeadRotation().getZ();
  41. this.bipedHead.setRotationPoint(0.0F, 1.0F, 0.0F);
  42. this.bipedBody.rotateAngleX = 0.017453292F * entityarmorstand.getBodyRotation().getX();
  43. this.bipedBody.rotateAngleY = 0.017453292F * entityarmorstand.getBodyRotation().getY();
  44. this.bipedBody.rotateAngleZ = 0.017453292F * entityarmorstand.getBodyRotation().getZ();
  45. this.bipedLeftArm.rotateAngleX = 0.017453292F * entityarmorstand.getLeftArmRotation().getX();
  46. this.bipedLeftArm.rotateAngleY = 0.017453292F * entityarmorstand.getLeftArmRotation().getY();
  47. this.bipedLeftArm.rotateAngleZ = 0.017453292F * entityarmorstand.getLeftArmRotation().getZ();
  48. this.bipedRightArm.rotateAngleX = 0.017453292F * entityarmorstand.getRightArmRotation().getX();
  49. this.bipedRightArm.rotateAngleY = 0.017453292F * entityarmorstand.getRightArmRotation().getY();
  50. this.bipedRightArm.rotateAngleZ = 0.017453292F * entityarmorstand.getRightArmRotation().getZ();
  51. this.bipedLeftLeg.rotateAngleX = 0.017453292F * entityarmorstand.getLeftLegRotation().getX();
  52. this.bipedLeftLeg.rotateAngleY = 0.017453292F * entityarmorstand.getLeftLegRotation().getY();
  53. this.bipedLeftLeg.rotateAngleZ = 0.017453292F * entityarmorstand.getLeftLegRotation().getZ();
  54. this.bipedLeftLeg.setRotationPoint(1.9F, 11.0F, 0.0F);
  55. this.bipedRightLeg.rotateAngleX = 0.017453292F * entityarmorstand.getRightLegRotation().getX();
  56. this.bipedRightLeg.rotateAngleY = 0.017453292F * entityarmorstand.getRightLegRotation().getY();
  57. this.bipedRightLeg.rotateAngleZ = 0.017453292F * entityarmorstand.getRightLegRotation().getZ();
  58. this.bipedRightLeg.setRotationPoint(-1.9F, 11.0F, 0.0F);
  59. copyModelAngles(this.bipedHead, this.bipedHeadwear);
  60. return;
  61. }
  62. super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
  63. }
  64. private void setRotation(ModelRenderer model, float x, float y, float z)
  65. {
  66. model.rotateAngleX = x;
  67. model.rotateAngleY = y;
  68. model.rotateAngleZ = z;
  69. }
  70. }