Minecraft protection?

I have been making a guardian farm and recently I died and lost all my stuff to the guardians. I was just wondering what type of protection would help the most against guardians.

I was thinking about bringing some buckets of milk and invisibility potions.

I’ve’ been trying to make good Guardian farm for awhile now but it’s too dangerous or it’s not efficient enough.