Difficulty Lock (Legacy Fabric) - Difficulty Locking in Minecraft
This minimalist mod provides an easy way to configure the difficulty level in all new Minecraft worlds. Perfect for modpacks or singleplayer gameplay if you prefer a specific default difficulty level.
Configuration Settings
The mod offers flexible settings for managing difficulty. Priority determines how conflicting settings are handled - for example, if all modes are enabled, new worlds will be created on peaceful difficulty.
forcePeaceful (default = false): Priority 1 - sets difficulty of any world to peaceful
forceEasy (default = false): Priority 2 - sets difficulty of any world to easy
forceNormal (default = false): Priority 3 - sets difficulty of any world to normal
forceHard (default = true): Priority 4 - sets difficulty of any world to hard
shouldLockDifficulty (default = true): Locks difficulty in any world, preventing its change
shouldChangeDifficultyWhenAlreadyLocked (default = false): Allows changing difficulty in worlds where it was already locked
With default settings, all worlds will be created on hard difficulty with locked change capability:

Requirements
Requires the Collective (Fabric) library mod and Fabric API.
This is the version for Legacy Fabric 1.16 and 1.17. New files and updates have been moved to the main project page. For Forge versions and Fabric 1.18+, use the main version of the mod.
Video reviews and demonstrations are available on the author's YouTube channel.