REQUIREMENTS:
Minecraft 1.19.2
Forge
This mod creates a team when the player joins the world. For every creature that spawns, it checks wether it is hostile or not: if it is aggressive, it will be added to your team hence it will not attack you.
This mod was created and tested client-side using MCreator. If you need the source code don't hesitate to ask :)
As soon as MCreator enables support for 1.19.3 I will create another version.