Add null check pointer to prevent crashes.

Add null check pointer to prevent crashes when an player stops riding an entity due to events inside the entity tick loop.