Doing it a hundred times until you memorize the attacks
Or
Build a minecart track that loops in a circle, stay on it, go full speed, ml can rarely hit you since he's mainly in the center
Look up moon lord circle arena if you want more info, it's cheesy though