public void onLivingUpdate() {
   if (field_9324_Y > 0) {
     double d = posX + (field_9323_Z - posX) / (double) field_9324_Y;
     double d1 = posY + (field_9356_aa - posY) / (double) field_9324_Y;
     double d2 = posZ + (field_9354_ab - posZ) / (double) field_9324_Y;
     double d3;
     for (d3 = field_9352_ac - (double) rotationYaw; d3 < -180D; d3 += 360D) {}
     for (; d3 >= 180D; d3 -= 360D) {}
     rotationYaw += d3 / (double) field_9324_Y;
     rotationPitch += (field_9350_ad - (double) rotationPitch) / (double) field_9324_Y;
     field_9324_Y--;
     setPosition(d, d1, d2);
     setRotation(rotationYaw, rotationPitch);
   }
   if (func_22049_v()) {
     isJumping = false;
     moveStrafing = 0.0F;
     moveForward = 0.0F;
     randomYawVelocity = 0.0F;
   } else if (!field_9343_G) {
     updatePlayerActionState();
   }
   boolean flag = handleWaterMovement();
   boolean flag1 = handleLavaMovement();
   if (isJumping) {
     if (flag) {
       motionY += 0.039999999105930328D;
     } else if (flag1) {
       motionY += 0.039999999105930328D;
     } else if (onGround) {
       jump();
     }
   }
   moveStrafing *= 0.98F;
   moveForward *= 0.98F;
   randomYawVelocity *= 0.9F;
   moveEntityWithHeading(moveStrafing, moveForward);
   if (this.health > 0) {
     List list =
         worldObj.getEntitiesWithinAABBExcludingEntity(
             this, boundingBox.expand(0.20000000298023224D, 0.0D, 0.20000000298023224D));
     if (list != null && list.size() > 0) {
       for (int i = 0; i < list.size(); i++) {
         Entity entity = (Entity) list.get(i);
         if (entity.canBePushed()) {
           entity.applyEntityCollision(this);
         }
       }
     }
   }
 }
 @SuppressWarnings("rawtypes")
 public void onLivingUpdate() {
   if (onGround && inWater && !gettingOutOfWater()) {
     motionY += 0.029999999999999999D;
   }
   if (!inWater && rand.nextInt(20) == 0 && riddenByEntity == null) {
     outOfWater++;
     posY += outOfWater / 30;
     attackEntityFrom(this, 1);
   }
   if (health <= 0 || !inWater && riddenByEntity == null) {
     isJumping = false;
     moveStrafing = 0.0F;
     moveForward = 0.0F;
     randomYawVelocity = 0.0F;
   } else if (!field_9343_G) {
     updatePlayerActionState();
   }
   boolean flag = handleWaterMovement();
   boolean flag1 = gettingOutOfWater();
   if (isJumping && flag && !flag1) {
     motionY += 0.02D;
   }
   moveStrafing *= 0.98F;
   moveForward *= 0.98F;
   randomYawVelocity *= 0.9F;
   moveEntityWithHeading(moveStrafing, moveForward);
   List list =
       worldObj.getEntitiesWithinAABBExcludingEntity(
           this, boundingBox.expand(0.20000000298023221D, 0.0D, 0.20000000298023221D));
   if (list != null && list.size() > 0) {
     for (int i = 0; i < list.size(); i++) {
       Entity entity = (Entity) list.get(i);
       if (entity.canBePushed()) {
         entity.applyEntityCollision(this);
       }
     }
   }
 }
Пример #3
0
  public void onUpdate() {
    super.onUpdate();
    if (getTimeSinceHit() > 0) {
      setTimeSinceHit(getTimeSinceHit() - 1);
    }
    if (getDamageTaken() > 0) {
      setDamageTaken(getDamageTaken() - 1);
    }
    prevPosX = posX;
    prevPosY = posY;
    prevPosZ = posZ;
    int i = 5;
    double d = 0.0D;
    for (int j = 0; j < i; j++) {
      double d2 =
          (boundingBox.minY
                  + ((boundingBox.maxY - boundingBox.minY) * (double) (j + 0)) / (double) i)
              - 0.125D;
      double d8 =
          (boundingBox.minY
                  + ((boundingBox.maxY - boundingBox.minY) * (double) (j + 1)) / (double) i)
              - 0.125D;
      AxisAlignedBB axisalignedbb =
          AxisAlignedBB.getBoundingBox(
              boundingBox.minX, d2, boundingBox.minZ, boundingBox.maxX, d8, boundingBox.maxZ);
      if (worldObj.isAABBInMaterial(axisalignedbb, Material.water)) {
        d += 1.0D / (double) i;
      }
    }

    double d1 = Math.sqrt(motionX * motionX + motionZ * motionZ);
    if (d1 > 0.14999999999999999D) {
      double d3 = Math.cos(((double) rotationYaw * 3.1415926535897931D) / 180D);
      double d9 = Math.sin(((double) rotationYaw * 3.1415926535897931D) / 180D);
      for (int i1 = 0; (double) i1 < 1.0D + d1 * 60D; i1++) {
        double d16 = rand.nextFloat() * 2.0F - 1.0F;
        double d19 = (double) (rand.nextInt(2) * 2 - 1) * 0.69999999999999996D;
        if (rand.nextBoolean()) {
          double d21 = (posX - d3 * d16 * 0.80000000000000004D) + d9 * d19;
          double d23 = posZ - d9 * d16 * 0.80000000000000004D - d3 * d19;
          worldObj.spawnParticle("splash", d21, posY - 0.125D, d23, motionX, motionY, motionZ);
        } else {
          double d22 = posX + d3 + d9 * d16 * 0.69999999999999996D;
          double d24 = (posZ + d9) - d3 * d16 * 0.69999999999999996D;
          worldObj.spawnParticle("splash", d22, posY - 0.125D, d24, motionX, motionY, motionZ);
        }
      }
    }
    if (worldObj.isRemote) {
      if (boatPosRotationIncrements > 0) {
        double d4 = posX + (boatX - posX) / (double) boatPosRotationIncrements;
        double d10 = posY + (boatY - posY) / (double) boatPosRotationIncrements;
        double d13 = posZ + (boatZ - posZ) / (double) boatPosRotationIncrements;
        double d17;
        for (d17 = boatYaw - (double) rotationYaw; d17 < -180D; d17 += 360D) {}
        for (; d17 >= 180D; d17 -= 360D) {}
        rotationYaw += d17 / (double) boatPosRotationIncrements;
        rotationPitch += (boatPitch - (double) rotationPitch) / (double) boatPosRotationIncrements;
        boatPosRotationIncrements--;
        setPosition(d4, d10, d13);
        setRotation(rotationYaw, rotationPitch);
      } else {
        double d5 = posX + motionX;
        double d11 = posY + motionY;
        double d14 = posZ + motionZ;
        setPosition(d5, d11, d14);
        if (onGround) {
          motionX *= 0.5D;
          motionY *= 0.5D;
          motionZ *= 0.5D;
        }
        motionX *= 0.99000000953674316D;
        motionY *= 0.94999998807907104D;
        motionZ *= 0.99000000953674316D;
      }
      return;
    }
    if (d < 1.0D) {
      double d6 = d * 2D - 1.0D;
      motionY += 0.039999999105930328D * d6;
    } else {
      if (motionY < 0.0D) {
        motionY /= 2D;
      }
      motionY += 0.0070000002160668373D;
    }
    if (riddenByEntity != null) {
      motionX += riddenByEntity.motionX * 0.20000000000000001D;
      motionZ += riddenByEntity.motionZ * 0.20000000000000001D;
    }
    double d7 = 0.40000000000000002D;
    if (motionX < -d7) {
      motionX = -d7;
    }
    if (motionX > d7) {
      motionX = d7;
    }
    if (motionZ < -d7) {
      motionZ = -d7;
    }
    if (motionZ > d7) {
      motionZ = d7;
    }
    if (onGround) {
      motionX *= 0.5D;
      motionY *= 0.5D;
      motionZ *= 0.5D;
    }
    moveEntity(motionX, motionY, motionZ);
    if (isCollidedHorizontally && d1 > 0.20000000000000001D) {
      if (!worldObj.isRemote) {
        setDead();
        for (int j = 0; j < 5; j++) {
          entityDropItem(new ItemStack(FloraTrees.redwood, 1, 8), 0F);
        }
      }
    } else {
      motionX *= 0.99000000953674316D;
      motionY *= 0.94999998807907104D;
      motionZ *= 0.99000000953674316D;
    }
    rotationPitch = 0.0F;
    double d12 = rotationYaw;
    double d15 = prevPosX - posX;
    double d18 = prevPosZ - posZ;
    if (d15 * d15 + d18 * d18 > 0.001D) {
      d12 = (float) ((Math.atan2(d18, d15) * 180D) / 3.1415926535897931D);
    }
    double d20;
    for (d20 = d12 - (double) rotationYaw; d20 >= 180D; d20 -= 360D) {}
    for (; d20 < -180D; d20 += 360D) {}
    if (d20 > 20D) {
      d20 = 20D;
    }
    if (d20 < -20D) {
      d20 = -20D;
    }
    rotationYaw += d20;
    setRotation(rotationYaw, rotationPitch);
    List list =
        worldObj.getEntitiesWithinAABBExcludingEntity(
            this, boundingBox.expand(0.20000000298023224D, 0.0D, 0.20000000298023224D));
    if (list != null && list.size() > 0) {
      for (int j1 = 0; j1 < list.size(); j1++) {
        Entity entity = (Entity) list.get(j1);
        if (entity != riddenByEntity
            && entity.canBePushed()
            && (entity instanceof EucalyptusBoat)) {
          entity.applyEntityCollision(this);
        }
      }
    }
    for (int k1 = 0; k1 < 4; k1++) {
      int l1 = MathHelper.floor_double(posX + ((double) (k1 % 2) - 0.5D) * 0.80000000000000004D);
      int i2 = MathHelper.floor_double(posY);
      int j2 = MathHelper.floor_double(posZ + ((double) (k1 / 2) - 0.5D) * 0.80000000000000004D);
      if (worldObj.getBlockId(l1, i2, j2) == Block.snow.blockID) {
        worldObj.setBlockWithNotify(l1, i2, j2, 0);
      }
    }

    if (riddenByEntity != null && riddenByEntity.isDead) {
      riddenByEntity = null;
    }
  }
Пример #4
0
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    super.onUpdate();

    if (this.getTimeSinceHit() > 0) {
      this.setTimeSinceHit(this.getTimeSinceHit() - 1);
    }

    if (this.getDamageTaken() > 0) {
      this.setDamageTaken(this.getDamageTaken() - 1);
    }

    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    byte var1 = 5;
    double var2 = 0.0D;

    for (int var4 = 0; var4 < var1; ++var4) {
      double var5 =
          this.boundingBox.minY
              + (this.boundingBox.maxY - this.boundingBox.minY)
                  * (double) (var4 + 0)
                  / (double) var1
              - 0.125D;
      double var7 =
          this.boundingBox.minY
              + (this.boundingBox.maxY - this.boundingBox.minY)
                  * (double) (var4 + 1)
                  / (double) var1
              - 0.125D;
      AxisAlignedBB var9 =
          AxisAlignedBB.getBoundingBoxFromPool(
              this.boundingBox.minX,
              var5,
              this.boundingBox.minZ,
              this.boundingBox.maxX,
              var7,
              this.boundingBox.maxZ);

      if (this.worldObj.isAABBInMaterial(var9, Material.water)) {
        var2 += 1.0D / (double) var1;
      }
    }

    double var21 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
    double var6;
    double var8;

    if (var21 > 0.15D) {
      var6 = Math.cos((double) this.rotationYaw * Math.PI / 180.0D);
      var8 = Math.sin((double) this.rotationYaw * Math.PI / 180.0D);

      for (int var10 = 0; (double) var10 < 1.0D + var21 * 60.0D; ++var10) {
        double var11 = (double) (this.rand.nextFloat() * 2.0F - 1.0F);
        double var13 = (double) (this.rand.nextInt(2) * 2 - 1) * 0.7D;
        double var15;
        double var17;

        if (this.rand.nextBoolean()) {
          var15 = this.posX - var6 * var11 * 0.8D + var8 * var13;
          var17 = this.posZ - var8 * var11 * 0.8D - var6 * var13;
          this.worldObj.spawnParticle(
              "splash", var15, this.posY - 0.125D, var17, this.motionX, this.motionY, this.motionZ);
        } else {
          var15 = this.posX + var6 + var8 * var11 * 0.7D;
          var17 = this.posZ + var8 - var6 * var11 * 0.7D;
          this.worldObj.spawnParticle(
              "splash", var15, this.posY - 0.125D, var17, this.motionX, this.motionY, this.motionZ);
        }
      }
    }

    double var12;
    double var23;

    if (this.worldObj.isRemote) {
      if (this.boatPosRotationIncrements > 0) {
        var6 = this.posX + (this.boatX - this.posX) / (double) this.boatPosRotationIncrements;
        var8 = this.posY + (this.boatY - this.posY) / (double) this.boatPosRotationIncrements;
        var23 = this.posZ + (this.boatZ - this.posZ) / (double) this.boatPosRotationIncrements;

        for (var12 = this.boatYaw - (double) this.rotationYaw; var12 < -180.0D; var12 += 360.0D) {;
        }

        while (var12 >= 180.0D) {
          var12 -= 360.0D;
        }

        this.rotationYaw =
            (float) ((double) this.rotationYaw + var12 / (double) this.boatPosRotationIncrements);
        this.rotationPitch =
            (float)
                ((double) this.rotationPitch
                    + (this.boatPitch - (double) this.rotationPitch)
                        / (double) this.boatPosRotationIncrements);
        --this.boatPosRotationIncrements;
        this.setPosition(var6, var8, var23);
        this.setRotation(this.rotationYaw, this.rotationPitch);
      } else {
        var6 = this.posX + this.motionX;
        var8 = this.posY + this.motionY;
        var23 = this.posZ + this.motionZ;
        this.setPosition(var6, var8, var23);

        if (this.onGround) {
          this.motionX *= 0.5D;
          this.motionY *= 0.5D;
          this.motionZ *= 0.5D;
        }

        this.motionX *= 0.9900000095367432D;
        this.motionY *= 0.949999988079071D;
        this.motionZ *= 0.9900000095367432D;
      }
    } else {
      if (var2 < 1.0D) {
        var6 = var2 * 2.0D - 1.0D;
        this.motionY += 0.03999999910593033D * var6;
      } else {
        if (this.motionY < 0.0D) {
          this.motionY /= 2.0D;
        }

        this.motionY += 0.007000000216066837D;
      }

      if (this.riddenByEntity != null) {
        this.motionX += this.riddenByEntity.motionX * 0.2D;
        this.motionZ += this.riddenByEntity.motionZ * 0.2D;
      }

      var6 = 0.4D;

      if (this.motionX < -var6) {
        this.motionX = -var6;
      }

      if (this.motionX > var6) {
        this.motionX = var6;
      }

      if (this.motionZ < -var6) {
        this.motionZ = -var6;
      }

      if (this.motionZ > var6) {
        this.motionZ = var6;
      }

      if (this.onGround) {
        this.motionX *= 0.5D;
        this.motionY *= 0.5D;
        this.motionZ *= 0.5D;
      }

      this.moveEntity(this.motionX, this.motionY, this.motionZ);

      if (this.isCollidedHorizontally && var21 > 0.2D) {
        if (!this.worldObj.isRemote) {
          this.setDead();
          int var22;

          for (var22 = 0; var22 < 3; ++var22) {
            this.dropItemWithOffset(Block.planks.blockID, 1, 0.0F);
          }

          for (var22 = 0; var22 < 2; ++var22) {
            this.dropItemWithOffset(Item.stick.shiftedIndex, 1, 0.0F);
          }
        }
      } else {
        this.motionX *= 0.9900000095367432D;
        this.motionY *= 0.949999988079071D;
        this.motionZ *= 0.9900000095367432D;
      }

      this.rotationPitch = 0.0F;
      var8 = (double) this.rotationYaw;
      var23 = this.prevPosX - this.posX;
      var12 = this.prevPosZ - this.posZ;

      if (var23 * var23 + var12 * var12 > 0.001D) {
        var8 = (double) ((float) (Math.atan2(var12, var23) * 180.0D / Math.PI));
      }

      double var14;

      for (var14 = var8 - (double) this.rotationYaw; var14 >= 180.0D; var14 -= 360.0D) {;
      }

      while (var14 < -180.0D) {
        var14 += 360.0D;
      }

      if (var14 > 20.0D) {
        var14 = 20.0D;
      }

      if (var14 < -20.0D) {
        var14 = -20.0D;
      }

      this.rotationYaw = (float) ((double) this.rotationYaw + var14);
      this.setRotation(this.rotationYaw, this.rotationPitch);
      List var16 =
          this.worldObj.getEntitiesWithinAABBExcludingEntity(
              this, this.boundingBox.expand(0.20000000298023224D, 0.0D, 0.20000000298023224D));
      int var24;

      if (var16 != null && var16.size() > 0) {
        for (var24 = 0; var24 < var16.size(); ++var24) {
          Entity var18 = (Entity) var16.get(var24);

          if (var18 != this.riddenByEntity && var18.canBePushed() && var18 instanceof EntityBoat) {
            var18.applyEntityCollision(this);
          }
        }
      }

      for (var24 = 0; var24 < 4; ++var24) {
        int var25 = MathHelper.floor_double(this.posX + ((double) (var24 % 2) - 0.5D) * 0.8D);
        int var19 = MathHelper.floor_double(this.posY);
        int var20 = MathHelper.floor_double(this.posZ + ((double) (var24 / 2) - 0.5D) * 0.8D);

        if (this.worldObj.getBlockId(var25, var19, var20) == Block.snow.blockID) {
          this.worldObj.setBlockWithNotify(var25, var19, var20, 0);
        }
      }

      if (this.riddenByEntity != null && this.riddenByEntity.isDead) {
        this.riddenByEntity = null;
      }
    }
  }
Пример #5
0
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    if (func_41019_p() > 0) {
      func_41014_b(func_41019_p() - 1);
    }

    if (func_41020_o() > 0) {
      func_41018_e_(func_41020_o() - 1);
    }

    if (isMinecartPowered() && rand.nextInt(4) == 0) {
      worldObj.spawnParticle("largesmoke", posX, posY + 0.8D, posZ, 0.0D, 0.0D, 0.0D);
    }

    if (worldObj.isRemote) {
      if (turnProgress > 0) {
        double d = posX + (minecartX - posX) / (double) turnProgress;
        double d1 = posY + (minecartY - posY) / (double) turnProgress;
        double d3 = posZ + (minecartZ - posZ) / (double) turnProgress;
        double d5;

        for (d5 = minecartYaw - (double) rotationYaw; d5 < -180D; d5 += 360D) {}

        for (; d5 >= 180D; d5 -= 360D) {}

        rotationYaw += d5 / (double) turnProgress;
        rotationPitch += (minecartPitch - (double) rotationPitch) / (double) turnProgress;
        turnProgress--;
        setPosition(d, d1, d3);
        setRotation(rotationYaw, rotationPitch);
      } else {
        setPosition(posX, posY, posZ);
        setRotation(rotationYaw, rotationPitch);
      }

      return;
    }

    prevPosX = posX;
    prevPosY = posY;
    prevPosZ = posZ;
    motionY -= 0.04D;
    int i = MathHelper.floor_double(posX);
    int j = MathHelper.floor_double(posY);
    int k = MathHelper.floor_double(posZ);

    if (BlockRail.isRailBlockAt(worldObj, i, j - 1, k)) {
      j--;
    }

    double d2 = 0.4D;
    double d4 = 0.0078125D;
    int l = worldObj.getBlockId(i, j, k);

    if (BlockRail.isRailBlock(l)) {
      Vec3D vec3d = func_182_g(posX, posY, posZ);
      int i1 = worldObj.getBlockMetadata(i, j, k);
      posY = j;
      boolean flag = false;
      boolean flag1 = false;

      if (l == Block.railPowered.blockID) {
        flag = (i1 & 8) != 0;
        flag1 = !flag;
      }

      if (((BlockRail) Block.blocksList[l]).isPowered()) {
        i1 &= 7;
      }

      if (i1 >= 2 && i1 <= 5) {
        posY = j + 1;
      }

      if (i1 == 2) {
        motionX -= d4;
      }

      if (i1 == 3) {
        motionX += d4;
      }

      if (i1 == 4) {
        motionZ += d4;
      }

      if (i1 == 5) {
        motionZ -= d4;
      }

      int ai[][] = field_468_ak[i1];
      double d9 = ai[1][0] - ai[0][0];
      double d10 = ai[1][2] - ai[0][2];
      double d11 = Math.sqrt(d9 * d9 + d10 * d10);
      double d12 = motionX * d9 + motionZ * d10;

      if (d12 < 0.0D) {
        d9 = -d9;
        d10 = -d10;
      }

      double d13 = Math.sqrt(motionX * motionX + motionZ * motionZ);
      motionX = (d13 * d9) / d11;
      motionZ = (d13 * d10) / d11;

      if (flag1) {
        double d16 = Math.sqrt(motionX * motionX + motionZ * motionZ);

        if (d16 < 0.03D) {
          motionX *= 0.0D;
          motionY *= 0.0D;
          motionZ *= 0.0D;
        } else {
          motionX *= 0.5D;
          motionY *= 0.0D;
          motionZ *= 0.5D;
        }
      }

      double d17 = 0.0D;
      double d18 = (double) i + 0.5D + (double) ai[0][0] * 0.5D;
      double d19 = (double) k + 0.5D + (double) ai[0][2] * 0.5D;
      double d20 = (double) i + 0.5D + (double) ai[1][0] * 0.5D;
      double d21 = (double) k + 0.5D + (double) ai[1][2] * 0.5D;
      d9 = d20 - d18;
      d10 = d21 - d19;

      if (d9 == 0.0D) {
        posX = (double) i + 0.5D;
        d17 = posZ - (double) k;
      } else if (d10 == 0.0D) {
        posZ = (double) k + 0.5D;
        d17 = posX - (double) i;
      } else {
        double d22 = posX - d18;
        double d24 = posZ - d19;
        double d26 = (d22 * d9 + d24 * d10) * 2D;
        d17 = d26;
      }

      posX = d18 + d9 * d17;
      posZ = d19 + d10 * d17;
      setPosition(posX, posY + (double) yOffset, posZ);
      double d23 = motionX;
      double d25 = motionZ;

      if (riddenByEntity != null) {
        d23 *= 0.75D;
        d25 *= 0.75D;
      }

      if (d23 < -d2) {
        d23 = -d2;
      }

      if (d23 > d2) {
        d23 = d2;
      }

      if (d25 < -d2) {
        d25 = -d2;
      }

      if (d25 > d2) {
        d25 = d2;
      }

      moveEntity(d23, 0.0D, d25);

      if (ai[0][1] != 0
          && MathHelper.floor_double(posX) - i == ai[0][0]
          && MathHelper.floor_double(posZ) - k == ai[0][2]) {
        setPosition(posX, posY + (double) ai[0][1], posZ);
      } else if (ai[1][1] != 0
          && MathHelper.floor_double(posX) - i == ai[1][0]
          && MathHelper.floor_double(posZ) - k == ai[1][2]) {
        setPosition(posX, posY + (double) ai[1][1], posZ);
      }

      if (riddenByEntity != null) {
        motionX *= 0.997D;
        motionY *= 0.0D;
        motionZ *= 0.997D;
      } else {
        if (minecartType == 2) {
          double d27 = MathHelper.sqrt_double(pushX * pushX + pushZ * pushZ);

          if (d27 > 0.01D) {
            pushX /= d27;
            pushZ /= d27;
            double d29 = 0.04D;
            motionX *= 0.8D;
            motionY *= 0.0D;
            motionZ *= 0.8D;
            motionX += pushX * d29;
            motionZ += pushZ * d29;
          } else {
            motionX *= 0.9D;
            motionY *= 0.0D;
            motionZ *= 0.9D;
          }
        }

        motionX *= 0.96D;
        motionY *= 0.0D;
        motionZ *= 0.96D;
      }

      Vec3D vec3d1 = func_182_g(posX, posY, posZ);

      if (vec3d1 != null && vec3d != null) {
        double d28 = (vec3d.yCoord - vec3d1.yCoord) * 0.05D;
        double d14 = Math.sqrt(motionX * motionX + motionZ * motionZ);

        if (d14 > 0.0D) {
          motionX = (motionX / d14) * (d14 + d28);
          motionZ = (motionZ / d14) * (d14 + d28);
        }

        setPosition(posX, vec3d1.yCoord, posZ);
      }

      int k1 = MathHelper.floor_double(posX);
      int l1 = MathHelper.floor_double(posZ);

      if (k1 != i || l1 != k) {
        double d15 = Math.sqrt(motionX * motionX + motionZ * motionZ);
        motionX = d15 * (double) (k1 - i);
        motionZ = d15 * (double) (l1 - k);
      }

      if (minecartType == 2) {
        double d30 = MathHelper.sqrt_double(pushX * pushX + pushZ * pushZ);

        if (d30 > 0.01D && motionX * motionX + motionZ * motionZ > 0.001D) {
          pushX /= d30;
          pushZ /= d30;

          if (pushX * motionX + pushZ * motionZ < 0.0D) {
            pushX = 0.0D;
            pushZ = 0.0D;
          } else {
            pushX = motionX;
            pushZ = motionZ;
          }
        }
      }

      if (flag) {
        double d31 = Math.sqrt(motionX * motionX + motionZ * motionZ);

        if (d31 > 0.01D) {
          double d32 = 0.04D;
          motionX += (motionX / d31) * d32;
          motionZ += (motionZ / d31) * d32;
        } else if (i1 == 1) {
          if (worldObj.isBlockNormalCube(i - 1, j, k)) {
            motionX = 0.02D;
          } else if (worldObj.isBlockNormalCube(i + 1, j, k)) {
            motionX = -0.02D;
          }
        } else if (i1 == 0) {
          if (worldObj.isBlockNormalCube(i, j, k - 1)) {
            motionZ = 0.02D;
          } else if (worldObj.isBlockNormalCube(i, j, k + 1)) {
            motionZ = -0.02D;
          }
        }
      }
    } else {
      if (motionX < -d2) {
        motionX = -d2;
      }

      if (motionX > d2) {
        motionX = d2;
      }

      if (motionZ < -d2) {
        motionZ = -d2;
      }

      if (motionZ > d2) {
        motionZ = d2;
      }

      if (onGround) {
        motionX *= 0.5D;
        motionY *= 0.5D;
        motionZ *= 0.5D;
      }

      moveEntity(motionX, motionY, motionZ);

      if (!onGround) {
        motionX *= 0.95D;
        motionY *= 0.95D;
        motionZ *= 0.95D;
      }
    }

    rotationPitch = 0.0F;
    double d6 = prevPosX - posX;
    double d7 = prevPosZ - posZ;

    if (d6 * d6 + d7 * d7 > 0.001D) {
      rotationYaw = (float) ((Math.atan2(d7, d6) * 180D) / Math.PI);

      if (field_469_aj) {
        rotationYaw += 180F;
      }
    }

    double d8;

    for (d8 = rotationYaw - prevRotationYaw; d8 >= 180D; d8 -= 360D) {}

    for (; d8 < -180D; d8 += 360D) {}

    if (d8 < -170D || d8 >= 170D) {
      rotationYaw += 180F;
      field_469_aj = !field_469_aj;
    }

    setRotation(rotationYaw, rotationPitch);
    List list =
        worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(0.2D, 0.0D, 0.2D));

    if (list != null && list.size() > 0) {
      for (int j1 = 0; j1 < list.size(); j1++) {
        Entity entity = (Entity) list.get(j1);

        if (entity != riddenByEntity
            && entity.canBePushed()
            && (entity instanceof EntityMinecart)) {
          entity.applyEntityCollision(this);
        }
      }
    }

    if (riddenByEntity != null && riddenByEntity.isDead) {
      if (riddenByEntity.ridingEntity == this) {
        riddenByEntity.ridingEntity = null;
      }

      riddenByEntity = null;
    }

    if (fuel > 0) {
      fuel--;
    }

    if (fuel <= 0) {
      pushX = pushZ = 0.0D;
    }

    setMinecartPowered(fuel > 0);
  }
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    super.onUpdate();

    if (this.getTimeSinceHit() > 0) {
      this.setTimeSinceHit(this.getTimeSinceHit() - 1);
    }

    if (this.getDamageTaken() > 0) {
      this.setDamageTaken(this.getDamageTaken() - 1);
    }

    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    byte var1 = 5;
    double var2 = 0.0D;

    for (int var4 = 0; var4 < var1; ++var4) {
      double var5 =
          this.boundingBox.minY
              + (this.boundingBox.maxY - this.boundingBox.minY)
                  * (double) (var4 + 0)
                  / (double) var1
              - 0.125D;
      double var7 =
          this.boundingBox.minY
              + (this.boundingBox.maxY - this.boundingBox.minY)
                  * (double) (var4 + 1)
                  / (double) var1
              - 0.125D;
      AxisAlignedBB var9 =
          AxisAlignedBB.getAABBPool()
              .addOrModifyAABBInPool(
                  this.boundingBox.minX,
                  var5,
                  this.boundingBox.minZ,
                  this.boundingBox.maxX,
                  var7,
                  this.boundingBox.maxZ);

      if (this.worldObj.isAABBInMaterial(var9, Material.water)) {
        var2 += 1.0D / (double) var1;
      }
    }

    double var24 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
    double var6;
    double var8;

    if (var24 > 0.26249999999999996D) {
      var6 = Math.cos((double) this.rotationYaw * Math.PI / 180.0D);
      var8 = Math.sin((double) this.rotationYaw * Math.PI / 180.0D);

      for (int var10 = 0; (double) var10 < 1.0D + var24 * 60.0D; ++var10) {
        double var11 = (double) (this.rand.nextFloat() * 2.0F - 1.0F);
        double var13 = (double) (this.rand.nextInt(2) * 2 - 1) * 0.7D;
        double var15;
        double var17;

        if (this.rand.nextBoolean()) {
          var15 = this.posX - var6 * var11 * 0.8D + var8 * var13;
          var17 = this.posZ - var8 * var11 * 0.8D - var6 * var13;
          this.worldObj.spawnParticle(
              "splash", var15, this.posY - 0.125D, var17, this.motionX, this.motionY, this.motionZ);
        } else {
          var15 = this.posX + var6 + var8 * var11 * 0.7D;
          var17 = this.posZ + var8 - var6 * var11 * 0.7D;
          this.worldObj.spawnParticle(
              "splash", var15, this.posY - 0.125D, var17, this.motionX, this.motionY, this.motionZ);
        }
      }
    }

    double var12;
    double var26;

    if (this.worldObj.isRemote && this.field_70279_a) {
      if (this.boatPosRotationIncrements > 0) {
        var6 = this.posX + (this.boatX - this.posX) / (double) this.boatPosRotationIncrements;
        var8 = this.posY + (this.boatY - this.posY) / (double) this.boatPosRotationIncrements;
        var26 = this.posZ + (this.boatZ - this.posZ) / (double) this.boatPosRotationIncrements;
        var12 = MathHelper.wrapAngleTo180_double(this.boatYaw - (double) this.rotationYaw);
        this.rotationYaw =
            (float) ((double) this.rotationYaw + var12 / (double) this.boatPosRotationIncrements);
        this.rotationPitch =
            (float)
                ((double) this.rotationPitch
                    + (this.boatPitch - (double) this.rotationPitch)
                        / (double) this.boatPosRotationIncrements);
        --this.boatPosRotationIncrements;
        this.setPosition(var6, var8, var26);
        this.setRotation(this.rotationYaw, this.rotationPitch);
      } else {
        var6 = this.posX + this.motionX;
        var8 = this.posY + this.motionY;
        var26 = this.posZ + this.motionZ;
        this.setPosition(var6, var8, var26);

        if (this.onGround) {
          this.motionX *= 0.5D;
          this.motionY *= 0.5D;
          this.motionZ *= 0.5D;
        }

        this.motionX *= 0.9900000095367432D;
        this.motionY *= 0.949999988079071D;
        this.motionZ *= 0.9900000095367432D;
      }
    } else {
      if (var2 < 1.0D) {
        var6 = var2 * 2.0D - 1.0D;
        this.motionY += 0.03999999910593033D * var6;
      } else {
        if (this.motionY < 0.0D) {
          this.motionY /= 2.0D;
        }

        this.motionY += 0.007000000216066837D;
      }

      if (this.riddenByEntity != null) {
        this.motionX += this.riddenByEntity.motionX * this.field_70276_b;
        this.motionZ += this.riddenByEntity.motionZ * this.field_70276_b;
      }

      var6 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);

      if (var6 > 0.35D) {
        var8 = 0.35D / var6;
        this.motionX *= var8;
        this.motionZ *= var8;
        var6 = 0.35D;
      }

      if (var6 > var24 && this.field_70276_b < 0.35D) {
        this.field_70276_b += (0.35D - this.field_70276_b) / 35.0D;

        if (this.field_70276_b > 0.35D) {
          this.field_70276_b = 0.35D;
        }
      } else {
        this.field_70276_b -= (this.field_70276_b - 0.07D) / 35.0D;

        if (this.field_70276_b < 0.07D) {
          this.field_70276_b = 0.07D;
        }
      }

      if (this.onGround) {
        this.motionX *= 0.5D;
        this.motionY *= 0.5D;
        this.motionZ *= 0.5D;
      }

      this.moveEntity(this.motionX, this.motionY, this.motionZ);

      if (this.isCollidedHorizontally && var24 > 0.2D) {
        if (!this.worldObj.isRemote) {
          this.setDead();
          int var25;

          for (var25 = 0; var25 < 3; ++var25) {
            this.dropItemWithOffset(Block.planks.blockID, 1, 0.0F);
          }

          for (var25 = 0; var25 < 2; ++var25) {
            this.dropItemWithOffset(Item.stick.shiftedIndex, 1, 0.0F);
          }
        }
      } else {
        this.motionX *= 0.9900000095367432D;
        this.motionY *= 0.949999988079071D;
        this.motionZ *= 0.9900000095367432D;
      }

      this.rotationPitch = 0.0F;
      var8 = (double) this.rotationYaw;
      var26 = this.prevPosX - this.posX;
      var12 = this.prevPosZ - this.posZ;

      if (var26 * var26 + var12 * var12 > 0.001D) {
        var8 = (double) ((float) (Math.atan2(var12, var26) * 180.0D / Math.PI));
      }

      double var14 = MathHelper.wrapAngleTo180_double(var8 - (double) this.rotationYaw);

      if (var14 > 20.0D) {
        var14 = 20.0D;
      }

      if (var14 < -20.0D) {
        var14 = -20.0D;
      }

      this.rotationYaw = (float) ((double) this.rotationYaw + var14);
      this.setRotation(this.rotationYaw, this.rotationPitch);

      if (!this.worldObj.isRemote) {
        List var16 =
            this.worldObj.getEntitiesWithinAABBExcludingEntity(
                this, this.boundingBox.expand(0.20000000298023224D, 0.0D, 0.20000000298023224D));
        int var27;

        if (var16 != null && !var16.isEmpty()) {
          for (var27 = 0; var27 < var16.size(); ++var27) {
            Entity var18 = (Entity) var16.get(var27);

            if (var18 != this.riddenByEntity
                && var18.canBePushed()
                && var18 instanceof EntityBoat) {
              var18.applyEntityCollision(this);
            }
          }
        }

        for (var27 = 0; var27 < 4; ++var27) {
          int var28 = MathHelper.floor_double(this.posX + ((double) (var27 % 2) - 0.5D) * 0.8D);
          int var19 = MathHelper.floor_double(this.posZ + ((double) (var27 / 2) - 0.5D) * 0.8D);

          for (int var20 = 0; var20 < 2; ++var20) {
            int var21 = MathHelper.floor_double(this.posY) + var20;
            int var22 = this.worldObj.getBlockId(var28, var21, var19);
            int var23 = this.worldObj.getBlockMetadata(var28, var21, var19);

            if (var22 == Block.snow.blockID) {
              this.worldObj.setBlockWithNotify(var28, var21, var19, 0);
            } else if (var22 == Block.waterlily.blockID) {
              Block.waterlily.dropBlockAsItemWithChance(
                  this.worldObj, var28, var21, var19, var23, 0.3F, 0);
              this.worldObj.setBlockWithNotify(var28, var21, var19, 0);
            }
          }
        }

        if (this.riddenByEntity != null && this.riddenByEntity.isDead) {
          this.riddenByEntity = null;
        }
      }
    }
  }
Пример #7
0
 /**
  * Returns a boundingBox used to collide the entity with other entities and blocks. This enables
  * the entity to be pushable on contact, like boats or minecarts.
  */
 public AxisAlignedBB getCollisionBox(Entity par1Entity) {
   return par1Entity.canBePushed() ? par1Entity.boundingBox : null;
 }
Пример #8
0
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    if (this.field_82344_g != null) {
      this.field_82344_g.update();
    }

    if (this.func_70496_j() > 0) {
      this.func_70497_h(this.func_70496_j() - 1);
    }

    if (this.getDamage() > 0) {
      this.setDamage(this.getDamage() - 1);
    }

    if (this.posY < -64.0D) {
      this.kill();
    }

    if (this.isMinecartPowered() && this.rand.nextInt(4) == 0) {
      this.worldObj.spawnParticle(
          "largesmoke", this.posX, this.posY + 0.8D, this.posZ, 0.0D, 0.0D, 0.0D);
    }

    int var2;

    if (!this.worldObj.isRemote && this.worldObj instanceof WorldServer) {
      this.worldObj.theProfiler.startSection("portal");
      MinecraftServer var1 = ((WorldServer) this.worldObj).getMinecraftServer();
      var2 = this.getMaxInPortalTime();

      if (this.inPortal) {
        if (var1.getAllowNether()) {
          if (this.ridingEntity == null && this.field_82153_h++ >= var2) {
            this.field_82153_h = var2;
            this.timeUntilPortal = this.getPortalCooldown();
            byte var3;

            if (this.worldObj.provider.dimensionId == -1) {
              var3 = 0;
            } else {
              var3 = -1;
            }

            this.travelToDimension(var3);
          }

          this.inPortal = false;
        }
      } else {
        if (this.field_82153_h > 0) {
          this.field_82153_h -= 4;
        }

        if (this.field_82153_h < 0) {
          this.field_82153_h = 0;
        }
      }

      if (this.timeUntilPortal > 0) {
        --this.timeUntilPortal;
      }

      this.worldObj.theProfiler.endSection();
    }

    if (this.worldObj.isRemote) {
      if (this.turnProgress > 0) {
        double var46 = this.posX + (this.minecartX - this.posX) / (double) this.turnProgress;
        double var48 = this.posY + (this.minecartY - this.posY) / (double) this.turnProgress;
        double var5 = this.posZ + (this.minecartZ - this.posZ) / (double) this.turnProgress;
        double var7 =
            MathHelper.wrapAngleTo180_double(this.minecartYaw - (double) this.rotationYaw);
        this.rotationYaw = (float) ((double) this.rotationYaw + var7 / (double) this.turnProgress);
        this.rotationPitch =
            (float)
                ((double) this.rotationPitch
                    + (this.minecartPitch - (double) this.rotationPitch)
                        / (double) this.turnProgress);
        --this.turnProgress;
        this.setPosition(var46, var48, var5);
        this.setRotation(this.rotationYaw, this.rotationPitch);
      } else {
        this.setPosition(this.posX, this.posY, this.posZ);
        this.setRotation(this.rotationYaw, this.rotationPitch);
      }
    } else {
      this.prevPosX = this.posX;
      this.prevPosY = this.posY;
      this.prevPosZ = this.posZ;
      this.motionY -= 0.03999999910593033D;
      int var45 = MathHelper.floor_double(this.posX);
      var2 = MathHelper.floor_double(this.posY);
      int var47 = MathHelper.floor_double(this.posZ);

      if (BlockRail.isRailBlockAt(this.worldObj, var45, var2 - 1, var47)) {
        --var2;
      }

      double var4 = 0.4D;
      double var6 = 0.0078125D;
      int var8 = this.worldObj.getBlockId(var45, var2, var47);

      if (BlockRail.isRailBlock(var8)) {
        this.fallDistance = 0.0F;
        Vec3 var9 = this.func_70489_a(this.posX, this.posY, this.posZ);
        int var10 = this.worldObj.getBlockMetadata(var45, var2, var47);
        this.posY = (double) var2;
        boolean var11 = false;
        boolean var12 = false;

        if (var8 == Block.railPowered.blockID) {
          var11 = (var10 & 8) != 0;
          var12 = !var11;
        }

        if (((BlockRail) Block.blocksList[var8]).isPowered()) {
          var10 &= 7;
        }

        if (var10 >= 2 && var10 <= 5) {
          this.posY = (double) (var2 + 1);
        }

        if (var10 == 2) {
          this.motionX -= var6;
        }

        if (var10 == 3) {
          this.motionX += var6;
        }

        if (var10 == 4) {
          this.motionZ += var6;
        }

        if (var10 == 5) {
          this.motionZ -= var6;
        }

        int[][] var13 = field_70500_g[var10];
        double var14 = (double) (var13[1][0] - var13[0][0]);
        double var16 = (double) (var13[1][2] - var13[0][2]);
        double var18 = Math.sqrt(var14 * var14 + var16 * var16);
        double var20 = this.motionX * var14 + this.motionZ * var16;

        if (var20 < 0.0D) {
          var14 = -var14;
          var16 = -var16;
        }

        double var22 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
        this.motionX = var22 * var14 / var18;
        this.motionZ = var22 * var16 / var18;
        double var24;
        double var26;

        if (this.riddenByEntity != null) {
          var24 =
              this.riddenByEntity.motionX * this.riddenByEntity.motionX
                  + this.riddenByEntity.motionZ * this.riddenByEntity.motionZ;
          var26 = this.motionX * this.motionX + this.motionZ * this.motionZ;

          if (var24 > 1.0E-4D && var26 < 0.01D) {
            this.motionX += this.riddenByEntity.motionX * 0.1D;
            this.motionZ += this.riddenByEntity.motionZ * 0.1D;
            var12 = false;
          }
        }

        if (var12) {
          var24 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);

          if (var24 < 0.03D) {
            this.motionX *= 0.0D;
            this.motionY *= 0.0D;
            this.motionZ *= 0.0D;
          } else {
            this.motionX *= 0.5D;
            this.motionY *= 0.0D;
            this.motionZ *= 0.5D;
          }
        }

        var24 = 0.0D;
        var26 = (double) var45 + 0.5D + (double) var13[0][0] * 0.5D;
        double var28 = (double) var47 + 0.5D + (double) var13[0][2] * 0.5D;
        double var30 = (double) var45 + 0.5D + (double) var13[1][0] * 0.5D;
        double var32 = (double) var47 + 0.5D + (double) var13[1][2] * 0.5D;
        var14 = var30 - var26;
        var16 = var32 - var28;
        double var34;
        double var36;

        if (var14 == 0.0D) {
          this.posX = (double) var45 + 0.5D;
          var24 = this.posZ - (double) var47;
        } else if (var16 == 0.0D) {
          this.posZ = (double) var47 + 0.5D;
          var24 = this.posX - (double) var45;
        } else {
          var34 = this.posX - var26;
          var36 = this.posZ - var28;
          var24 = (var34 * var14 + var36 * var16) * 2.0D;
        }

        this.posX = var26 + var14 * var24;
        this.posZ = var28 + var16 * var24;
        this.setPosition(this.posX, this.posY + (double) this.yOffset, this.posZ);
        var34 = this.motionX;
        var36 = this.motionZ;

        if (this.riddenByEntity != null) {
          var34 *= 0.75D;
          var36 *= 0.75D;
        }

        if (var34 < -var4) {
          var34 = -var4;
        }

        if (var34 > var4) {
          var34 = var4;
        }

        if (var36 < -var4) {
          var36 = -var4;
        }

        if (var36 > var4) {
          var36 = var4;
        }

        this.moveEntity(var34, 0.0D, var36);

        if (var13[0][1] != 0
            && MathHelper.floor_double(this.posX) - var45 == var13[0][0]
            && MathHelper.floor_double(this.posZ) - var47 == var13[0][2]) {
          this.setPosition(this.posX, this.posY + (double) var13[0][1], this.posZ);
        } else if (var13[1][1] != 0
            && MathHelper.floor_double(this.posX) - var45 == var13[1][0]
            && MathHelper.floor_double(this.posZ) - var47 == var13[1][2]) {
          this.setPosition(this.posX, this.posY + (double) var13[1][1], this.posZ);
        }

        if (this.riddenByEntity != null) {
          this.motionX *= 0.996999979019165D;
          this.motionY *= 0.0D;
          this.motionZ *= 0.996999979019165D;
        } else {
          if (this.minecartType == 2) {
            double var38 = this.pushX * this.pushX + this.pushZ * this.pushZ;

            if (var38 > 1.0E-4D) {
              var38 = (double) MathHelper.sqrt_double(var38);
              this.pushX /= var38;
              this.pushZ /= var38;
              double var40 = 0.04D;
              this.motionX *= 0.800000011920929D;
              this.motionY *= 0.0D;
              this.motionZ *= 0.800000011920929D;
              this.motionX += this.pushX * var40;
              this.motionZ += this.pushZ * var40;
            } else {
              this.motionX *= 0.8999999761581421D;
              this.motionY *= 0.0D;
              this.motionZ *= 0.8999999761581421D;
            }
          }

          this.motionX *= 0.9599999785423279D;
          this.motionY *= 0.0D;
          this.motionZ *= 0.9599999785423279D;
        }

        Vec3 var54 = this.func_70489_a(this.posX, this.posY, this.posZ);

        if (var54 != null && var9 != null) {
          double var39 = (var9.yCoord - var54.yCoord) * 0.05D;
          var22 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);

          if (var22 > 0.0D) {
            this.motionX = this.motionX / var22 * (var22 + var39);
            this.motionZ = this.motionZ / var22 * (var22 + var39);
          }

          this.setPosition(this.posX, var54.yCoord, this.posZ);
        }

        int var53 = MathHelper.floor_double(this.posX);
        int var55 = MathHelper.floor_double(this.posZ);

        if (var53 != var45 || var55 != var47) {
          var22 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
          this.motionX = var22 * (double) (var53 - var45);
          this.motionZ = var22 * (double) (var55 - var47);
        }

        double var41;

        if (this.minecartType == 2) {
          var41 = this.pushX * this.pushX + this.pushZ * this.pushZ;

          if (var41 > 1.0E-4D
              && this.motionX * this.motionX + this.motionZ * this.motionZ > 0.001D) {
            var41 = (double) MathHelper.sqrt_double(var41);
            this.pushX /= var41;
            this.pushZ /= var41;

            if (this.pushX * this.motionX + this.pushZ * this.motionZ < 0.0D) {
              this.pushX = 0.0D;
              this.pushZ = 0.0D;
            } else {
              this.pushX = this.motionX;
              this.pushZ = this.motionZ;
            }
          }
        }

        if (var11) {
          var41 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);

          if (var41 > 0.01D) {
            double var43 = 0.06D;
            this.motionX += this.motionX / var41 * var43;
            this.motionZ += this.motionZ / var41 * var43;
          } else if (var10 == 1) {
            if (this.worldObj.isBlockNormalCube(var45 - 1, var2, var47)) {
              this.motionX = 0.02D;
            } else if (this.worldObj.isBlockNormalCube(var45 + 1, var2, var47)) {
              this.motionX = -0.02D;
            }
          } else if (var10 == 0) {
            if (this.worldObj.isBlockNormalCube(var45, var2, var47 - 1)) {
              this.motionZ = 0.02D;
            } else if (this.worldObj.isBlockNormalCube(var45, var2, var47 + 1)) {
              this.motionZ = -0.02D;
            }
          }
        }
      } else {
        if (this.motionX < -var4) {
          this.motionX = -var4;
        }

        if (this.motionX > var4) {
          this.motionX = var4;
        }

        if (this.motionZ < -var4) {
          this.motionZ = -var4;
        }

        if (this.motionZ > var4) {
          this.motionZ = var4;
        }

        if (this.onGround) {
          this.motionX *= 0.5D;
          this.motionY *= 0.5D;
          this.motionZ *= 0.5D;
        }

        this.moveEntity(this.motionX, this.motionY, this.motionZ);

        if (!this.onGround) {
          this.motionX *= 0.949999988079071D;
          this.motionY *= 0.949999988079071D;
          this.motionZ *= 0.949999988079071D;
        }
      }

      this.doBlockCollisions();
      this.rotationPitch = 0.0F;
      double var49 = this.prevPosX - this.posX;
      double var50 = this.prevPosZ - this.posZ;

      if (var49 * var49 + var50 * var50 > 0.001D) {
        this.rotationYaw = (float) (Math.atan2(var50, var49) * 180.0D / Math.PI);

        if (this.field_70499_f) {
          this.rotationYaw += 180.0F;
        }
      }

      double var51 =
          (double) MathHelper.wrapAngleTo180_float(this.rotationYaw - this.prevRotationYaw);

      if (var51 < -170.0D || var51 >= 170.0D) {
        this.rotationYaw += 180.0F;
        this.field_70499_f = !this.field_70499_f;
      }

      this.setRotation(this.rotationYaw, this.rotationPitch);
      List var15 =
          this.worldObj.getEntitiesWithinAABBExcludingEntity(
              this, this.boundingBox.expand(0.20000000298023224D, 0.0D, 0.20000000298023224D));

      if (var15 != null && !var15.isEmpty()) {
        for (int var52 = 0; var52 < var15.size(); ++var52) {
          Entity var17 = (Entity) var15.get(var52);

          if (var17 != this.riddenByEntity
              && var17.canBePushed()
              && var17 instanceof EntityMinecart) {
            var17.applyEntityCollision(this);
          }
        }
      }

      if (this.riddenByEntity != null && this.riddenByEntity.isDead) {
        if (this.riddenByEntity.ridingEntity == this) {
          this.riddenByEntity.ridingEntity = null;
        }

        this.riddenByEntity = null;
      }

      if (this.fuel > 0) {
        --this.fuel;
      }

      if (this.fuel <= 0) {
        this.pushX = this.pushZ = 0.0D;
      }

      this.setMinecartPowered(this.fuel > 0);
    }
  }