My head torch broke randomly when I was out on a hike and changing the batteries. I'd only had it for a month or two when it happened and didn't want to just throw it away because it cost a good £30. All that had broke was the latch that held the back case shut and although it's a bit of a pain to disassemble and punch the pin out, it is doable.
I made a replica from measuring the broken part which is better suited to resin because it doesn't have a flat face to stick to a FDM build plate, and a simpler version which should work on FDM printers which is just a flat version. It may require some clean up as the hole on the part can shrink depending on what material you use so recommend running a drill bit through it.
I've had mine fixed for a good while now. I've been on runs and hikes with it with a PLA latch and it's been perfectly fine, but of course, even if you break the latch again, you can just print another one!
If you need to mod, I've included the step file.
EDIT: I've updated the description and also included a print file with 4 latches with and without brims. I recommend printing more than one just to allow the part to cool between layers.
Edit 2: As per request, I've included the lever as well. This one is a little more difficult as it has an overhang so if you have a resin printer that might be the better option, otherwise you will just have to live with a rough face. I've never used this part so don't know if it works, like before just use a drill bit to clear the holes as necessary.
If you don't have a printer, you can buy these parts from my website:
https://ampdesignworks.co.uk/products/black-diamond-storm-400-led-headlamp-latch-replacement
The author marked this model as their own original creation.