You mean regarding the value resetting to 0 or regarding the whole capability implementation?
Either way, check my GitHub repository to see how I implemented it.
https://github.com/deneth-weerasinghe/PracticeMod
Note the capability's stored value is increased by 10 when right-clicking water with a custom item I made.