Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Minecraft server comes as a single jar. How are mods developed? How do they interact with the original jar? What is there under the hood?

What technologies are involved there? I'm mostly a C++/Python guy, but I'd like to learn something about mods development.

share|improve this question

3 Answers 3

up vote 11 down vote accepted

A JAR is simply a ZIP file, containing the various class files and other metadata used - it's a completely standardized format.

ZIP files can be extracted, and the class files can be edited as necessary for the modification. The modified files are then added back into the archive, which makes the server use the modified files instead of the original ones.

Technically, Minecraft mods are really "hacked" versions of the original code: the actual binary class files have to be modified to let the game know about the new stuff; there's no official mod support yet (although Notch has stated that they'll work on it during Beta).

Of course, that isn't a very nice way of doing things if you actively design for mods. Instead, you would design some sort of plugin architecture which allows custom code to be run where appropriate. Exactly how you would go about this depends on what you want your mods to be able to do - e.g., if security is a concern, you probably want to design the mod interface to use some sort of scripting, so you can restrict mods from doing all sorts of things to the user's computer.

share|improve this answer
    
This is not entirely true - McAdmin, for instance, was written in C# –  BlueRaja - Danny Pflughoeft Jul 15 '11 at 15:50
    
@BlueRaja: MCAdmin isn't really a mod in my opinion - it's a custom, stand-alone server. While it may allow the client to do new things via commands, I consider the two things to be different. –  Michael Madsen Jul 15 '11 at 16:27
    
Huh? No, it was definitely a mod; it was a wrapper around the minecraft server. It required the minecraft server to be running, so it wasn't standalone. I briefly looked at the source, and it appeared to intercept network messages and alter them on their way in/out. –  BlueRaja - Danny Pflughoeft Jul 15 '11 at 16:29
3  
@BlueRaja: Huh - could have sworn it was a stand-alone server, but then again, I admit that I never actually used it. It's kind of a special case, since it appears to work by acting as a proxy server between the player and the server. I still wouldn't quite call it a mod, but that may just be me. –  Michael Madsen Jul 15 '11 at 17:10

For your information, Mojang will be releasing a "Mod API" some time in the near future (during beta, so before its official release which will be around november 2011).

In fact, it will be the full source code, as mentioned on Notch's blog

http://notch.tumblr.com/post/4955141617/the-plan-for-mods

but for now, you have to "decompile" the jars, to see a partially obfuscated code and recompiling it for later use/debugging.

To do this, I highly recommend Minecraft Coder's Pack http://mcp.ocean-labs.de/index.php/MCP_Releases

there is a couple of modding tutorials on the forums too, like this one : http://www.minecraftforum.net/topic/96862-creating-mods-modding-tutorials-21511/

share|improve this answer

Single player mods are hacked versions of the original code. Multiplayer mods are different right now. They almost all use hey0's server wrapper, which links in the minecraft_server.jar (or whatever the term is in Java land) but defines its own functions classes, overloads some of the core functions, and runs its own main()

Hey0 provides a mod API. See

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.