Read the following for information on how to write MyBB plugins.
https://docs.mybb.com/1.6/Authoring-Plugins/
It is pretty simple to understand if you are familiar with function pointers or 'hook functions'.
The MyBB code itself, is easy to understand. You can download the source code or view it
online
To write a plugin/mod you merely write a function that implements the desired functionality and register (hook) that function.
When the MyBB engine for that functionality runs, it invokes the registered functions.
More specific info can be found by reading the above document.
You will notice that all TPB links have an onion link alongside. This (I suspect) has been written as a plugin. It is a customization.
All 'official' mods are available
here.
Plugin code resides in a separate file. The core code is not modified. The code is self-documenting. No comments required. ;-)
If you can think of a good plugin for our forum, you can write one, test it and submit it. It may perhaps be accepted by admins after evaluation. ;-)