There's an old A19/20 mod, "Claim Auto-Repair Block" that has very similar functionality: https://7daystodiemods.com/claim-auto-repair-block/
Not sure if it still works in A21 (would depend on if the existing code can recognize the new blocks or not, I guess), but even if it's broken there may be some ideas in there so that you don't have to reinvent the wheel.
EDIT: According to the relevant forum topic on here, the dev has quietly updated the mod for A21.