Share

Share

Mods/Creating mods

From Minecraft Wiki
Jump to: navigation, search
The contents of this page are not supported by Mojang AB, the Minecraft Wiki, the Minecraft IRC channel or the Minecraft Forums.

Minecraft modding is one of the most popular features introduced into the community. There are many different kinds of mods. This tutorial will present you information on how to make your very own Minecraft mod, whether it be with Modloader, Minecraft Forge or hard coded in to the core source. Some knowledge of Java is necessary; it is assumed the reader is familiar with common programming terminology. You can create mods for Minecraft on all computer operating systems that you can get PC minecraft on and on PE Android. You can play mods on these operating systems and IOS and AmazonFire TV. You can not make mods on consoles or Raspberry Pi.

Other Tutorials[edit | edit source]

For other tutorials not listed on this page (including some that are), the Minecraft Forums Modding Tutorials page will help to create your first mod. There are various tutorials for both ModLoader and Minecraft Forge.

Tools[edit | edit source]

There are many tools that can be used to mod Minecraft. The following is a list of any that people put on here or suggest in the discussion page.

  • Mod loading APIs(Application Programming Interface) standardize things, allowing for compatibility between mods. The official Minecraft API is not published yet. In the meantime, the Minecraft modding community has filled that void:
  • ModLoader is among the oldest and was previously one of the most popular mod APIs, although since it has lost most of its popularity to Minecraft Forge. It has been discontinued since the 1.6.2 version and the 1.6.2 bugfix by Acomputerdog. It loads mod class files in each minecraft version .jar file. Prior to 1.6 it and ModLoaderMP loaded mod class files in the old minecraft.jar file in the old "bin" folder. Forge and FML used to load mod class files prior to 1.5, but in 1.5 it started to load .jar and .zip mods in a new folder called "mods". ModLoader and ModloaderMP have to be installed manually by adding the classes to the version .jar files. Forge and FML were installed in the same way until 1.5 where they had installers which installed them in the libraries folder. Modloader has been around since one of the first alpha testing versions of minecraft. The creator of this modloader is called Risugami. ModLoader only works on clientside worlds.
  • ModLoaderMP has been around since the early versions of beta testing, but development was discontinued in 1.3.2.
  • Minecraft Forge is backwards-compatible with ModLoader and also adds hundreds of additional methods, classes, and utilities to assist mod authors.
  • Bukkit is a popular server-side-only server plugin API. Bukkit is supported by Dinnerbone, a member of Mojang.
  • Decompiling tools help you work with Minecraft's source code, which is not published by Mojang. These tools turn compiled, executable, java code into source code.
  • FMC(Fyddle for MineCraft) is a alternative to MCP.
  • General-purpose Java decompilers, such as JD, JAD and fernflower, will help you when MCP is not released or unavailable (for example, when modding snapshots). The best one probably is CFR because it is probably the only Java Decomiler that supports the latest Java version and JavaDevelopmentKit(JDK), Java 8. A list of Java Decompilers is here. Also fernflower is no longer being updated, but lives on in the AndroChef java decompiler which based most of it's code off fernflower. Also I think that the second best decompiler is Procyon which is open source and also supports JDK 8. The main developer for Procyon and the main developer for CFR challenged each other to develop the best java decompiler.
  • An IDE (Integrated Development Environment) is useful for any nontrivial programming. MCP automatically generates project files for use in Eclipse, a popular Java IDE. The most popular IDE at the moment is Eclipse, but the other two competitors are NetBeans(2nd) and IntelliJ(3rd). A list of Java IDEs is here. Overall Xcode is more popular than IntelliJ, but Xcode is only available on Apple Computers.
  • Compiling tools turn source code into a high-level, 3rd-5th generation, programming language. You can use these for your own mod's source code and/or the source code of other mods on GitHub and BitBucket.
  • Javac is the most popular compiler at the moment. But the Power J compiler(2nd) is very close and used to be more popular. These are followed by: Jikes(3rd), ECJ(Eclipse Compiler for Java)(4th) and GCJ(GNU Compiler for Java)(5th). A list of Java compilers can be found here and here.
  • ECJ is part of the Eclipse IDE and Power J is part of another IDE.
  • Debugging tools search for issues in the mod's code and help fix them. There is a default java debugger called jdb(Java DeBugger) which comes with JDK.
  • A list of debuggers can be found here and here. A comparison of debuggers can be found here.
  • OpenMods has made some debug tools designed for minecraft.
  • Deobfuscation tools help deobfuscate complex obfuscated code and make it easier to understand. They can help you understand more about how minecraft works and how other mods work. They can be useful when you want to continue a abandoned mod. They also let you make the code of your mod easier for other developers to understand so that the development of the mod is finished more quickly. Don't confuse these with decompiling tools.
  • MCP deals with deobfuscation as well as compiling.
  • Enigma is a deobfuscation tool made using Procycon.
  • Immibis's BON(Bearded Octo Nemesis) is a tool that also can be used for deobfuscating Minecraft-related code. It is recommended that if you want to deobfuscate using BON and also decompile the code it is recommended that you use the JDGui decompiler if you want to and also it is recommended that you use MCP if you want to.
  • Java deobfuscators for general java coding like JMD(Java Multipurpose Deobfuscator) and JBO(Java DeObfuscator) are useful too. The best java deobfuscator is probably JBO because it has got into stable release, as JMD was in development, only available as open source and development on it has stopped long ago. You can still get it and use it if you turn the source code into programming code by compiling. JBO is written in the C# programming language and is used to decompile the java programming language. You can get JBO on SourceForge(I recommend you to download non-development versions from here(in the binary folder)) and on GitHub. You can get JMD on GitHub and JavaSED.
  • Obfuscation tools help make you code harder for other programmers to read so it makes it harder for programmers to copy your code and use it to make a mod that replaces your mod. It help stops people from making unofficial copies of your mod without your permission.
  • General purpose java obfuscators will help make it easier to obfuscate your code so that people can't steal your code. The most popular java obfuscator seems to be ProGuard. There are two lists of java obfuscators found here and here.
  • The class file assembler called Jasmin is used to create java class files to put in a .jar folder. This tool creates class files inside you mod's .jar file to put your mod's code in. It generates these class files from assembly code and changes them into java code class files.
  • Class file disassemblers, such as the default JDK java class file disassembler, javap, or the opposite of Jasmin, Jaspar, are used to take apart java class files.
  • Compiler-compilers(also known as compiler generators, parser generators or lexer generators) are compiler, parser and lexer generators(parsers and lexers are parts of a compiler, parsers do parsing and lexers do lexical analysis). If you want to create your own custom compiler because none of of the compilers that exist for java suit you or maybe you want to create a compiler designed for minecraft modding and modding tools. Compiler-compilers compile a compiler from low-level programming language, 2nd generation programming language, assembly code into high-level programming language, 3rd generation programming language, java. A list of lexer generators is available here, and a list of parser generators is available here. Lexers organise assembly code and source code into high-level 3rd generation java programming language "words" and parsers organise these words into "sentences" so that the "words" can be understood as java. Currently you can't get any lexers that are separate from a compiler for java, but you can generate java lexers using java lexer generators.
  • The JavaParser(JP) is a program or parser that gets a certain instruction or command or bit of code then it breaks up that item into bits that can be processed by other programming tools or other bits of a compiler. It also makes sure that all the code put in is necessary, and it excludes the code that is not needed. JavaParser is the only java parser that is not part of a compiler. JDK has it's own parser. JavaParser was first available on GoogleCode, but since GoogleCode has become less popular and you can no longer create new projects, it has now moved to GitHub.
  • Checkmarx is a website that offers various tools from analysing source code to protecting your code by blocking risks to learning how to make your software more secure.
  • Text editors can be used to create mods, but coding using a text editor is super hard. The code they show is normally very hard for someone to understand. You might be able to understand a few bits of the code, but most of it is illegible to people who are not skilled in reading the code shown. Notepad is the default text editor for windows, but Notepad++ is probably the best, especially for coding. A list of text editors is available here and a comparison here.
  • File archivers, such as WinRAR, 7-Zip and WinZip, are useful for compressing, extracting, copying, deleting, editing, renaming and viewing class files within .jar files, .zip files, .rar files and .litemod files. They give you access to the class files within mods. A list of file acrhivers is available here.
  • Revision control software help you create many separate coding projects, some being open-source, undo and redo various edits, assign issues to yourself and others, share your code with other mod developers and code with mod developers all over the world to help create your mod. This kind of software helps you develop code more quickly, share code easily and fix problems. One of the most well known out of revision control software is probably Git which was created by Linus Torvalds(the creator of the operating system Linux). Also the company called Atlassian(the creators of BitBucket) has created tons of revision control software, the main one being JIRA. A list of revision control software is here and a comparison of revision control software is here. A list of text editors is here and a comparison here.
  • Continuous integration(CI) software help mod developers share code easily and integrate code into repositories and when you change code on a computer they can sync it with the repository on the internet. They also help test your mod and let other mod developers help you. CIs let you easily update your software several times a day. CIs also help you combine code together from other repositories. A well known CI is Jenkins which is a online software extension to JIRA and is based off of the Hudson CI tool. Bamboo by Atlassian is also another well known CI. A list of CIs is available here.
  • File synchronization software help sync files between two different locations on a computer or between two computers. When you edit one file the file on the other computer get automatically edited so the files are identical. A list of file synchronization software can be found here. You can sync mods using this.
  • Disk cloning software help cone files from one hard drive to another hard drive. A list of disk cloning software is available here and a comparison here.
  • File sharing applications help share files with other people. You can share your mod with other people using these. A list is here.
  • File hosting services are an easy way to make your mod publicly available for download or editing on the internet. They can let you upload and edit files on the internet, share links with other people and sync files between the internet and other computers. Some of the most well known file hosting services are Google Drive, Dropbox, Mediafire and MEGA. A list of file hosting services is here. Zoolz, Uploaded and File-Upload.net are not included in this list. There are two main file hosting websites for minecraft mods called CurseForge(made by Curse the company that made this wiki, also you can download(but not create) CurseForge projects from the Curse website) and Planet Minecraft.
  • Backup software help backup, save and rescue files. They help make sure you don't lose or corrupt any important files. A list is here and a comparison here.
  • Online backup services help backup files online. A list is available here.
  • Source code hosting facilities, such as GitHub, BitBucket, Google Code and SourceForge, help create open source software and mods online and edit files and share files with programmers around the world. The can let you undo and redo edits, make downloadable source code and have compiled software downloads. A list is available here.
  • Free software project directories give you a place to develop software in repositories. A list is available here.
  • Wikia is a website which lets you create wikis about your mod and what it adds into the game and how to use your mod and there are also forums that let people suggest their own ideas to make the mod better.
  • Simplified mod generators, such as Mod Maker and MCreator, exist for mod authors who don't want to have to write and compile Java code. These are not recommended as they generally create poor quality code, and are very limited.
  • Crash report analysers are forge mods that help analyse crash reports and try to find solutions to the problems. These can help mod developers find out what problems their mod has and fix those problems. The most well known is OpenEye, a 1.7.10 mod, which gathers more information on crashes. OpenEye needs OpenModsLib in order to work. OpenEye was made by OpenMods. Minecraft Crash Report Analyser, a mod for 1.7.10, helps find the solution to crashes by checking if it knows the solution to that crash, and if it does know the solution it will tell you what the solution is. Jenkins builds made by OpenMods.
  • World editing and world generation tools can help you generate or create large and complex structures and copy structures from world to world. You could input these structures into MCreator or use the structures to test how you want structures in your mod to be in your mod. If you want to create a dimension that is created in a certain way like The Lord of the Rings Mod these tools probably will help. The three world editing and world generation tools are: MCEdit, WorldPainter and WorldEdit.
  • MCEdit lets you copy, create, select, manipulate and delete structures in your world. It can also create and export MCEdit schematic files for each structure you create and you can import these to different worlds. It is also possible to create "schematic mods" by adding extra code to the schematic files, and combining the code of various items in minecraft to create new ones. A lot of "schematic mods" use armor stands and item frames for their code. These "schematic mods" are added to world saves. You just need to copy the "schematic mod" world save into your .minecraft saves folder or import the schematic file into one of your worlds using MCEdit, and the "schematic mod" is installed. These "schematic mods" can be used serverside and clientside and are technically vanilla since anyone with vanilla minecraft can use them. A few of the best schematic mods are this Remote Control Helicopter and this Camp Fire Command and Redstone "Schematic Mod". You can also use texture packs for you world saves to go with these "schematic mods".
  • WorldPainter lets you paint part of a world and a part of a world is generated it that particular way. This can be useful for making biomes and dimensions
  • Height mods are useful when you want your mod to generate massive structures above the build limit. Add in a line of code that tests to see if a height mod is installed and your mod generates larger structures. There are many height mods, but the best ones are cubic chunks mods. Normal height mods generate massive vertical chunks the vanilla way which creates tons of lag, but cubic chunks mods split the vertical chunks with horizontal lines and load 16x16 cubic chunks. These cubic chunks reduce lag because they are smaller and the game needs to to load less. So far three cubic chunks mods have been made: Robinton's Cubic Chunks Mod for 1.0.1, Barteks2x's Cubic Chunks Mod for 1.6.2(but it still works on 1.6.4), and Cuchaz's Tall Worlds Cubic Chunks Mod for 1.8.3. Robinton's Cubic Chunks Mod is a Forge mod, Barteks2x's Cubic Chunks Mod is a vanilla class file installation mod and Cuchaz's Tall Worlds Mod is a M3L mod(only M3L mod at the moment)(made using the Procyon decompiler, Cuchaz's Minecraft Mappings and Cuchaz's Enigma(and a bit of MCP), and based off the previous height mods). A list of height mods(except Barteks2x's Cubic Chunks Mod and Cuchaz's Tall Worlds Cubic Chunks Mod) is available here(Dynamic Height is downloadable from here).
  • MCPatcher is a tool that helps "patch" and fix texture errors and issues.
  • Raster graphics editors and vector graphics editors help let you edit the image files in your mod. Raster graphics editors simply edit the textures, but vector graphics editors allow you to create textures that always remain as high definition as possible. Some of the most well known raster graphics editors are Paint and Paint.NET. A list of raster graphics editors is here and a list of vector graphics editors is here.
  • Protocol analysis tools, many of which are documented on the List #mcdevs wiki, can be useful for debugging multiplayer mods.

The Minecraft Forge API[edit | edit source]

The Minecraft Forge API is a very useful tool in creating new mods. Its most important use is preventing conflicts between mods. It also contains convenience methods for creating mods more easily than without it; for example, the addSmelting method adds smelting recipes in one line of code. Many other methods exist. Tutorials on using the Forge API can be found many places, including many YouTube videos. It can be downloaded at official forge downloads.

Learning Java[edit | edit source]

These tutorials use Java terms that may confuse new users. Below are some links about the structure of Java and what certain terms mean. It is recommended that those who are not knowledgeable in the Java programming language read the links.

For more links, see Helpful Links.

Tutorials[edit | edit source]

Warning: These are outdated Risugami's modloader tutorials. This page needs more tutorials for the modloaders specified in the talk page.

Setting up the MCP workspace[edit | edit source]

Setting up the MCP workspace allows you to access Minecraft and ModLoader's source code and begin modding. The tutorial provides step-by-step instructions for installing Java SE Developer's Kit, the Minecraft Coder Pack, Eclipse IDE for Java Developers, and other programs/mods required to begin modding. The tutorial is written for Windows, Mac, and Linux operating systems.

Starting your first mod[edit | edit source]

This tutorial helps you set up and program the primary file for your mod. This file serves a very important purpose. In future tutorials, they will require that you have entered the code explained in this tutorial. This tutorial requires that you have completed the Setting up the MCP Workspace tutorial first.

Methods in Minecraft[edit | edit source]

This guide contains a table that lists how blocks, items, and entities are referenced in the code. These references are listed as methods. This is useful in many tutorials below.

Adding a block/item[edit | edit source]

This guide will teach you how to create your very own block.

This guide will teach you how to create your very own item.

Mob Creation[edit | edit source]

This tutorial shows you how to create a mob with Techne.

Adding recipes[edit | edit source]

This tutorial teaches you how to create unique and simple crafting recipes for items and/or blocks already in the game. It also guides you in creating shapeless recipes and smelting recipes in the Furnace. This tutorial requires that you have completed the Starting your First Mod tutorial.

Making a recipe is not as hard as it looks. All you have to do is figure out what blocks/items you want to be used in you item. Then you insert the items used and you're done!

Creating an armor set[edit | edit source]

Recompiling and reobfuscating[edit | edit source]

This tutorial is quite small, and allows you to finalize your mod by retrieving the .class files you have created and/or edited to be copied into the minecraft.jar. By sending these .class files to other players, they can play your mod as long as they have ModLoader installed.

Tips[edit | edit source]

  • One of the simplest types of mod is adding new blocks or items. Copy a similar class, and rewrite it as necessary. If the new block or item will share most of its behavior with an existing one, it may be easier to subclass that one and override only the parts that will be different. Depending on the desired behavior and how it will interact with other objects, it may be necessary to modify other classes, which makes it more likely to conflict with other mods.

Creating mods without MCP[edit | edit source]

Sometimes it is useful to create mods without MCP. For example, MCP is usually not released for snapshots.

To create mods without MCP you must either decompile obfuscated code or modify java bytecode. Decompiling is easy, but you can decompile only simple classes.