Writing mods for minecraft. Programs for creating mods for Minecraft. Intuitive interface

How to create a mod for Minecraft?

In order to create mods in Minecraft, you must have at least basic knowledge of working with applications and programming in general.

You can create mods for Minecraft using the API or without it. API is an application programming interface that allows you to work with ready-made classes, functions, procedures, structures and constants for use in other programs. The most popular API for Minecraft is Minecraft Forge. Using Forge to create mods in a game requires the use of this API for the game itself, which significantly complicates the gameplay itself, but at the same time allows you to install applications without conflicts with your modifications and with the mods of other players. It is impossible to achieve this without an API.

Preparing to create mods in the game is as follows:

  1. Download the latest version of Java.
  2. Install Java SE Development Kit.
  3. Download Eclipse IDE for Java Developers and place a copy of it on your desktop.
  4. Download Minecraft Forge.
  5. Move all programs into one folder on your desktop and run install.cmd.
  6. After starting Eclipse, specify the folder you created earlier as the workspace.

After this, you can proceed directly to creating the mod. You will need to go through the following steps:

  1. Creating a base file that specifies the name, id and version of the mod;
  2. Creating a block;
  3. Creating a drop;
  4. Block generation;
  5. Creation of versatile structures;
  6. Multiblock structures;
  7. Crafting items;
  8. Creation of tools, etc.

By starting small, you will gradually understand the basic principles of how to create mods for Minecraft, and you can even add your own mods to the server in order to show them to your friends. If creating mods is not up to you yet, read the article

Many players dreamed of a program that could create modifications. Thanks to developer Pilo, anyone can download MCreator for Minecraft 1.7.2 and 1.7.10 and start creating their own mods without deep programming knowledge. Create new blocks, things, achievements, new types of existing blocks, mobs, biomes, food, tools, plants, cars and more. Any idea can be easily implemented using the MCreator 1.7.10/1.7.2 program.

Create different types of mods


This program allows you to create various types of modifications, including overlays (like in the mini map mod), cars, structures, dimensions, tool sets, weapons (swords, guns) and more.

Intuitive interface


MCreator offers a convenient way to place items in a menu. The developer just needs to move things and elements onto the work surface using the mouse.

Crafting recipes and drops


Write recipes and drops as easily as crafting in the game. Use filters to search through a huge list of things in Minecraft. MCreator can export pictures of recipes so that they can be placed on the site.

For experienced developers


Experienced developers will love the ability to edit mod source code in an easy-to-use interface. The MKreator program editor has syntax highlighting, auto-completion and other things that are pleasant for the programmer. Integration with Eclipse is supported.

The popularity of the Minecraft game is only growing every year, partly due to the players themselves, developing mods and adding new texture packs. Even an inexperienced user will be able to create his own modification if he uses special programs. In this article, we have selected for you several of the most suitable representatives of such software.

First, let's look at the most popular program for creating mods and textures. The interface is made very convenient, each function is located in a corresponding tab and has its own editor with a set of specific tools. In addition, you can connect additional software, which you will need to download in advance.

As for functionality, MCreator has both advantages and disadvantages. On the one hand, there is a basic set of tools, several operating modes, and on the other hand, the user can configure only a few parameters without creating anything new. To change the game globally, you need to go to the source code and change it in the appropriate editor, but this requires special knowledge.

Linkseyi's Mod Maker

Linkseyi`s Mod Maker is a less popular program, but it provides users with significantly more options than its previous representative. Working in this software is implemented in such a way that you need to select certain parameters from pop-up menus and upload your own images - this only makes the program more convenient and simpler.

You can create a new character, mob, material, block and even biome. All this is combined into one mod, after which it is loaded into the game itself. In addition, there is a built-in model editor. Linkseyi`s Mod Maker is distributed free of charge and is available for download on the official website of the developers. Please note that there is no Russian language in the settings, but even without knowledge of English, it will be very easy to master Mod Maker.

Deathly's Mod Editor

Deathly`s Mod Editor is very similar in functionality to its previous representative. There are also several tabs in which a character, tool, block, mob or biome is created. The mod itself is formed into a separate folder with its component directories, which you can see on the left in the main window.

One of the main advantages of this program is the convenient system for adding texture images. You don't need to draw the model in 3D, you just need to load images of a certain size into the appropriate rows. In addition, there is a built-in modification testing function that allows you to detect errors that could not be identified manually.

There weren’t many programs on the list, but the representatives present perfectly cope with their tasks and provide the user with everything they need when creating their own modification for the game Minecraft.


Today I am re-opening the series of articles this time. I will not abandon it and will even respond to your comments. Well, from words to deeds. Go!
Preparation

To write our plugins we will need:
  • Eclipse Java application development environment;
  • Spigot Api: https://hub.spigotmc.org/nexus/content/groups/public/org/spigotmc/spigot-api/.
You will also need basic knowledge of Java. If there are none, then here are links to “raising your skill”:
  • Java Basics for Beginners
    The site is designed for those who are just starting to learn Java.
  • Java (Beginner) Programming Tutorials
    Video tutorial on Java, designed for beginners (I started with it).
  • Java reference
    I would call this a Java cheat sheet
  • Java expert
    And don't let the name scare you. Here you can find many examples of solutions for these or
    other tasks.
Installing and Configuring Eclipse
If you are already familiar with Eclipse or have a different IDE, then skip this section.

There should be no problems installing Eclipse: you just need to unpack it into any folder and run it. Immediately after this, Eclipse will ask you to indicate which workspace to open now. This is the folder in which all created projects will be saved and where to place it is your personal decision. If you don't care, then leave everything as it is. If you suddenly want to change the workspace, then don’t worry: every time you start it, Eclipse will ask you about the workspace again. You can create as many of these spaces as you like, and each can be configured differently, for specific purposes. For example, I have 2 workspaces: for writing regular java applications and for writing bucket plugins. If you suddenly get tired of this message, there is a checkbox “Use this as the default and do not ask again”, which allows you to set the workspace as the default.+

As soon as you decide on the choice of location and Eclipse loads, we will see an invitation tab... which we immediately close. We don't need her.

Now we see the workspace of the Eclipse itself. From all this, we only need the following panels:

  • Package Explorer
    Your projects, packages (more on them later) and all sorts of files for our future plugins will be displayed here.
  • Problems
    We will rarely use this panel (if we ever get around to it), but it’s worth talking about. Errors made in the code will be shown here, as well as warning messages about possible errors or inaccuracies.
  • Outline
    Navigation directly through the open source java code will be displayed here.
The last 2 panels described can be completely collapsed, because We will rarely use them.

The workplace is almost ready. All that remains is to check 2 more boxes in the settings.

Go to the Window -> Preferences menu, then along the General -> Editor -> Text Editors tree and check the “Show line numbers” checkbox to enable display of line numbering. Now go to General -> Workspace and in the “Text file encoding” group set the encoding to UTF-8, thereby setting the default encoding.

The installation and configuration is done. Now I’ll explain how to create a new project for the plugin. This can be done in one of 3 ways:

The New Java Project window will open in front of us. In Project name we indicate the name of our project

Click Next.
In the window that appears, go to the Libraries tab, click the Add External JARs button and select the downloaded Bukkit API

Click Finish.

On the left, in Package Explorer, our project appears with the src folder in which our source codes will be stored. Now let's create a new class. This is done in exactly the same way as with the Java Project.

In the New Java Class window we only need the following columns:

  • Package
    indicates the package in which our class will be stored. The name format should be something like this: ru.dmitriymx.bukkit.tutorial.
    In a nutshell and in a nutshell, packages in Java are a namespace or “virtual folders” into which classes are placed. You can read more about this here: , , .
  • Name
    indicate the name of the class (for me it is DmxFirstPlugin)
Leave all other items as they are and click Finish.

Now let's move directly to the code.
Writing a simple plugin
As soon as we have created a new class, a ready-made empty template appears before our eyes

For now, this is just an empty class that is absolutely useless in everyday life. We will fix this. Let's change this

on this

Eclipse will highlight JavaPlugin to us, indicating an error in the code. If you move the mouse over such an underlined code, a window will open with a description of the error and how to solve it. In this case, we need to import the class from the Bukkit API, for which we select the item “Import ‘JavaPlugin’(org.bukkit.plugin.java)”

We immediately notice how the line is written above all our code

A little theoretical material. Plugins have 3 main methods: onEnable(), onDisable() and onLoad(). The first two are responsible for enabling and disabling the plugin, and the last one is triggered when the plugin is directly loaded into the server memory. It follows that onLoad is executed first, but the plugin itself starts working only after onEnable is called from the server side. When the server is turned off or rebooted, the onDisable method is called.

We sorted out the “entry-exit points”. Let's now write something more or less workable. Let's reduce the general class code to the following form:

who doesn't see the second part:
What we just wrote about is a ready-made plugin. All he does is write in the chat about the arrival and departure of the player on the server. We will understand his work in order (how else?).
First, let me pay attention to the class declaration line. As you can see, the Listener extension has been added to our class. Without delving into the jungle of Java, I’ll say it simpler: by specifying this extension, we thereby expand the scope of the class not only as a plugin (JavaPlugin), but also as an event handler (Listener). But it’s in the onEnable() method that we register our class on the server as an event handler (this is a reference to itself, in case anyone has forgotten).

Next are our 2 event handlers onJoin() and onQuit(). The first one is responsible for the event of a player entering the server, and the second one is responsible for leaving. Using the event.getPlayer().sendMessage() method, we can send a message to the player who caused this event (in our case, the player who logged in). The static class ChatColor stores color constants for coloring. I think how to use it can already be seen from the example. Also, both of our processors notify other players on the server about events that have occurred, but they do it in different ways. In onJoin(), using the event.setJoinMessage() method, we change the usual “Player joined the game” message to any other one. And in onQuit() we did something different (for example purposes): we removed the output of the exit message and report this through the getServer().broadcastMessage() method, which simply sends the specified message to all players on the server.+

All that's left to do is write the important plugin.yml file and package it all into a jar file.

Plugin.yml is a plugin description file. It specifies the name of the plugin, the main class, description and what commands to register for plugins (more on this later), etc. In our case, the file should look like this:

Oh, I forgot to tell you where this file should be located. Right-click on the src folder in PackageExplorer and select File from the New menu. In the File name field, write plugin.yml and click Finish. In the text editor that opens, write what I indicated above. We save everything and move on to the last phase: packaging.

Right click on the src folder -> Export. In the folder tree, open Java and select the JAR file and click Next. Of the little things, we leave only “Export generated class files and resources” and “Compress the contents of the JAR file”. In the JAR file field we indicate where we will save the resulting plugin. After clicking Finish, you can put the plugin in the plugins folder, start the server and check its operation.

Do you see? It's quite simple. With practice, you will gain more experience and be able to make cooler plugins, even such legendary ones as WorldEdit and WorldGuard.
Source


No need to delete META-INF in minecraft.jar, and minecraft_server.jar
1. Create a folder (For example: MCP Forge) and unpack the contents of the archive with MCP there.
2. Copy the bin and resources folder from the client to the ../MCP Forge/jars/ folder, from the server we only need minecraft_server.jar.
3. Unpack the archive with Forge-src into the MCP Forge folder
4. Open the folder ../MCP Forge/forge/ and run the install.cmd file. We are waiting for the decompilation to finish..
(P.S If you want you to already have a ready-made MCP with Forge, for example, if you accidentally deleted it or something else, then: When the decompilation is completed, launch the game and let it download the lib, and then add this MCP Forge to the archive, for example like this (mcp Forge 1.5.1)
5. “Install” and launch Eclipse, during startup you will be “asked” for the folder with the project, specify the path: ../MCP Forge/eclipse/
6. So, we opened the project, now (Usually on the left, there is a Package explorer) we look at what library it “eats” (In the Package explorer window, “open the Minecraft project” and if there is a line “JRE System Library”, then everything is fine, but if the line is “JRE System Library”, then right-click (Right-click), select Properties, then a window opens in which Execution environment is selected, select JavaSE-1.7 in it and click Ok.
7. So, the preparations are ready.

How can you start writing a mod?

First, we need to create a “base”, that is, the main “folder” in which our “base” and everything else will be stored.
1. Go to Eclipse, see the Minecraft folder in Package Explorer, open it, and right-click on the src folder, select New->Package. In the open window, in the Name line, we indicate the name of the folder in which everything will be stored (For example, take: mods.testmod.src) and click Ok.
2. Right-click on our folder (mods.testmod.src), then New -> Class. In the Name line, indicate the name of our file (For example: TestModBase) and click Finish.
3. Change the path, but do not remove mods, like this, for example mods.NewItemMod.src.
4. In new versions you need to import “A lot” of everything, to do it faster in Eclipse press “ctrl + shift + o”, and it will quickly import everything, and if a window appears then select the import you need.
5. If you do not work in Eclipse, then it will be much more difficult for you, so it is better to switch to it, it will indicate where the error is, and what imports are needed, and you will not ask stupid questions in the comments.

package mods.testmod.src;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.common.network.NetworkMod.SidedPacketHandler;
import cpw.mods.fml.common.SidedProxy;
@Mod (modid = "TestMod", name = "Test Mod", version = "0.0.1")
@NetworkMod(clientSideRequired = true, serverSideRequired = false, versionBounds = "1.0.0")

public class TestModBase (

@Instance("TestModID")
public static TestModBase instance;

@Init

{
}

@PreInit
public void preLoad(FMLPreInitializationEvent event)
{
}

@PostInit
public void postLoad(FMLPostInitializationEvent event)
{
}
}


In our TestModBase file
After the inscription:
public class TestModBase (
Enter this line:
public static final Block testBlock = new TestBlock(2020).setUnlocalizedName("testBlock");
Parsing:
public static final Block "testBlock" - testBlock the name of our block in the code (not in the game)
new TestBlock(2020) - TestBlock the name of our block in the code (not in the game), 2020 block ID
setUnlocalizedName("testBlock") - ("testBlock") the name of our block in the code (not in the game)
After the inscription:
@Init
public void load(FMLInitializationEvent event)
{

Enter this line:
GameRegistry.registerBlock(testBlock);
LanguageRegistry.addName(testBlock, "Test Block");

Parsing:
(testBlock) - the name of our block in the code (not in the game)
(testBlock, "Test Block") - testBlock is the name of our block in the code (not in the game), "Test Block" is the name of our block in the game.
Create a file testBlock and enter the following code into it:
package mods.testmod.src;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;

public class TestBlock extends Block (

public TestBlock(int par1)
{
super(par1, Material.ground);//Material
this.setCreativeTab(CreativeTabs.tabTools);//Add to creative
}
//Register the texture
@Override

{
}
}


In our TestModBase file
After the inscription:
public class TestModBase (
Enter this line:
public static Item testItem = new TestItem(2021).setUnlocalizedName("testItem");
Parsing:
public static final Item "testItem" - testItem is the name of our item in the code (not in the game)
new TestItem(2021) - TestItem the name of our item in the code (not in the game), 2021 item ID
setUnlocalizedName("testItem") - ("testItem") the name of our item in the code (not in the game)
After the inscription:
@Init
public void load(FMLInitializationEvent event)
{

Enter this line:
LanguageRegistry.addName(testItem, "Test Item");
Parsing:
(testItem, "Test Item") - testItem is the name of our item in the code (not in the game), "Test Item" is the name of our item in the game.
Create a file testItem and enter the following code into it:
package mods.testmod.src;

import net.minecraft.item.Item;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;

public class TestItem extends Item
{
public TestItem(int par1)
{
super(par1);
setCreativeTab(CreativeTabs.tabTools);
}

//Texture registration for an item is slightly different from a block
@Override
public void registerIcons(IconRegister par1IconRegister)
{
}
}


@Override
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon = par1IconRegister.registerIcon("testmod:testBlock");
}

("testmod:testBlock"), testmod is the "name of the folder" in which the "folder with the texture" will be, testBlock is the name of our texture. This is our texture placement:

\Tutorial Forge 1.5.1\mcp744\src\minecraft\mods\testmod\textures\blocks\testBlock.png


@Override
public void registerIcons(IconRegister par1IconRegister)
{
this.itemIcon = par1IconRegister.registerIcon("testmod:testItem");
}

("testmod:testItem"), testmod is the "name of the folder" in which the "folder with the texture" will be, testItem is the name of our texture. This is our texture placement.