This question already has an answer here:
I like playing in peaceful mode, as I feel that making something complex in peaceful is more fulfilling than in creative. However, making many things requires items dropped only by mobs. In creative mode, mobs spawn, but simply ignore you. You can still get mob drops by killing these effectively harmless mobs. Such a feature is not present in peaceful, as mobs do not spawn at all.
My question is, is it possible, through some mod, config file editing, in-game command, etc. to make mobs spawn in peaceful, but ignore the player as if the player is in creative? Any other method that preserves the mechanics of peaceful but adds this feature will also be appreciated.
The mods that I found that offer the solution are not up to date with the current version of Minecraft.