Пример #1
0
  @Override
  protected void jump() {
    this.motionY = 0.52D / WorldUtil.getGravityFactor(this);
    if (this.motionY < 0.26D) this.motionY = 0.26D;

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

    if (this.isSprinting()) {
      float f = this.rotationYaw * 0.017453292F;
      this.motionX -= MathHelper.sin(f) * 0.2F;
      this.motionZ += MathHelper.cos(f) * 0.2F;
    }

    this.isAirBorne = true;
    ForgeHooks.onLivingJump(this);
  }
  /** 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_);
    }
  }