How to make mods for minecraft

How to make mods for minecraft

Getting Started with Add-On Development for Bedrock Edition

Add-Ons are the first step on our journey towards bringing even greater levels of customization to Minecraft: Bedrock Edition. Add-Ons allow players to transform the look of their worlds and even change the behavior of mobs. For example, you can change the blast radius of a creeper and the texture it’s wearing.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

In this tutorial, you will learn the following.

com.mojang

When Minecraft is installed on your computer, there is a folder called com.mojang that is generated in the AppData folder. You will need to find this folder so you can add your content to it.

To locate the com.mojang folder on your computer, you will need to have Hidden items checkbox set to true, as shown below. while you’re at it, go ahead and check the box for File name extensions, too.

Showing hidden items

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Locating com.mojang

Now would be a good time to save a shortcut to this folder on your desktop.

As shown in the image below, there are multiple subdirectories located within the com.mojang folder.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

If you see more content in this folder than what is shown above, do not panic! This image shows a fresh install of Minecraft.

Behavior, Skin, and Resource Packs

Development Packs

You will use the development_resource_packs and development_behavior_packs folders for the Resource Pack and Behavior Pack tutorials. The development_skin_packs folder is used for developing skin packs. Development pack folders are updated each time Minecraft is launched so you can quickly load and test the changes you made to their contents.

minecraftWorlds

minecraftWorlds contains each world that has been generated within the current build of Minecraft. Each folder will also contain resource and behavior pack folders to contain any packs that may be in use within the world.

It’s recommended that when installing a new build of Minecraft, you should save a copy of this folder to use as a back up to prevent any potential loss of Minecraft Worlds that you may have.

Visual Studio Code

JSON is a popular text file format that is used by Minecraft: Bedrock Edition to interact with content. JSON can be edited in any text editor such as Notepad or Word. However, Visual Studio Code is a free to use text-based editor that supports third party extensions, including some built specifically for Bedrock development.

Installing Visual Studio Code

Visual Studio Code Extensions

Visual Studio Code supports extensions created by the Visual Studio Code developer community. Extensions are a great way to help write and understand Minecraft syntax when working on resource and behavior packs.

Installing Extensions

What’s Next?

Now that your development environment is set up, you can start creating your first Add-On and learn more about resource packs.

Alternatively, if you would like to get started with commands in Minecraft, head on over to Introduction to Command Blocks to learn how to use command blocks to chain together different commands.

The Ultimate Guide to Minecraft Modding with Java

Share the post «The Ultimate Guide to Minecraft Modding with Java»

In this Minecraft Modding tutorial, we will be providing you with step-by-step instructions on how to get started with Minecraft modding while creating an awesome custom Sword that you’ll get to play in the game.

We’ll be using Minecraft 1.12.2 as it is the version compatible with our current Minecraft courses. Newer versions may use different setup instructions.

As a rule of thumb, Minecraft mod code is not compatible from version to version. For example, 1.12 mods will not work with 1.13 and above.

You’ll need a PC or Mac computer for this tutorial, as Chromebooks or mobile devices will not run the software properly.

At CodaKid we have taught over 50,000 students Minecraft coding, and have won numerous industry awards for online courses including a Parents’ Choice Gold Award and CODiE Finalist for Best Coding and Computational Thinking Solution.

While we teach coding for kids, this guide can be used by teachers, parents, or anyone with an interest in creating a custom Sword Mod for Minecraft Forge.

We hope that you enjoy this free step by step guide to covering one of the first courses we teach in our Minecraft Modding series.

We’ll cover the very basics of what you’ll need to start Minecraft modding, and you will learn how to use Java, one of the most popular programming languages in the world.

We’ll also teach you how to download and use the Eclipse IDE, a text editor used by professional developers at companies such as Facebook, Google, and Amazon.

We will continue to update this blog in the coming months and transition to more recent versions of Minecraft as they become stable for mod creation. Our next big course revision will take place after the upcoming Minecraft Caves and Cliffs Update.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Table of Contents

Step 1: Set up Java Developer Kit (JDK)

We will need to download the Java Developer Kit that will let our Minecraft Modding in Eclipse work correctly.

You can find the download link HERE for JDK 8. The version of JDK you need is JDK 8 to work properly with Minecraft Modding.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

The download page should automatically detect your platform and give you the correct download. The version I am downloading that is shown in the picture is for Windows 64-bit. However, you can click “Other platforms” to find versions for other operating systems. Click the “Latest release” button to begin your download.

Now the download of the executable file will start.

Once this is finished, find the file in your downloads folder and run the executable to install the JDK.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Run through the pop up window guide to install the JDK for your computer and click on each next keeping the default settings until the JDK finishes installing.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

You will need to agree to the End-User License Agreement (EULA) to continue.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Let Java run its installation until it is finished.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Now that JDK is finished, we can set up our code editor in the next step.

Step 2: Set up your Text Editor

Before we begin Minecraft modding, we’ll need to download some tools.

First, for this guide, we are going to download the Eclipse IDE, one of the most popular professional text editors for Java in the world.

To download the installer CLICK HERE and look for the Get Eclipse IDE 2020-06 Download area that looks like this:

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Click the Download 64 bit button and the next page will appear where you can download. Click the Download button shown and wait for the Eclipse file to finish downloading.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Find the executable file in your download file and open it to launch the Eclipse installer.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

When the launcher opens, select the Eclipse IDE for Java Developers.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Then on the next window, keep the default install location and then click the INSTALL button.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

The next window will appear and you need to accept the agreement for Eclipse.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Then the next window will prompt to make sure you accept the license Agreement.

Checkmark the “Remember accepted licenses” box and accept the Eclipse Foundation Software User Agreement.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once this is accepted, you are almost done with the install.

Just accept the Eclipse Foundation certificate as shown in the image below.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once this is done, Eclipse will be downloaded and ready for when we need to use it to write our code.

The next step is going to be installing the Java Developer Kit which will let our code work properly with Minecraft.

Step 3: Set up Forge

Next you will need to download the 1.12.2 version Minecraft Forge, as this will allow us to mod Minecraft 1.12.2. The instructions shown here should work for any Minecraft version from 1.12.2 onwards.

On this page you should see the latest and recommended version for Forge. Download the Recommended version Mdk (Mod Development Kit) file for 1.12.2 as shown.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

You’ll be taken to Forge’s advertisement redirect. You don’t need to click on anything but the “Skip” button in the top-right corner, highlighted in red below.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once this is downloaded, find it in your downloads folder, right click on the zipped up folder and then select Extract All…

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

On the next window click the Extract button.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

This is going to be our project folder. So we want to make a copy and rename and move it to a new location on our computer.

We recommend putting a copy in your Documents folder or on your Desktop.

Right click and copy and paste the unzipped forge folder in a location you want and make sure to rename it to something descriptive.

In this example we will be naming it ForgePractice.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

We have the Forge folder set up and are ready to create our new project!

Step 4: Install Pinta

Next we want to install the Pinta program we will use to change the look of our Sword Texture.

Go the the link HERE to get to the Pinta download page.

On this page click the download link for the OS you are on Mac or Windows.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once you have the installer downloaded, open it up in your downloads folder and run the installer.

Fully install the application and accepting any agreements along the way.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Close out of the installation when it is finished.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Now we have the programs we need to create our mod.

The next step is creating our project.

Step 5: Create Your Project

Launch Eclipse. It will ask you to choose a directory to use as Eclipse’s workspace. This directory needs to be outside of your project folder. I recommend creating “eclipse-workspace” inside of your Documents folder. You can also just use the default location Eclipse gives you.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Eclipse will now open up. Close out of the Welcome tab.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

In the Package Explorer, click on “Import projects…”

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

In the “Import” window that pops up, select “Existing Gradle Project” and click Next.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

On the next page, click “Browse…” and select your project folder. Click “Select Folder”.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

You should now see this. Click Finish. It should close after importing the project.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

You should now see your default workspace view:

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Go into the Gradle Tasks tab at the bottom of the window. It looks like this:

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Expand the “fg_runs” task folder, and double-click on genEclipseRuns to run the task to set up our Minecraft launch configuration. Once it’s finished running, we need to import our new launch configurations.

Go to the File menu of Eclipse near the top of the window. Click it, then click Import in the menu that appears.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Click the arrow next to Run/Debug in the menu that appears. Select Launch Configurations and click Next.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

In the next menu, checkmark the box next to ForgePractice (or your folder name if you named it differently). It should show the runClient and runServer configurations selected. Click Finish.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Just one more edit before we can run Minecraft. Click the arrow next to the green Run button. Click on Run Configurations. You can also find this from the Run menu at the top of Eclipse.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Go to the Environment tab in the new window that appears. Go to the MC_VERSION line in the list.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

You can close out of the Minecraft Client; you should now be able to run the game just by clicking the green “Run” button in the toolbar near the top of Eclipse.

We are now ready to start Creating a Mod and learning Java!

Step 6: Make Your Own Mod – A Custom Sword!

Finally our Minecraft modding tutorial begins!

Once Eclipse is loaded up and opened, we are ready to start typing in java code.

Let’s open an example Mod java file that is provided for us that we will be starting from.

On the left side of the window, open the project folder by clicking the arrow next to the name. Your project folder will likely be named with the same name you gave to the folder in Documents.

Now open the “src/main/java” folder and then open the “com.example.examplemod” file and inside you will find ExampleMod.java.

Double click this to open up this java code file.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

This file contains our starting code. It contains our mod ID and name. The first thing we want to do in ExampleMod is find the lines that define our MODID and NAME.

Change the MODID to sword making sure it is all lower case.

This is the unique ID for our mod we will make.

The NAME is the name of the mod as it will appear in Minecraft.

Name this what you prefer.

Make sure these are inside quotation marks because they are String variables.

Strings are variables that are words or characters.

(We will be covering variables in a little bit).

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Go to the src/main/resources folder and open the mod info file.

Open mcmod.info here and change the modid to “sword” and change the name, description, author, and credits to whatever you like.

Make sure these are inside quotation marks again as they are Strings that will be read by the code.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

The next step is to create variables for our ToolMaterial and sword.

Place these lines beneath the private static Logger logger line in ExampleMod.java.

Variables are helpful in code because they act as boxes with names that store information inside of them we can use easily.

What we are doing here is we are creating to variables myToolMaterial and mySword.

The types of variables are the ToolMaterial and Item.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once we have the variables created, we need to import the code files that define what a ToolMaterial and an Item do.

We can do this by mousing over the red error lines underneath ToolMaterial and Item.

In the dropdown list that appears, import the code shown.

Start with the ToolMaterial as shown below.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Next import the Item as shown below.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Now because we are making a customized sword in Minecraft, we need to define what the material is for the sword tool is we will be using.

This is where we define our custom tool material variable we created.

Go into the preInit function shown and inside below the logger line, write out the myToolMaterial line shown.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

What that line does is it fills in our myToolMaterial variable with information on what the material does for tools we apply it on.

We will be applying this tool material to our sword. But let’s actually fill in the name, harvest level, damage etc.

Change out the name to a String variable that is the material name.

You can name this whatever you like.

The harvest level indicates which minerals it can get resources from.

If we applied this material to a pickaxe, this is where we would define if it can get diamonds from Diamond Ore.

Putting this at 4 lets it mine whatever we want it to.

maxUses is how many times we can use it before it breaks, the efficiency is applied for harvesting tools for how quickly it will mine or harvest a block.

The damage is how much damage it will do when you hit an entity with it.

The enchantability is related to how easy it is to enchant.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

After this material line add in a definition for what our sword is.

This line defines the sword as a new class called CustomSword.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

We need to create this new class and we do that by mousing over the red error line and clicking

Create class ‘CustomSword’.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

A new window will open up, keep these values at the default settings and just click Finish.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

This will create a new Java code file CustomSword and automatically open it up for it.

This is a Class which is code that defines what the CustomSword is and how it behaves.

What is convenient for us is we can make sure to change the import and public class lines to say “ItemSword” instead of “Item” and this defines our class with all of the information that already exists for swords in Minecraft.

This lets us swing it and damage creatures as well as pick it up and drop it and any small interaction a sword will have in the code.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Now what we need to do is add a constructor for our class.

This defines how the sword is made. Think of it as how blueprints are used when creating buildings.

We are defining specific rules for how our sword will be created.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once the constructor is added in, change it to remove the Material reference in the parentheses and then fill in our ExampleMod.myToolMaterial.

After these changes are made, we need to set the RegistryName, UnlocalizedName, and CreativeTab for our sword.

The Registry and Unlocalized names of our sword need to specifically be “my_sword” because these are the names our code uses to identify our sword and link our texture to it.

The CreativeTab can be changed to the tab you want the sword to appear in.

We chose COMBAT but there is a list that will appear where you can choose the tab you want your sword to be in.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once this is done, our class is ready to go.

We need to create a new java class that we will use to register our sword into Minecraft.

Go to the Package Explorer on the left side of Eclipse and right click on the com.example.examplemod package and create a new Class (as shown below).

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

This will open the class window we saw earlier.

This time we want to name it CommonProxy and then select Finish.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Now we want to go above the public class CommonProxy line and write the @mod.EventBusSubscriber.

This will let the class be run during the loading of Minecraft so it can register our sword into the game.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

We need to import the code for mod just like how we imported Item and ToolMaterial earlier.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once that is imported, we need to create a new function that will run specific code to register the sword Item in Minecraft.

Make sure to include the ExampleMod.mySword inside the registerAll() parentheses because this tells the register function specifically to register our sword item.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Now we need to import the code that is missing from this Class.

We need to import SubscribeEvent, RegistryEvent, and Item.

Just like before, we are importing code that already exists to help us with our register code.

Start with SubscribeEvent as shown below.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Next Import RegistryEvent as shown below.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Finally, Import Item (net.minecraft.item) as shown below.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once these imports are done, we can actually test out or “sword” except it will not look like a sword just yet.

In order to test out our code, make sure you are clicked inside a code window and then go up to the green play button and press it only once.

Make sure you press the button that is just the green button and not the ones with little icons in the corner.

After some time, you should see a window start opening Forge Minecraft.

Wait until it fully loads Minecraft to its main menu.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once you have finished waiting, select Single Player at the main menu.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Next, select Create New World to start setting up a Creative mode game.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Then change the game mode to Creative and change the name, then select Create New World.

This will open the new world and take a bit of time to open the Minecraft world.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once the world is opened, click the “e” button to open the Creative Tab inventory.

Go to the Combat tab or whatever tab you picked when we set the Creative Tab in our code.

Scroll to the bottom of the tab and make sure you have your sword.

We will be updating the look and the name but if you put it in your inventory, you will have a sword that will function as we coded it to!

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once you are done testing your purple and black block sword, let’s go back to our code to make the model and texture linked up in our code.

Exit out of the Minecraft window and open CommonProxy.java and add a new registerRender function inside of the CommonProxy class as outlined below.

This will register the model for the sword based on the item we want to register.

We will link this to our sword in the next couple of steps.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

We now need to import more code.

Make sure to import ModelLoader and ModelResourceLocation.

Start with ModelLoader.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Next, Import ModelResourceLocation as shown below.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Now let’s render our sword!

Make a registerRenders function that we will register our ExampleMod.mySword variable.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Now we need to import the ModelRegistryEvent code so our models will properly render in Minecraft.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Now we need to name our sword.

Right click on the src/main/resources and make a new untitled Text file inside.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Now add in a code line that will name the sword.

You can customize the name of your sword by changing the name to the right of the equals (=) symbol.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Now let’s save this untitled filed.

Go to File > Save as and a window will open asking you to select the location of the file.

Select the MDKExample>src>main>resources folder and change the file name to be en_us.lang and then click OK to make the file

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Now we need to make our sword texture and import it into our project.

I have a picture of an Iron Sword in Minecraft below.

Go ahead and right-click on it and select “Save image as…” then save the file as “my_sword.png”.

It is a small file because Minecraft needs a smaller image.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once you have it saved, right-click on the picture wherever it is saved on your computer and then copy it.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once it is copied, let’s find the folder we need to paste it in.

Go to our project folder ForgePractice and open the src > main > resources folder and paste in the my_sword.png into here.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Now return to Eclipse and add a new Text file into the src/main/resources folder like we did before.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

In this new file, type in code that will define the item sword resources.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

We will now save this file as a json file so go to File > Save as and save the untitled file as my_sword.json inside of MDKExample > src > main > java > resources.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Now click the small dropdown Triangle next to Package Explorer and change the Package Presentation to Hierarchical. We do this because we will be adding in more packages to organize our code and set it up so our sword files can be properly managed by our code.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Now we need to create Packages for our resources folder.

Right click on this folder and add a New Package.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

In the pop up window, name it assets.sword and then click Finish to create the package that will hold our other three packages.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Now right click on assets.sword package and add a New Package.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

In the pop up window name it assets.sword.lang.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Now make two more packages inside of assets.sword.

Name these “assets.sword.textures” and “assets.sword.lang”.

Once these are made, drag in the en_us.lang, my_sword.json, and my_sword.png to their respective folders as shown in the image below.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

The last thing to do is customize our sword.

Open Pinta by searching for Pinta in our search bar and opening the Pinta program.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

With Pinta opened, go to File > Open where a new window will open up.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Let’s now find our sword imagine in our project folder ForgePractice > src > main > resources > assets > sword > textures > items.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Now we need to actually paint the sword!

Zoom all the way in and turn anti aliasing to the off position and change brush width to 1. All of these settings are highlighted in the image below.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Now all you need to do is paint your sword and erase or add anything you want.

Use the colors, the brush, and eraser tool.

Make sure to change your eraser anti aliasing and brush width as needed just like what we changed with the paint brush.

Then paint your sword to look like whatever you want! If you make a mistake you can hold down CNTL then press down on Z to undo changes. On a Mac, you’ll hold down the Command button and press down on z.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once you are done go to file > Save and make sure the new changes are saved you made.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once this is all finished we are done with our custom Sword mod!

You can now test it by clicking on the Green play button just like what we did earlier!

Make sure everything is perfect and as you want it and then get ready to Compile your Mod and test it in Minecraft.

Step 7: Compile your Mod

Now that our code is finished, we need to compile and build our mod.

In order to build it, we need to go to the project folder we made and right click in an open space and select “Open Powershell window here” or “Open command window here”.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once the window is open, write in the command “./gradlew build” and press Enter to run this command.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Then wait for the BUILD SUCCESSFUL message to display.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once this build is finished, return to your project folder ForgePractice and open the build folder.

Make sure you see modid-1.0.jar.

This is our build mod file!

Now in the next step we will show you how to load your Mod onto your Minecraft game.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Step 8: Test your Mod!

Now to test our mod we need to make sure we have regular Minecraft forge downloaded.

What we were working in was the developer kit for Forge.

Now we need to access the Minecraft Forge client.

Return to the same Minecraft Forge download page we were at earlier.

Now once at this page click the regular install button shown.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once the download finishes, open the executable file in your downloads folder.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once this launches, you should see the Forge install window.

Make sure you have Install client selected, and keep the default location and then click OK.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Make sure the Forge client installs successfully and then press OK when it is done installing.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once Forge is done installing, we need to find our build mod file in our Eclipse project folder.

Open your ForgePractice folder.

Then open the build folder and find the libs folder in here.

This is where our Mod will be.

Right click and rename the modid-1.0.jar to what you want.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once it is renamed, go ahead and right click and copy the new jar file.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once the jar file is copied, we need to open the folder that has our mods in it.

Go to the search bar and type %appdata% and open the folder that shows up in the search.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Next, paste in your mod we copied earlier.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Your mod is all set up to work in Minecraft!

Now we need to launch Minecraft and open the Forge version. Search and Open the regular Minecraft version.

This has to be the Java version of Minecraft.

The Windows 10 or a mobile version of Minecraft will not work.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once the Minecraft Launcher is opened, go to the Launch Options tab and click Add new.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

In the Add New window, Change the version to the release 1.12.2-forge version.

Name it Forge 1.12 or something descriptively similar.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Go back to the main Minecraft News tab and click the drop-down arrow next to PLAY and select the new Forge 1.12 launch version we made.

Once this is selected, click PLAY to launch the Minecraft Forge version.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Once Minecraft is loaded, we need to make a new level just like what we did when testing our sword.

Go to Single Player and then Create New World just like we did earlier.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

In the settings, change it to Creative Mode and change your World Name.

Once all of this is done, click the Create button and wait for the new Minecraft game to load.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Just like earlier, find your sword in the Creative Tab by clicking “e” on your keyboard, and then head to the tab you set your Sword to appear in.

Mine is the Combat tab and as you can see, the custom sword is at the bottom of the list of items.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

You’ve officially created your own Minecraft Mod from scratch and loaded it into your own Minecraft game!

You can make another sword using the same techniques or even challenge yourself to create an Axe or other tool.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

What Can Kids Mod in Minecraft 1.12.2?

When it comes to creating Minecraft mods, a sword (or even weapons in general) is barely the tip of the iceberg. You can create so many awesome mods with the Java Developer Kit, Eclipse IDE, and Minecraft Forge. From mods that add thousands of new weapons for you to find and test out in-game to mods that add new cities and new adventures, the sky is literally the limit with Minecraft.

Here’s a quick overview of some of the most popular 1.12.2 Minecraft mods, so you can see (1) how creative Minecraft players can be, and (2) how you can mod almost anything imaginable:

Minecraft Lumberjack – a mod that instantly clears away anything wooden in its path (trees, leaves, logs, etc.)

JurassiCraft mod – a mod based on the Jurassic Park and Jurassic World franchises. Create in-game dinosaurs by extracting DNA from fossils and amber!

1.12.2 MoarFood Remastered – a mod that adds 100+ new and unique types of food

Minewatch Mod – a mod that combines Minecraft with another popular game, Overwatch. It adds playable heroes and usable weapons and armor that follow the look + functionality of Overwatch items.

Five Nights at Freddy’s Mod – a mod that adds new blocks, items, and mobs based off of the characters from another game, Five Nights at Freddy’s

TelePad Mod 1.12.2 – “teleportation made easy!” A mod that allows players to travel over dimensions, back and forth

Item Filter Mod (Advanced Filtering Items) – a practical mod that allows you to add specific filters with the API. This is perfect if you’re trying to comb through thousands of in-game objects in your inventory

Extra Alchemy Mod – a mod that adds hundreds of new useful potions

Xaero’s World Map Mod (Trace Your Footsteps) – a Minecraft 1.12.2 mod that introduces a self-writing fullscreen map to your client. Changes depending on the world/dimension/server

PetCraft Mod 1.12.2 – this mod adds a variety of pets (i.e., dogs, cats, hamsters, etc.) to the game

Guns Mod | Modern Edition – fairly recent mod that adds modern guns (i.e., pistols, shotguns, SMGs) to the game

UFO Mod 1.12.2 (Alien) – exactly as the name suggests; this mod introduces a full-blown UFO invasion into the Minecraft world

Yes, all these are real mods, and, yes, they’re all functional. Created by Minecraft players for Minecraft players, Minecraft modding is honestly one of the best ways the community keeps engaged with the game.

Believe us; once you’ve gotten used to mods, vanilla Minecraft may seem almost limiting (which is crazy, because Minecraft remains one of the most intuitive and extensive sandbox games of all time) in comparison. So when you start creating and downloading mods, we highly recommend you organize your mods folder. It’s very hard to stop at just a few!

Conclusion

If you enjoy Minecraft Modding and want to take your skills further, CodaKid has a series of courses that can teach you how to make your own custom creature, biome, dimension, insane explosions, and special effects, and more!

Our courses even include messaging and screen share support from live engineers if you ever get stuck, and our courses even come with a two-week free trial!

We hope you enjoyed The Ultimate Guide to Minecraft Modding with Java in 2022. If you enjoyed our Minecraft modding tutorial, we’d love it if you could share it with friends.

If you have any questions or comments, please leave them below!

Happy Minecraft Modding!

BONUS: Check out our latest guide How to Make your own Minecraft Server. A super fun project!

Share the post «The Ultimate Guide to Minecraft Modding with Java»

How do I make mods for Minecraft 1.12.2?

This wiki page is here for legacy reasons only. Older versions of MCreator used to have this feature or the feature does not need extended documentation anymore. Nevertheless, we kept the page for users of older versions.

IMPORTANT NOTE: MCreator 2021.2 and upwards no longer support 1.12.2 at all. Nor native, nor with the plugin. We do not have the means to maintain this plugin for a Minecraft version that old. If you are interested, you can fork the 1.12.2 plugin and develop your own version from there.

Making mods for Minecraft 1.12.2 was possible up until MCreator 2020.2. If you want native support for 1.12.2 mods, use this version. Keep in mind this version has absolutely no support and forum topics addressing this version will be removed.

1.12.2 generator plugin

Since 2020.3 and up to 2021.1, it is still possible to make 1.12.2 mods using MCreator via the 1.12.2 generator plugin. You can get the plugin on the plugin page.

From the plugin page:

Although we no longer support or encourage the use of 1.12.2, we still want you to update to newer versions. Most of the new features are not supported in it, though, but feel free to open pull requests.

This generator only works on MCreator 2021.1

1.12.2 support

We no longer support 1.12.2 by any means. We only officially support the versions supported in the latest stable release. All forum topics addressing older versions will be removed.

What to do?

Generally there are two realistic options:

Creating a Minecraft Mod using Java and Fabric

A few weeks ago, YouTube recommended me a Minecraft video from Dream’s Channel in which he was trying to beat the game while his friend George attempted to stop him. That video was really fun and got me to explore more of their content.

Right now, there’s a bunch of people recording and uploading Minecraft videos to YouTube, but these two found a way to make their content different. Basically, they build their own plugins to change the rules of the game and then they record themselves attempting to beat the modified game. All I can say is that I love their content, and it’s awesome to see what you can accomplish with the power of code.

A few days later, I had an idea to develop a Minecraft mod and thought Why not? It will be fun!

Selecting the tools

Just like in Minecraft, we need some tools but in this case, they will help us in the creation process of our first mod.

Multiple tools help you build Minecraft mods, and I chose Fabric because one of the mods that I usually play with was built with it.

Minecraft uses Java and so does Fabric, which means we also need to have the Java Development Kit or JDK installed. To be more specific, we need the JDK 8 to be able to compile our mod. You can download it on this page.

Last but not least, we need to pick a code editor, in this case, I chose Visual Studio Code because it’s my favorite editor. Nevertheless, you can use whatever editor you like for this guide, as most of the steps will be performed in the CLI.

Setting up the project

For this guide, we will be using a starter to move quickly into actually building our first mod. Let’s go through the following steps:

1. Clone / Download the repository

If you use Git, just clone the repo:

Exit fullscreen mode

2. Open the project folder with your code editor

Using Visual Studio Code:

Exit fullscreen mode

3. Open a terminal inside the project folder and run the client

Exit fullscreen mode

4. Check that everything is working

A Minecraft instance should be running now on your computer, and the console should have printed these two lines alongside others:

Exit fullscreen mode

If that’s not the case for you, recheck everything and if nothing seems to work, leave a comment or send me a PM and I’ll try to help you.

Getting to know the project

At the moment, we can already get our hands dirty by starting to code, but let’s get familiarized with some of the files.

gradle.properties

In this file, we can configure some values that will be used when building our mod. For example, we can change the Minecraft version, the fabric loader version, the mod version and other properties that we may need to change if we want to use new features of Fabric or Minecraft.

Exit fullscreen mode

src/main

src/main/java

All the Java code is located inside this folder. There we can find a package called starter which contains two items: the StarterMod.java file and the mixin package.

We can find the file StarterMixin.java inside the mixin package.

TIP: If you’re using Visual Studio Code, I recommend you to install the Java Extension Pack. It will power your editor with a bunch of utilities to make Java development easier.

This is the main entry point of our mod, as we can see, it belongs to the starter package and implements the onInitialize() method, which simply prints Hello Fabric world! to the console.

Exit fullscreen mode

This class belongs to the starter.mixin package. Our mod will be really small so we shouldn’t worry a lot about the file structure of our project. Let’s just assume that all mixins will be located inside the starter.mixin package.

And what are mixins?

That’s part of the magic of mixins, and this is just the tip of the iceberg, for now, this is all we need to build our mod. If you want more in-depth knowledge you should go check the Mixin docs.

Exit fullscreen mode

src/main/resources

Inside the resources folder, we can find the assets folder, which right now only contains the icon for our mod. Besides that folder, there are two JSON files:

For this file, I recommend you to go into the Fabric docs about fabric.mod.json and read about every field defined inside the file of our project.

If you prefer to read the docs later, just take a look at the entrypoints and mixins properties.

I bet you can already see a connection here. In the entrypoints is where we are telling Fabric which one of our Java classes should act as the main entry point of our mod.

Exit fullscreen mode

Remember our StarterMixin class? This is how we can tell the toolchain the mixins that we want to include in our mod. The package property is where we define the Java package where the mixins are located, and inside the mixins array is where we can put all the mixin classes that we want to include to the game.

This file follows the specification defined in the Mixin configuration files section of the Mixin Docs. Just the same as before, I recommend you to go to the docs and learn more about this file 😄

Exit fullscreen mode

Let’s build our mod!

Now that we are familiar with the project, let’s gets our hands dirty and create our mod!

In this case, the mod will simply alter one mechanic of the game: receiving damage. We’ll make it so whenever a player receives damage, it will switch its position and inventory with another player in the server.

For this, we’re going to need a mixin that injects code in the PlayerEntity class, to be more specific, just before the end of the damage() method.

Detecting when players receive damage

Let’s create this new mixin in the starter.mixin package with the name SwitchPlayerEntityMixin.java :

Exit fullscreen mode

Don’t forget to add it to the starter.mixins.json file:

Exit fullscreen mode

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Just like in the GIF, you should be able to see a new line pop up in the console every time the player gets hurt, and that means we can continue to the explanation of what is going on.

Both the source and amount are parameters that the original damage method receives, and that’s the reason we can just use them in our method.

Accessing the current player

Right now, the mod is just printing a line every time a player gets hurt, our next objective is accessing the player instance.

We don’t have a way to tell the compiler that this method is being executed inside of another type of class, so we can use this trick:

Exit fullscreen mode

Exit fullscreen mode

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Switching positions with another player

The world property references the current Minecraft World that is being played, and one of the things we can do with it is getting the list of the online players.

With that list, we can pick one of those players and later, swap their positions as you can see in the following code:

Exit fullscreen mode

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Swapping their inventories

And now we’ll add the last feature of the mod: swapping the inventory of the players.

To swap the inventories of two players, we have to clone each inventory and after that, we can just replace and swap them. The inventory of a player can be accessed using the inventory property.

Exit fullscreen mode

As you may have noticed, we’re only swapping the inventories if both players are alive because if we don’t include this check, one of the inventories would get lost whenever a player died.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

The final code

I also recommend you to rename the package from starter to whatever you want, just remember to change every occurrence in the project.

You can find the latest version of the code in the branch final-code of the starter repo. Click here see the final version of the mod.

Packaging the mod

To create a bundle of your mod, you only need to run the following command:

Exit fullscreen mode

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Learning resources

Here are some resources that may come in handy if you want to learn more about Minecraft Modding:

The Fabric Wiki. This one has already been mentioned in the article, but seriously, go check it out because there’s a lot of content that I haven’t covered!

The Forge API. The Forge API is the most famous Minecraft API, you may want to check it out because some of the best mods out there have been built with it!

ScriptCraft. There seems to be a way to build mods using JavaScript, so if you have a background in web dev, you may want to try this one.

MCreator. As their site says, MCreator is a software used to make Minecraft mods and data packs using an intuitive easy-to-learn interface or with an integrated code editor. If you know about someone that wants to get started with programming, this may be a good way to introduce them!

Conclusion

Building my first Minecraft Mod was interesting because I got to know a bit more about how my favorite game works, and I even managed to craft something really fun to play.

Also, I took this as an opportunity to create this article because I think modding is a great way to get introduced to programming, and there are a lot of Minecraft players that may get interested and end up learning a lot about software development.

How to make a Minecraft Mod / Introduction / Tutorial Series

Want to learn how to make a mod and show off to your friends? Yes? Well TeamJaval
have made an awesome tutorial guide on how you can!

— Setup workspace and get your mod ready for modding : You’re already here!
— Setting up debug mode and Gradle : Click Here
— Basic mod file : Click Here
— Proxies: Click Here
— Adding a new item : Click Here (Coming soon!)
— Adding a new block : Click Here (Coming soon!)
— Adding functionality to your item : Click Here (Coming soon!)
— Adding functionality to your block : Click Here (Coming soon!)
— Package your mod for posting : Click Here (Coming soon!)

Advanced tutorials (Wait for basic mod tutorials to be finished!) :

— Surround the player with a cage : Click Here (Coming soon!)
— Making a simple GUI : Click Here (Coming soon!)
— Making an entity : Click Here (Coming soon!)
— Adding AI to your entity : Click Here (Coming soon!)
— Making a custom dimension : Click Here (Coming soon!)
— And many more to come!

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Setup :

First of all, you’ll need to download the latest version of Eclipse, the latest Minecraft Forge installer and JDK.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Next you will need to run the JDK installer and JDK will be partially installed.
To finish off setting up JDK you must go to:

And follow the tutorial there, this block would get too long if I put that in here.. XD

Next, extract the eclipse.zip and inside that will be an eclipse.exe, you can put a shortcut to that on your desktop.

Next you will need to run the Minecraft Forge Installer, select «Extract» and select the folder you would like to mod in. (e.g C:\Minecraft\Modding)

Go to the folder you extracted Minecraft Forge into, then inside of that make a new folder called «Forge».

Open your extracted minecraftforge.zip and drag the contents into your newly created folder, » Forge «.

Eclipse should open a window looking like this:

That’s all for this tutorial and I will see you all in the next tutorial!

That is it for this tutorial on Setting up, next we will be getting the debugger set up so that you can test your mods without having to recompile them! I hope you’ve enjoyed this tutorial introduction and hope that alot of you will use this to create awesome mods.

To create these tutorials for you is quite a challenge, If
you’d like to see more tutorials and more sections covered then please
donate to our team as generously as you can. Every bit of it helps and
supports us even more.

How to make mods for minecraft. Смотреть фото How to make mods for minecraft. Смотреть картинку How to make mods for minecraft. Картинка про How to make mods for minecraft. Фото How to make mods for minecraft

Источники информации:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *