The general principles that diesieben07 is mentioning are:
1) If you want do to something in modding, start by looking at the closest things in vanilla minecraft and see how they accomplish it.
2) The approach you take often depends on whether you're making your entirely new thing (block, item, entity) or trying to change an existing one. For your own thing, you can often just extend classes, implement interfaces and override methods as you wish. For vanilla things you need to look for "hooks" such as:
a) Many classes have publicly accessible fields and methods. For example, entity AI is public so you can totally replace it if you wanted.
b) Forge has provided a lot of hooks, especially events but also registries and ore dictiionary, that allow you to intercept and replace vanilla behavior.
c) If you really don't have either of the above, you can use Java reflection to change the access scope of the vanilla fields and methods.