Java Code Examples for net.minecraft.pathfinding.Path#getCurrentPathIndex()

The following examples show how to use net.minecraft.pathfinding.Path#getCurrentPathIndex() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityEasterCow.java    From Moo-Fluids with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected float getJumpUpwardsMotion() {
  if (!collidedHorizontally && (!moveHelper.isUpdating() || moveHelper.getY() <= posY + 0.5D)) {
    final Path path = navigator.getPath();

    if (path != null && path.getCurrentPathIndex() < path.getCurrentPathLength()) {
      final Vec3d vec3d = path.getPosition(this);

      if (vec3d.y > posY) {
        return 0.5F;
      }
    }

    return moveHelper.getSpeed() <= 0.6D ? 0.2F : 0.3F;
  } else {
    return 0.5F;
  }
}
 
Example 2
Source File: EntityEasterCow.java    From Moo-Fluids with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void updateAITasks() {
  if (currentMoveTypeDuration > 0) {
    --currentMoveTypeDuration;
  }

  if (onGround) {
    if (!wasOnGround) {
      setJumping(false);
      checkLandingDelay();
    }

    if (currentMoveTypeDuration == 0) {
      final EntityLivingBase entityLivingBase = getAttackTarget();

      if (entityLivingBase != null && getDistanceSq(entityLivingBase) < 16.0D) {
        calculateRotationYaw(entityLivingBase.posX, entityLivingBase.posZ);
        moveHelper.setMoveTo(entityLivingBase.posX, entityLivingBase.posY,
                             entityLivingBase.posZ, moveHelper.getSpeed());
        startJumping();
        wasOnGround = true;
      }
    }

    final EntityEasterCow.JumpHelper
        entityEasterCow$jumpHelper =
        (EntityEasterCow.JumpHelper) jumpHelper;

    if (!entityEasterCow$jumpHelper.getIsJumping()) {
      if (moveHelper.isUpdating() && currentMoveTypeDuration == 0) {
        final Path path = navigator.getPath();
        Vec3d vec3d = new Vec3d(moveHelper.getX(), moveHelper.getY(), moveHelper.getZ());

        if (path != null && path.getCurrentPathIndex() < path.getCurrentPathLength()) {
          vec3d = path.getPosition(this);
        }

        calculateRotationYaw(vec3d.x, vec3d.z);
        startJumping();
      }
    } else if (!entityEasterCow$jumpHelper.canJump()) {
      enableJumpControl();
    }
  }

  wasOnGround = onGround;
}