9
\$\begingroup\$

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.

\$\endgroup\$
0

3 Answers 3

11
\$\begingroup\$

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.

\$\endgroup\$
4
  • \$\begingroup\$ This is not entirely true - McAdmin, for instance, was written in C# \$\endgroup\$ Commented Jul 15, 2011 at 15:50
  • \$\begingroup\$ @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. \$\endgroup\$ Commented Jul 15, 2011 at 16:27
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Jul 15, 2011 at 16:29
  • 3
    \$\begingroup\$ @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. \$\endgroup\$ Commented Jul 15, 2011 at 17:10
6
\$\begingroup\$

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

\$\endgroup\$
1
\$\begingroup\$

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/

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .