How can I prevent players from having a specific item in their inventory?

You don't need mods. Spawn chunks are always loaded, put your command block there.


Alternate Method: Use a datapack to run the /clear command. This works since datapack functions are always loaded, no matter where you are in the world. You can just reference a function in the minecraft function tag tick, and in the function add

clear <selector> <item> <count>

This will always clear x item(s), from y player(s), no matter where you are.