I'm playing on a 1.12.2 version and I'm looking for a (light) way to delete a block (well replace it by air I guess) if a player right click on it (no matter if the player has an item on hand or not).
I have seen so much talking (carot stick, scoreboard etc) and ideas everywhere than I'm totally lost now. I succeeded to replace a block if the player is near it (/execute @a ~ ~ ~ fill ~-1 ~-1 ~-1 ~1 ~1 ~1 minecraft:air 0 replace minecraft:dirt), but it is not exactly what I'm looking for.
Wait... What do you want to do? allow the player to break only a specific block? If you do, items can get the "CanBreak" tag : If held in adventure mode, the player could break any block listed in the tag; you could do this for dirt
Else, as you can't use looking relative position, the easiest would be to give a custom egg with CanPlaceOn tag, then when the entity is spawned on CanPlaceOn-allowed block, it will remove the block under its feet if it's a valid block, then will be killed.