Пример #1
0
  /** Moves the entity based on the specified heading. */
  public void moveEntityWithHeading(float strafe, float forward) {
    Entity entity = this.getPassengers().isEmpty() ? null : (Entity) this.getPassengers().get(0);

    if (this.isBeingRidden() && this.canBeSteered()) {
      this.rotationYaw = entity.rotationYaw;
      this.prevRotationYaw = this.rotationYaw;
      this.rotationPitch = entity.rotationPitch * 0.5F;
      this.setRotation(this.rotationYaw, this.rotationPitch);
      this.renderYawOffset = this.rotationYaw;
      this.rotationYawHead = this.rotationYaw;
      this.stepHeight = 1.0F;
      this.jumpMovementFactor = this.getAIMoveSpeed() * 0.1F;

      if (this.canPassengerSteer()) {
        float f =
            (float)
                    this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED)
                        .getAttributeValue()
                * 0.225F;

        if (this.boosting) {
          if (this.boostTime++ > this.totalBoostTime) {
            this.boosting = false;
          }

          f +=
              f
                  * 1.15F
                  * MathHelper.sin(
                      (float) this.boostTime / (float) this.totalBoostTime * (float) Math.PI);
        }

        this.setAIMoveSpeed(f);
        super.moveEntityWithHeading(0.0F, 1.0F);
      } else {
        this.motionX = 0.0D;
        this.motionY = 0.0D;
        this.motionZ = 0.0D;
      }

      this.prevLimbSwingAmount = this.limbSwingAmount;
      double d1 = this.posX - this.prevPosX;
      double d0 = this.posZ - this.prevPosZ;
      float f1 = MathHelper.sqrt_double(d1 * d1 + d0 * d0) * 4.0F;

      if (f1 > 1.0F) {
        f1 = 1.0F;
      }

      this.limbSwingAmount += (f1 - this.limbSwingAmount) * 0.4F;
      this.limbSwing += this.limbSwingAmount;
    } else {
      this.stepHeight = 0.5F;
      this.jumpMovementFactor = 0.02F;
      super.moveEntityWithHeading(strafe, forward);
    }
  }
  /** Moves the entity based on the specified heading. Args: strafe, forward */
  public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_) {
    if (this.riddenByEntity != null
        && this.riddenByEntity instanceof EntityLivingBase
        && this.isHorseSaddled()) {
      this.prevRotationYaw = this.rotationYaw = this.riddenByEntity.rotationYaw;
      this.rotationPitch = this.riddenByEntity.rotationPitch * 0.5F;
      this.setRotation(this.rotationYaw, this.rotationPitch);
      this.rotationYawHead = this.renderYawOffset = this.rotationYaw;
      p_70612_1_ = ((EntityLivingBase) this.riddenByEntity).moveStrafing * 0.5F;
      p_70612_2_ = ((EntityLivingBase) this.riddenByEntity).moveForward;

      if (p_70612_2_ <= 0.0F) {
        p_70612_2_ *= 0.25F;
        this.gallopTime = 0;
      }

      if (this.onGround && this.jumpPower == 0.0F && this.isRearing() && !this.field_110294_bI) {
        p_70612_1_ = 0.0F;
        p_70612_2_ = 0.0F;
      }

      if (this.jumpPower > 0.0F && !this.isHorseJumping() && this.onGround) {
        this.motionY = this.getHorseJumpStrength() * (double) this.jumpPower;

        if (this.isPotionActive(Potion.jump)) {
          this.motionY +=
              (double)
                  ((float) (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F);
        }

        this.setHorseJumping(true);
        this.isAirBorne = true;

        if (p_70612_2_ > 0.0F) {
          float f2 = MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F);
          float f3 = MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F);
          this.motionX += (double) (-0.4F * f2 * this.jumpPower);
          this.motionZ += (double) (0.4F * f3 * this.jumpPower);
          this.playSound("mob.horse.jump", 0.4F, 1.0F);
        }

        this.jumpPower = 0.0F;
        net.minecraftforge.common.ForgeHooks.onLivingJump(this);
      }

      this.stepHeight = 1.0F;
      this.jumpMovementFactor = this.getAIMoveSpeed() * 0.1F;

      if (!this.worldObj.isRemote) {
        this.setAIMoveSpeed(
            (float)
                this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue());
        super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
      }

      if (this.onGround) {
        this.jumpPower = 0.0F;
        this.setHorseJumping(false);
      }

      this.prevLimbSwingAmount = this.limbSwingAmount;
      double d1 = this.posX - this.prevPosX;
      double d0 = this.posZ - this.prevPosZ;
      float f4 = MathHelper.sqrt_double(d1 * d1 + d0 * d0) * 4.0F;

      if (f4 > 1.0F) {
        f4 = 1.0F;
      }

      this.limbSwingAmount += (f4 - this.limbSwingAmount) * 0.4F;
      this.limbSwing += this.limbSwingAmount;
    } else {
      this.stepHeight = 0.5F;
      this.jumpMovementFactor = 0.02F;
      super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
    }
  }