Why aren't you just overriding Item.useOn() in your item? e.g. see DebugStickItem.useOn()
The answer to your direct question is pretty trivial
@Mod.EventBusSubscriber(modid = MODID)
public class ModEvents {
@SubscribeEvent
public static void rightClickBlock(RightClickBlock event) {
if (event.getItemStack().is(MY_ITEM.get())) {
BlockState state = event.getLevel().getBlockState(event.getPos());
Block block = state.getBlock();
// etc.
}
}
}