Four things to get right first
Selectors do most of the work
@e[type=zombie,distance=..10,limit=3,sort=nearest] is the difference between a command that works and one that hits everything in the world. Narrow the selector before you worry about the rest.
Components replaced NBT on items
Modern versions give items data components such as [custom_name='"Hammer"'] instead of the old NBT blob. Old guides on the internet still use the NBT form and will not run.
A function file is just commands, one per line
Drop it at data/yourname/function/thing.mcfunction and call it with /function yourname:thing. No brackets, no JSON.
Chain with execute rather than with more command blocks
One /execute as … at … run … replaces a row of command blocks and is far easier to read a month later.
Tools that do the work
Reference, straight from the game files
Read out of the game with Mojang’s own data generator, so it matches the version exactly.
