Program: 22181
Project: 22181
Buggy source:
@Override public void onUpdate(){
  super.onUpdate();
  if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) {
    float var1=MathHelper.sqrt(motionX * motionX + motionZ * motionZ);
    prevRotationYaw=rotationYaw=(float)(Math.atan2(motionX,motionZ) * 180.0D / Math.PI);
    prevRotationPitch=rotationPitch=(float)(Math.atan2(motionY,(double)var1) * 180.0D / Math.PI);
  }
  IBlockState state=world.getBlockState(tilePos);
  Block block=state.getBlock();
  if (block != null) {
    if (state.getMaterial() != Material.AIR) {
      AxisAlignedBB aabb=block.getCollisionBoundingBox(state,world,tilePos);
      if (aabb != null && aabb.contains(new Vec3d(posX,posY,posZ))) {
        inGround=true;
      }
    }
  }
  if (arrowShake > 0) {
    --arrowShake;
  }
  if (inGround && block != null) {
    int meta=block.getMetaFromState(state);
    if (block == inTile && meta == inData) {
      ++ticksInGround;
      if (ticksInGround == 1200) {
        setDead();
      }
    }
 else {
      inGround=false;
      motionX*=(double)(rand.nextFloat() * 0.2F);
      motionY*=(double)(rand.nextFloat() * 0.2F);
      motionZ*=(double)(rand.nextFloat() * 0.2F);
      ticksInGround=0;
      ticksInAir=0;
    }
  }
 else {
    ++ticksInAir;
    Vec3d posVec=new Vec3d(posX,posY,posZ);
    Vec3d motionVec=new Vec3d(posX + motionX,posY + motionY,posZ + motionZ);
    RayTraceResult rayTraceResult=world.rayTraceBlocks(posVec,motionVec,false,true,false);
    posVec=new Vec3d(posX,posY,posZ);
    motionVec=new Vec3d(posX + motionX,posY + motionY,posZ + motionZ);
    if (rayTraceResult != null) {
      motionVec=rayTraceResult.hitVec;
    }
    Entity entity=null;
    List<Entity> entities=world.getEntitiesWithinAABBExcludingEntity(this,getEntityBoundingBox().grow(motionX,motionY,motionZ).expand(1.0D,1.0D,1.0D));
    double d1=0.0D;
    float f1=0.3F;
    for (    Entity entity1 : entities) {
      if (entity1.canBeCollidedWith() && (entity1 != shootingEntity || ticksInAir >= 5)) {
        AxisAlignedBB aabb=entity1.getEntityBoundingBox().expand((double)f1,(double)f1,(double)f1);
        RayTraceResult intercept=aabb.calculateIntercept(posVec,motionVec);
        if (intercept != null) {
          double distanceTo=posVec.distanceTo(intercept.hitVec);
          if (distanceTo < d1 || d1 == 0.0D) {
            entity=entity1;
            d1=distanceTo;
          }
        }
      }
    }
    if (entity != null) {
      rayTraceResult=new RayTraceResult(entity);
    }
    if (rayTraceResult != null) {
      if (rayTraceResult.entityHit != null) {
        int damage=(int)this.damage;
        DamageSource source;
        if (shootingEntity == null || silenced) {
          source=DamageSource.causeThrownDamage(this,this);
        }
 else {
          source=DamageSource.causeThrownDamage(this,shootingEntity);
        }
        if (isBurning() && !(rayTraceResult.entityHit instanceof EntityEnderman)) {
          rayTraceResult.entityHit.setFire(5);
        }
        if (rayTraceResult.entityHit.attackEntityFrom(source,damage)) {
          if (rayTraceResult.entityHit instanceof EntityLiving) {
            EntityLiving entityHit=(EntityLiving)rayTraceResult.entityHit;
            if (!world.isRemote) {
              entityHit.setArrowCountInEntity(entityHit.getArrowCountInEntity() + 1);
            }
          }
          if (!(rayTraceResult.entityHit instanceof EntityEnderman)) {
            setDead();
          }
        }
 else {
          motionX*=-0.10000000149011612D;
          motionY*=-0.10000000149011612D;
          motionZ*=-0.10000000149011612D;
          rotationYaw+=180.0F;
          prevRotationYaw+=180.0F;
          ticksInAir=0;
        }
      }
 else {
        tilePos=rayTraceResult.getBlockPos();
        IBlockState inState=world.getBlockState(tilePos);
        inTile=inState.getBlock();
        inData=inTile.getMetaFromState(inState);
        motionX=(double)((float)(rayTraceResult.hitVec.x - posX));
        motionY=(double)((float)(rayTraceResult.hitVec.y - posY));
        motionZ=(double)((float)(rayTraceResult.hitVec.z - posZ));
        float root=MathHelper.sqrt(motionX * motionX + motionY * motionY + motionZ * motionZ);
        posX-=motionX / (double)root * 0.05000000074505806D;
        posY-=motionY / (double)root * 0.05000000074505806D;
        posZ-=motionZ / (double)root * 0.05000000074505806D;
        inGround=true;
        arrowShake=7;
        if (inTile != null) {
          inTile.onEntityCollidedWithBlock(world,tilePos,inState,this);
        }
      }
    }
    posX+=motionX;
    posY+=motionY;
    posZ+=motionZ;
    rotationYaw=(float)(Math.atan2(motionX,motionZ) * 180.0D / Math.PI);
    while (rotationPitch - prevRotationPitch >= 180.0F) {
      prevRotationPitch+=360.0F;
    }
    while (rotationYaw - prevRotationYaw < -180.0F) {
      prevRotationYaw-=360.0F;
    }
    while (rotationYaw - prevRotationYaw >= 180.0F) {
      prevRotationYaw+=360.0F;
    }
    rotationPitch=prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
    rotationYaw=prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
    float f3=0.99F;
    f1=0.05F;
    if (this.isInWater()) {
      double f2=0.25D;
      for (int i=0; i < 4; ++i) {
        world.spawnParticle(EnumParticleTypes.WATER_BUBBLE,posX - motionX * f2,posY - motionY * f2,posZ - motionZ * f2,motionX,motionY,motionZ);
      }
      f3=0.8F;
    }
    motionX*=(double)f3;
    motionY*=(double)f3;
    motionZ*=(double)f3;
    motionY-=(double)f1;
    setPosition(posX,posY,posZ);
  }
}

Fixed version (ground truth):
@Override public void onUpdate(){
  super.onUpdate();
  if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) {
    float var1=MathHelper.sqrt(motionX * motionX + motionZ * motionZ);
    prevRotationYaw=rotationYaw=(float)(Math.atan2(motionX,motionZ) * 180.0D / Math.PI);
    prevRotationPitch=rotationPitch=(float)(Math.atan2(motionY,var1) * 180.0D / Math.PI);
  }
  IBlockState state=world.getBlockState(tilePos);
  Block block=state.getBlock();
  if (block != null) {
    if (state.getMaterial() != Material.AIR) {
      AxisAlignedBB aabb=block.getCollisionBoundingBox(state,world,tilePos);
      if (aabb != null && aabb.contains(new Vec3d(posX,posY,posZ))) {
        inGround=true;
      }
    }
  }
  if (arrowShake > 0) {
    --arrowShake;
  }
  if (inGround && block != null) {
    int meta=block.getMetaFromState(state);
    if (block == inTile && meta == inData) {
      ++ticksInGround;
      if (ticksInGround == 1200) {
        setDead();
      }
    }
 else {
      inGround=false;
      motionX*=(rand.nextFloat() * 0.2F);
      motionY*=(rand.nextFloat() * 0.2F);
      motionZ*=(rand.nextFloat() * 0.2F);
      ticksInGround=0;
      ticksInAir=0;
    }
  }
 else {
    ++ticksInAir;
    Vec3d posVec=new Vec3d(posX,posY,posZ);
    Vec3d motionVec=new Vec3d(posX + motionX,posY + motionY,posZ + motionZ);
    RayTraceResult rayTraceResult=world.rayTraceBlocks(posVec,motionVec,false,true,false);
    posVec=new Vec3d(posX,posY,posZ);
    motionVec=new Vec3d(posX + motionX,posY + motionY,posZ + motionZ);
    if (rayTraceResult != null) {
      motionVec=rayTraceResult.hitVec;
    }
    Entity entity=null;
    List<Entity> entities=world.getEntitiesWithinAABBExcludingEntity(this,getEntityBoundingBox().grow(motionX,motionY,motionZ).expand(1.0D,1.0D,1.0D));
    double d1=0.0D;
    float f1=0.3F;
    for (    Entity entity1 : entities) {
      if (entity1.canBeCollidedWith() && (entity1 != shootingEntity || ticksInAir >= 5)) {
        AxisAlignedBB aabb=entity1.getEntityBoundingBox().expand(f1,f1,f1);
        RayTraceResult intercept=aabb.calculateIntercept(posVec,motionVec);
        if (intercept != null) {
          double distanceTo=posVec.distanceTo(intercept.hitVec);
          if (distanceTo < d1 || d1 == 0.0D) {
            entity=entity1;
            d1=distanceTo;
          }
        }
      }
    }
    if (entity != null) {
      rayTraceResult=new RayTraceResult(entity);
    }
    if (rayTraceResult != null) {
      if (rayTraceResult.entityHit != null) {
        int damage=(int)this.damage;
        DamageSource source;
        if (shootingEntity == null || silenced) {
          source=DamageSource.causeThrownDamage(this,this);
        }
 else {
          source=DamageSource.causeThrownDamage(this,shootingEntity);
        }
        if (isBurning() && !(rayTraceResult.entityHit instanceof EntityEnderman)) {
          rayTraceResult.entityHit.setFire(5);
        }
        if (rayTraceResult.entityHit.attackEntityFrom(source,damage)) {
          if (rayTraceResult.entityHit instanceof EntityLiving) {
            EntityLiving entityHit=(EntityLiving)rayTraceResult.entityHit;
            if (!world.isRemote) {
              entityHit.setArrowCountInEntity(entityHit.getArrowCountInEntity() + 1);
            }
          }
          if (!(rayTraceResult.entityHit instanceof EntityEnderman)) {
            setDead();
          }
        }
 else {
          motionX*=-0.10000000149011612D;
          motionY*=-0.10000000149011612D;
          motionZ*=-0.10000000149011612D;
          rotationYaw+=180.0F;
          prevRotationYaw+=180.0F;
          ticksInAir=0;
        }
      }
 else {
        tilePos=rayTraceResult.getBlockPos();
        IBlockState inState=world.getBlockState(tilePos);
        inTile=inState.getBlock();
        inData=inTile.getMetaFromState(inState);
        motionX=((float)(rayTraceResult.hitVec.x - posX));
        motionY=((float)(rayTraceResult.hitVec.y - posY));
        motionZ=((float)(rayTraceResult.hitVec.z - posZ));
        float root=MathHelper.sqrt(motionX * motionX + motionY * motionY + motionZ * motionZ);
        posX-=motionX / root * 0.05000000074505806D;
        posY-=motionY / root * 0.05000000074505806D;
        posZ-=motionZ / root * 0.05000000074505806D;
        inGround=true;
        arrowShake=7;
        if (inTile != null) {
          inTile.onEntityCollidedWithBlock(world,tilePos,inState,this);
        }
      }
    }
    posX+=motionX;
    posY+=motionY;
    posZ+=motionZ;
    rotationYaw=(float)(Math.atan2(motionX,motionZ) * 180.0D / Math.PI);
    while (rotationPitch - prevRotationPitch >= 180.0F) {
      prevRotationPitch+=360.0F;
    }
    while (rotationYaw - prevRotationYaw < -180.0F) {
      prevRotationYaw-=360.0F;
    }
    while (rotationYaw - prevRotationYaw >= 180.0F) {
      prevRotationYaw+=360.0F;
    }
    rotationPitch=prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
    rotationYaw=prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
    float f3=0.99F;
    f1=0.05F;
    if (isInWater()) {
      double f2=0.25D;
      for (int i=0; i < 4; ++i) {
        world.spawnParticle(EnumParticleTypes.WATER_BUBBLE,posX - motionX * f2,posY - motionY * f2,posZ - motionZ * f2,motionX,motionY,motionZ);
      }
      f3=0.8F;
    }
    motionX*=f3;
    motionY*=f3;
    motionZ*=f3;
    motionY-=f1;
    setPosition(posX,posY,posZ);
  }
}