Minecraft Modding: Updating Your Mod


If you haven't been keeping up with changes in versions and want to skip a bunch of versions you might want to consider updating in order. For example, if you have something that works in 1.7.10 and want to move to 1.10.2 you might want to convert to 1.8.x then 1.9.x then 1.10.2. The reason for this is that much of the information out there is between versions that are immediate successors.

Key Point: You can use your IDE (like Eclipse) for helping you convert which I will explain in Jabelar's General Approach For Updating Your Mod tutorial.

Specific Upgrade Tips

Here, I've tried to list some (not a complete list) of the changes required for some common upgrades and this might give you enough idea to get you going.

Tip: If you are jumping past multiple versions you might want to do it in steps -- convert 1.7.10 to 1.8, then to 1.10, then to 1.12 because otherwise the number of changes might be overwhelming to convert all at once.

Easily Searching-And-Replacing Across Your Source Files

Tip: Thanks to Leviathan for this tip.

In many cases when updating you have to "search and replace" a name change throughout your code. Eclipse has a "smart" search and replace function called "refactor" which looks at the usage as well as the matching the text and is generally recommended to use refactoring when replacing something throughout your code. However, when updating a mod refactoring doesn't work well because your code is riddled with errors and so the refactoring can't really figure out context.

To avoid a tedious search-and-replace or refactoring it is possible to use an advanced text editor to do the work by looking for "regular expressions" (regex). For example, you can use Notepad++'s "find in all files" feature:

  1. Make a backup of your source (in case it hits an edge case and does something odd. The worst thing it can do is capitalise a single word that comes after a target).
  2. Open Notepad++ and press Ctrl+Shift+F to open the Find in All Files dialog. 
  3. Set it to regular expression mode and set the directory to your mod's src folder. Use the regexes in this gist and click Replace in Files.

No comments:

Post a Comment