Archive of an old reddit comment. Original Comment Date, July 27, 2014
Mods break from update to update for a two main reasons. I'm going to try to lay them down with the most layman terms as possible, but I'm not too good at this so bear with me.
Obfuscation:
- If you try to crack open the minecraft code using a program, all you'll end up finding is a bunch of unreadable nonsense. This is very common practice in Java (the programming language minecraft happens to be written on), since programs written in Java are very easy to crack open and get access to the code (this process is called Decompiling). This is called Obfuscation, it's the process of changing all sorts of things in the code so that they can't be human read properly, but machines can still interpret it just as well as if it was written with humans in mind.
- For example. The class (a piece of code) for the Creeper is called EntityCreeper.class, if you use the MCP names (which I'll get on to in a moment). If you try to open up the minecraft code, what you'll find is wl.class (on 1.7.10, source: MCPBot) instead.
- You can't properly do work with this code, minecraft has hundreds, if not thousands of files modders work with, not to mention all of the functions (programming term for commands, on simple terms) and fields (programming term for any value something has), imagine trying to memorize all of these!
- This is where MCP (short for Minecraft Coders' Pack) comes in. It's a tool that through a large community database, tries to convert all of this nonsense into readable code. This is essential for modders, as it allows for much better searching, categorizing, understanding and obviously, readability of the code. Not only does it do this, but it also converts the modders' code into the nonsense code minecraft uses, so that you can just drop the mods in your mods folder and it's compatible.
- Now here lies the problem. Every time mojang introduces something new to the code, the obfuscation changes. By which, all of the garbled names turn into completely new garbled names and have to be translated all over again by the MCP team, which obviously takes time and effort,
- And with all the names changed, the mods have to be updated as well. Since they have the old names, they won't be compatible with new ones, so you'll crash when you try to use them.
Code Changes:
- In your post, you asked why mods don't work on new versions if all they need is there. It's simple, it's not. Minecraft code is actively changed, removed, moved, renamed, repurposed, so on. Every version something changes, because if it didn't change, there'd be no need for a new version right. And of course, every mod that relies on that will break.
- Here's some examples:
- From Minecraft 1.5 to 1.6, mojang changed the way Entities (any thing you see in the world that isn't a block, say Creepers, Zombies, Paintings, Dropped Items, XP Orbs, etc) work with the introduction of the Attribute system. So any mod that was trying to get, say, a mob's current health, using the old system, would crash the game, as that old system is no longer present.
- From Minecraft 1.6 to 1.7 mojang removed block IDs, as you might know. Each block was previously refered to as an arbitrary number (stone was 1, dirt was 2, so on). Post 1.7, they are now refered to as Strings (in code, pieces of text), so stone would be stone, wooden planks would be planks, so on. If a mod was trying to add a new block to the game using a number (as it used to be done pre-1.7), the game would crash, as the blocks no longer use numbers.
- There's a lot more of course, but these are some of the most recent ones.
- Minecraft Mods (at least most of them) are built on top of platforms, let's say. Two of the most popular are MinecraftForge and LiteLoader, you might have heard of these. They're what make mods run, and have to be updated to every version to match the new code. And obviously, these will inevitably break every version.
- These platforms allow for some cross-compatibility between version (which I'm not going to get into because it's somewhat complex). You may notice a 1.7.2 mod can work on 1.7.10, whereas MinecraftForge for 1.7.2 will explode in 1.7.10. Given of course, that the changes in the code don't impact the mod (see what I mentioned above). This is because Forge (or any other platform) directly works with the Minecraft code, whereas mods simply use the tools Forge provide, which change in tandem with the minecraft code's changes.
- I've made a mod which uses zero minecraft code (yes, that is possible) and only forge code. Obviously it doesn't add any content whatsoever. But I made that mod for Minecraft 1.3, and so far it's still working fine on every version released to date. It all depends on what the mod uses.
I hope this serves you as a proper explanation, have fun modding :-)
Obviously any experienced modder who reads this probably has a lot to add. Stuff such as Searge Names, Reflection, ASM, Internally handled block IDs so on. I don't think those are required for the explanation, so I opted to leave them out.
TLDR: Minecraft changes the way it's code looks every version, which breaks mods that are trying to look like the old one. There's also code changes that mods need to make themselves compatible with.