1. You should always be updated about your work timeline and its results, and project the effect generated from your work properly.
2. Don't think that you are not needed in the team, but try to understand what is the real reason behind the rude behavior of your boss.
3. Observe your boss to find out if he is behaving like this with you only, or whether it is his normal behavior.
4. If this is his normal behavior, then work according to it, and take feedback about your performance directly from him.
5. You should keep every line of dialogue open, and do not focus too much on the words used for your criticism.
6. You should also properly utilise the feedback mechanism given by your company, such as help desk, employee satisfaction survey, level meetings, feedback sessions, etc. to put forth your viewpoints in front of other officials.