Exporting functions is easy -- and useful! Export blocks allow you to copy functions from another mod and place it into your current mod using import blocks. Mods that contain no “main” method and just exportable functions are called “libraries”. You can use exports and libraries to keep your big mods clean, simple, and easy-to-read!
First, create two mods, one called “MyFirstLibrary” and the other called “MyTestMod”. Inside “MyFirstLibrary”, make a simple function that sends the message “Hey, this export works!” Then, drag an export block from the Misc tab above the function and type the function’s name in the box.
Now jump out and go over to “MyTestMod”. Make a “main” function, but don’t put anything in it. Drag an import block from the Misc tab and put it above your main. Now, in order to import the code you exported over in “MyFirstLibrary”, you have to type “-” into the box. So, if my nickname was Notch and I wanted to import “MyFirstLibrary”, it would look something like this:
Once you’ve imported your library, check out the Functions tab. Your “messageSender” function should be there! Grab it and drag it into your main. Run your mod, and you’ll get the “Hey this export works!” message you made in your “MyFirstLibrary” mod.