protected void convertToChild(ModelRenderer parParent, ModelRenderer parChild) {
   parChild.rotationPointX -= parParent.rotationPointX;
   parChild.rotationPointY -= parParent.rotationPointY;
   parChild.rotationPointZ -= parParent.rotationPointZ;
   parChild.rotateAngleX -= parParent.rotateAngleX;
   parChild.rotateAngleY -= parParent.rotateAngleY;
   parChild.rotateAngleZ -= parParent.rotateAngleZ;
   parParent.addChild(parChild);
 }
Ejemplo n.º 2
0
  public void setRotationAngles(
      float f, float f1, float f2, float f3, float f4, float f5, Entity entity) {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);

    this.TurretHead.rotateAngleY =
        this.TurretAntennaI.rotateAngleY =
            this.TurretAntennaII.rotateAngleY =
                this.RightBarrel.rotateAngleY =
                    this.LeftBarrel.rotateAngleY = f3 / (180F / (float) Math.PI);
    this.TurretHead.rotateAngleX =
        this.TurretAntennaI.rotateAngleX =
            this.TurretAntennaII.rotateAngleX =
                this.RightBarrel.rotateAngleX =
                    this.LeftBarrel.rotateAngleX = f4 / (180F / (float) Math.PI);

    setStaticBody(f3);

    EntityTurret_T2Revolver turret = (EntityTurret_T2Revolver) entity;

    float healthRot =
        -((float) Math.PI / 2F)
            * ((float) (turret.getMaxHealth() - turret.getSrvHealth())
                / (float) turret.getMaxHealth());
    this.HealthBar.rotateAngleZ = healthRot;
    float ammoRot =
        ((float) Math.PI / 2F)
            * ((float) (turret.getMaxAmmo() - turret.getAmmo()) / (float) turret.getMaxAmmo());

    if (TurretUpgrades.hasUpgrade(TUpgInfAmmo.class, turret.upgrades) && turret.getAmmo() > 0) {
      ammoRot = 0F;
    }
    this.AmmoBar.rotateAngleZ = ammoRot;

    double xR =
        Math.sin(turret.rotationYawHead / (180D / Math.PI))
            * ((double) (turret.getRightBarrelOffset()) / (double) turret.getMaxShootTicks());
    double zR =
        Math.cos(turret.rotationYawHead / (180D / Math.PI))
            * ((double) (turret.getRightBarrelOffset()) / (double) turret.getMaxShootTicks());
    double yR =
        -Math.sin(turret.rotationPitch / (180F / (float) Math.PI))
            * ((double) (turret.getRightBarrelOffset()) / (double) turret.getMaxShootTicks());

    double xL =
        Math.sin(turret.rotationYawHead / (180D / Math.PI))
            * ((double) (turret.getLeftBarrelOffset()) / (double) turret.getMaxShootTicks());
    double zL =
        Math.cos(turret.rotationYawHead / (180D / Math.PI))
            * ((double) (turret.getLeftBarrelOffset()) / (double) turret.getMaxShootTicks());
    double yL =
        -Math.sin(turret.rotationPitch / (180F / (float) Math.PI))
            * ((double) (turret.getLeftBarrelOffset()) / (double) turret.getMaxShootTicks());

    xR *= (Math.cos(turret.rotationPitch / (180F / (float) Math.PI)));
    zR *= (Math.cos(turret.rotationPitch / (180F / (float) Math.PI)));
    xL *= (Math.cos(turret.rotationPitch / (180F / (float) Math.PI)));
    zL *= (Math.cos(turret.rotationPitch / (180F / (float) Math.PI)));

    if (turret.getAmmo() <= 0) {
      xR = 0D;
      yR = 0D;
      zR = 0D;
      xL = 0D;
      yL = 0D;
      zL = 0D;
    }

    RightBarrel.rotationPointX = (float) xR * 3F;
    RightBarrel.rotationPointZ = (float) zR * 3F;
    RightBarrel.rotationPointY = (float) yR * 3F;

    LeftBarrel.rotationPointX = (float) xL * 3F;
    LeftBarrel.rotationPointZ = (float) zL * 3F;
    LeftBarrel.rotationPointY = (float) yL * 3F;
  }