Before you can program in java, you need the Java JDK. Search that on the internet and install the latest version for your operating system.
To set up for mod making, first you need to download a Java IDE. I use the Eclipse IDE and recommend it for mod making.
After you've downloaded and installed your IDE, you will want to download the Minecraft Coder Pack. If you search that on the internet, click on the first link and download that.
Now, we can start setting up. You will want to extract the Mincraft Coder Pack that you just downloaded to a folder called mcp. You can save that folder wherever you want, but remember where you saved it. Now go to your Minecraft directory. On windows, click the start menu and search for %appdata%. On linux, show the hidden folders in your home directory. Mac users, you'll have to figure out where your directory is, as I've never used a Mac before. Then click on the folder called .minecraft. You will see many folders inside of it, but we only want the ones named bin and resources. Open the bin folder and you will see a file called minecraft.jar. Download and Install modloader and delete the META-INF folder inside the minecraft.jar. Copy those. After you have them copied, open your mcp folder again. Find the folder that is named jars and paste the bin and resources folder into that. Then go to the main mcp directory. Click on the decompile.bat(or decompile.sh) and wait for it to decompile. When it's done, you're set up!
Your first mod:
Once you're set up, you will want to open your Java IDE. I will be telling you how to use Eclipse for this tutorial. Eclipse will ask you where you want to open your workspace. Enter your mcp directory followed by "\eclipse"(or "/eclipse") It will load and you will see a folder named Client and a folder named Server. We want the client folder. Open the client folder and you more folders. Open the folder called src and you will see a ton of packages. Open the package called net.minecraft.src and you will see all of Minecraft's code!
Now you're probably wondering how we're going to edit this. We aren't. We are going to make an entirely new class, so right click on net.minecraft.src and select new -> class. Name this class mod_***, replacing the *** with whatever name you choose. You will see a little bit of Java code, but since you should know Java, this isn't scary. You just need to make the class extends BaseMod. Example:
public class mod_MyMod extends BaseMod
{
Once you've done this, you will get an error, but this is normal. Just add these lines of code to your mod.
public String getVersion()
{
return "MyMod V1.0";
}
public void load()
{
}
Now your mod is MOSTLY set up. To get your first block, add this under your class declaration.
public static Block myFirstBlock = new Block(170, Material.wood);
And add this into your load method.
ModLoader.registerBlock(myFirstBlock);
ModLoader.addName(myFirstBlock, "My First Block");
You can now click the Run button and see your mod in action! (The run button in Eclipse looks like a Play button on a remote!)
Your first Item:
To make an Item, add this under your class declaration line.
public static Item myFirstItem = new Item(5021);
And add this to your load method.
ModLoader.addName(myFirstItem, "My First Item");
Adding textures to your Blocks and Items:
To add a texture, you need an image editing program, like GIMP or Paint .NET. Download and install whichever one you want and make a new 16x16 image. Draw what you want and save it as whatever you want, as long as it is a .png. Close your Java IDE and open up the mcp folder. Go to your jars -> bin -> minecraft.jar and open it with WinRAR or 7-Zip. Find the folder called textures and drag your image into the blocks or items, depending on what your image is for. Now close WinRAR/7-Zip and re-open your Java IDE. Go into your mod's class and add the following line of code at the end of your block, but before the semicolon. (Do NOT add the .png at the end!!!!!!)
.getIndirectPowerOutput("yourImageName");
For items, add this at the end, but before the semicolon. (Do NOT add the .png at the end!!!!!!);
.setUnlocalizedName("yourImageName");
These methods just tell Minecraft to look in the corresponding folder for the image with that name. (Don't use the same name twice!!)
You can now click the Run button and see your mod with TEXTURES!
Adding a simple crafting recipe:
You probably want your mod to work in survival as well as in creative. No worries, you can make crafting recipes very easily. To make a crafting recipe, simple add this code into your load method-
ModLoader.addRecipe(new ItemStack(myFirstItem, 1), new Object[]{"WWW", "WWW", "WWW", 'W', Block.planks});
Let's break this down. The first parameter is an ItemStack, which is the Item/Block you want to give the player, followed by the amount of that Item/Block.
The second parameter is an Object Array, which is the 3x3 crafting square, followed by the symbol's declaration, which, in English, means that the symbol you type is equal to the next thing after the comma.
Adding a smelting (cooking) recipe:
To add a smelting recipe, you must type this into your load() method -
ModLoader.addSmelting(myFirstItem.itemID, new ItemStack(myFirstBlock, 1), 0.4F);
Let's break this down.
The first part,
ModLoader.addSmelting
is pretty easy, right?
Well the first parameter of this method is what you're wanting to smelt, i.e. a block of iron, but the ID of the item/block, which turns the Block/Item into an integer.
The second parameter is an ItemStack that represents what you want to smelt it into. The first ItemStack parameter is the item/block. The second ItemStack parameter is the amount in the ItemStack.
The last parameter of the addSmelting method is the amount of XP you want to be given to the player. It must be a float.
Adding a light value to a block:
To add a light value to a block, just add this to the block's declaration:
.setLightValue(1.0F);
This method tells Minecraft that this block will give off the same brightness as GlowStone. Any higher will not be noticeable, so keep it at or below 1.0F. The 'F' means that the number is a float, which is required for this method.
Adding a Shapeless Crafting Recipe:
To add a shapeless recipe (a recipe that doesn't need the ingredients in any certain order), just add this into your load() method-
ModLoader.addShapelessRecipe(new ItemStack(myFirstBlock, 1), new Object[] {Item.ingotGold, myFirstItem});
The first parameter of this method is an ItemStack, which is the Item/Block you want to give the player, and the amount of said Item/Block.
The second parameter is an Array of Objects, which is the ingredients you need to craft the ItemStack.
In this case, to make myFirstBlock, we need 1 gold ingot and myFirstItem. You can play around with this, but you cannot have more than nine ingredients. Any more than that and you won't be able to craft it!
Rollback Post to RevisionRollBack
java.lang.NullPointerException - Signature cannot be null!
public static final Item emeraldsword = (new ItemSword(1000, EnumToolMaterial.REALEMERALD).setUnlocalizedName("/Textures/emeraldsword")).setCreativeTab(CreativeTabs.tabCombat);
public void load() {
ModLoader.addName(emeraldsword, "Emerald Sword");
ModLoader.addRecipe(new ItemStack(emeraldsword, 1), new Object[]{
"WWW", "WWW", "WWW", 'W', Block.dirt,
});
}
public String getVersion() {
return "More Swords and Mobs Mod v1.0";
}
Nonono- like the item isnt even there. When I craft it nothing happends. I hover over the slot- but it doesnt appear. I didnt have this problem in 1.4 D:
Ok, but Im still lost. I see other people making 1.5.1 mods- but what am I doing wrong??? Here is the new code:
package net.minecraft.src;
public class Mod_moswordsandmobs extends BaseMod{
public static final Block awesome = (new Block(170, Material.glass));
public static final Item emeraldsword = (new ItemSword(2000, EnumToolMaterial.REALEMERALD).setUnlocalizedName("emeraldsword")).setCreativeTab(CreativeTabs.tabCombat);
public void load() {
ModLoader.addName(emeraldsword, "Emerald Sword");
ModLoader.addShapelessRecipe(new ItemStack(emeraldsword, 1), new Object[]{
"W", 'W', Block.dirt
});
ModLoader.registerBlock(awesome);
ModLoader.addName(awesome, "Awesome");
}
public String getVersion() {
return "More Swords and Mobs Mod v1.0";
}
}
I also tested a block that I called awesome.(no texture- it should make it just a purple block)Never mind- you renaming idea worked!!! THANK YOU SO MUCH!!!!
Ok, im new to this, but how would i set a damage value to a block i created, and also how do i get it to be Mineable.
To change the hardness, you add this to the end of your block code, but before the semicolon:
.setHardness(1.0F)
Change the 1.0 to what you want, but keep the F at the end, otherwise you will get errors. And what do you mean by mine-able? Do you mean having it randomly generate over the terrain? If so, ModLoader seems to have an error with that for 1.5.1, but I'll try to fix that (or wait for an update, whichever comes first) and tell you how to fix that and how to then make it mine-able.
Hi,
I have a problem
i can't decompile
Is say decompiling...
next says Decompile feiled :/
And gives alot of errors!
Plese help me!
Pleseeeeeeeeeeeeeeeeeeeeee
Can you post the errors please?
Rollback Post to RevisionRollBack
java.lang.NullPointerException - Signature cannot be null!
Before you can program in java, you need the Java JDK. Search that on the internet and install the latest version for your operating system.
To set up for mod making, first you need to download a Java IDE. I use the Eclipse IDE and recommend it for mod making.
After you've downloaded and installed your IDE, you will want to download the Minecraft Coder Pack. If you search that on the internet, click on the first link and download that.
Now, we can start setting up. You will want to extract the Mincraft Coder Pack that you just downloaded to a folder called mcp. You can save that folder wherever you want, but remember where you saved it. Now go to your Minecraft directory. On windows, click the start menu and search for %appdata%. On linux, show the hidden folders in your home directory. Mac users, you'll have to figure out where your directory is, as I've never used a Mac before. Then click on the folder called .minecraft. You will see many folders inside of it, but we only want the ones named bin and resources. Open the bin folder and you will see a file called minecraft.jar. Download and Install modloader and delete the META-INF folder inside the minecraft.jar. Copy those. After you have them copied, open your mcp folder again. Find the folder that is named jars and paste the bin and resources folder into that. Then go to the main mcp directory. Click on the decompile.bat(or decompile.sh) and wait for it to decompile. When it's done, you're set up!
Once you're set up, you will want to open your Java IDE. I will be telling you how to use Eclipse for this tutorial. Eclipse will ask you where you want to open your workspace. Enter your mcp directory followed by "\eclipse"(or "/eclipse") It will load and you will see a folder named Client and a folder named Server. We want the client folder. Open the client folder and you more folders. Open the folder called src and you will see a ton of packages. Open the package called net.minecraft.src and you will see all of Minecraft's code!
Now you're probably wondering how we're going to edit this. We aren't. We are going to make an entirely new class, so right click on net.minecraft.src and select new -> class. Name this class mod_***, replacing the *** with whatever name you choose. You will see a little bit of Java code, but since you should know Java, this isn't scary. You just need to make the class extends BaseMod. Example:
Once you've done this, you will get an error, but this is normal. Just add these lines of code to your mod.
Now your mod is MOSTLY set up. To get your first block, add this under your class declaration.
And add this into your load method.
You can now click the Run button and see your mod in action! (The run button in Eclipse looks like a Play button on a remote!)
To make an Item, add this under your class declaration line.
And add this to your load method.
To add a texture, you need an image editing program, like GIMP or Paint .NET. Download and install whichever one you want and make a new 16x16 image. Draw what you want and save it as whatever you want, as long as it is a .png. Close your Java IDE and open up the mcp folder. Go to your jars -> bin -> minecraft.jar and open it with WinRAR or 7-Zip. Find the folder called textures and drag your image into the blocks or items, depending on what your image is for. Now close WinRAR/7-Zip and re-open your Java IDE. Go into your mod's class and add the following line of code at the end of your block, but before the semicolon. (Do NOT add the .png at the end!!!!!!)
For items, add this at the end, but before the semicolon. (Do NOT add the .png at the end!!!!!!);
These methods just tell Minecraft to look in the corresponding folder for the image with that name. (Don't use the same name twice!!)
You can now click the Run button and see your mod with TEXTURES!
You probably want your mod to work in survival as well as in creative. No worries, you can make crafting recipes very easily. To make a crafting recipe, simple add this code into your load method-
Let's break this down. The first parameter is an ItemStack, which is the Item/Block you want to give the player, followed by the amount of that Item/Block.
The second parameter is an Object Array, which is the 3x3 crafting square, followed by the symbol's declaration, which, in English, means that the symbol you type is equal to the next thing after the comma.
To add a smelting recipe, you must type this into your load() method -
Let's break this down.
The first part,
is pretty easy, right?
Well the first parameter of this method is what you're wanting to smelt, i.e. a block of iron, but the ID of the item/block, which turns the Block/Item into an integer.
The second parameter is an ItemStack that represents what you want to smelt it into. The first ItemStack parameter is the item/block. The second ItemStack parameter is the amount in the ItemStack.
The last parameter of the addSmelting method is the amount of XP you want to be given to the player. It must be a float.
To add a light value to a block, just add this to the block's declaration:
This method tells Minecraft that this block will give off the same brightness as GlowStone. Any higher will not be noticeable, so keep it at or below 1.0F. The 'F' means that the number is a float, which is required for this method.
To add a shapeless recipe (a recipe that doesn't need the ingredients in any certain order), just add this into your load() method-
The first parameter of this method is an ItemStack, which is the Item/Block you want to give the player, and the amount of said Item/Block.
The second parameter is an Array of Objects, which is the ingredients you need to craft the ItemStack.
In this case, to make myFirstBlock, we need 1 gold ingot and myFirstItem. You can play around with this, but you cannot have more than nine ingredients. Any more than that and you won't be able to craft it!
java.lang.NullPointerException - Signature cannot be null!
It only works for blocks, i.e.
java.lang.NullPointerException - Signature cannot be null!
java.lang.NullPointerException - Signature cannot be null!
public class Mod_moswordsandmobs extends BaseMod{
public static final Item emeraldsword = (new ItemSword(1000, EnumToolMaterial.REALEMERALD).setUnlocalizedName("/Textures/emeraldsword")).setCreativeTab(CreativeTabs.tabCombat);
public void load() {
ModLoader.addName(emeraldsword, "Emerald Sword");
ModLoader.addRecipe(new ItemStack(emeraldsword, 1), new Object[]{
"WWW", "WWW", "WWW", 'W', Block.dirt,
});
}
public String getVersion() {
return "More Swords and Mobs Mod v1.0";
}
}
java.lang.NullPointerException - Signature cannot be null!
java.lang.NullPointerException - Signature cannot be null!
java.lang.NullPointerException - Signature cannot be null!
java.lang.NullPointerException - Signature cannot be null!
I also tested a block that I called awesome.(no texture- it should make it just a purple block)Never mind- you renaming idea worked!!! THANK YOU SO MUCH!!!!
java.lang.NullPointerException - Signature cannot be null!
To change the hardness, you add this to the end of your block code, but before the semicolon:
Change the 1.0 to what you want, but keep the F at the end, otherwise you will get errors. And what do you mean by mine-able? Do you mean having it randomly generate over the terrain? If so, ModLoader seems to have an error with that for 1.5.1, but I'll try to fix that (or wait for an update, whichever comes first) and tell you how to fix that and how to then make it mine-able.
Can you post the errors please?
java.lang.NullPointerException - Signature cannot be null!
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
public class mod_Carpet extends BaseMod{
public static final Block carpet = (new Block(170, Material.grass));
public void load() {
ModLoader.registerBlock(carpet);
ModLoader.addName(carpet, "Carpet");
};
public String getVersion() {
return "Carpet Mod";
}
}
I made this code but it is saying that it is registering null, any help please?
java.lang.NullPointerException - Signature cannot be null!
2013-03-29 18:07:38 [INFO] [ForgeModLoader] Java is Java HotSpot(TM) 64-Bit Server VM, version 1.6.0_43, running on Mac OS X:x86_64:10.8.3, installed at /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
2013-03-29 18:07:38 [INFO] [ForgeModLoader] Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation
2013-03-29 18:07:39 [INFO] [STDOUT] 229 recipes
2013-03-29 18:07:39 [INFO] [STDOUT] 27 achievements
2013-03-29 18:07:40 [INFO] [Minecraft-Client] Setting user: Player100
2013-03-29 18:07:40 [INFO] [STDOUT] (Session ID is -)
2013-03-29 18:07:40 [INFO] [STDERR] Client asked for parameter: server
2013-03-29 18:07:40 [INFO] [Minecraft-Client] LWJGL Version: 2.4.2
2013-03-29 18:07:40 [INFO] [MinecraftForge] Attempting early MinecraftForge initialization
2013-03-29 18:07:40 [INFO] [STDOUT] MinecraftForge v7.7.0.597 Initialized
2013-03-29 18:07:40 [INFO] [ForgeModLoader] MinecraftForge v7.7.0.597 Initialized
2013-03-29 18:07:40 [INFO] [STDOUT] Replaced 85 ore recipies
2013-03-29 18:07:40 [INFO] [MinecraftForge] Completed early MinecraftForge initialization
2013-03-29 18:07:40 [INFO] [ForgeModLoader] Reading custom logging properties from /Users/Aditya/Desktop/MCP/jars/config/logging.properties
2013-03-29 18:07:40 [OFF] [ForgeModLoader] Logging level for ForgeModLoader logging is set to ALL
2013-03-29 18:07:40 [INFO] [ForgeModLoader] Searching /Users/Aditya/Desktop/MCP/jars/mods for mods
2013-03-29 18:07:41 [INFO] [ForgeModLoader] Forge Mod Loader has identified 4 mods to load
2013-03-29 18:07:41 [INFO] [mcp] Activating mod mcp
2013-03-29 18:07:41 [INFO] [FML] Activating mod FML
2013-03-29 18:07:41 [INFO] [Forge] Activating mod Forge
2013-03-29 18:07:41 [INFO] [mod_Carpet] Activating mod mod_Carpet
2013-03-29 18:07:41 [INFO] [ForgeModLoader] Configured a dormant chunk cache size of 0
2013-03-29 18:07:42 [INFO] [STDERR] java.lang.RuntimeException: Don't register null!
2013-03-29 18:07:42 [INFO] [STDERR] at net.minecraft.client.renderer.texture.TextureMap.registerIcon(TextureMap.java:229)
2013-03-29 18:07:42 [INFO] [STDERR] at net.minecraft.block.Block.registerIcons(Block.java:1380)
2013-03-29 18:07:42 [INFO] [STDERR] at net.minecraft.client.renderer.texture.TextureMap.refreshTextures(TextureMap.java:68)
2013-03-29 18:07:42 [INFO] [STDERR] at net.minecraft.client.renderer.RenderEngine.refreshTextureMaps(RenderEngine.java:520)
2013-03-29 18:07:42 [INFO] [STDERR] at net.minecraft.client.Minecraft.startGame(Minecraft.java:440)
2013-03-29 18:07:42 [INFO] [STDERR] at net.minecraft.client.MinecraftAppletImpl.startGame(MinecraftAppletImpl.java:44)
2013-03-29 18:07:42 [INFO] [STDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:729)
2013-03-29 18:07:42 [INFO] [STDERR] at java.lang.Thread.run(Thread.java:680)
2013-03-29 18:07:42 [INFO] [STDERR] java.lang.NullPointerException
2013-03-29 18:07:42 [INFO] [STDERR] at net.minecraft.client.renderer.texture.TextureMap.refreshTextures(TextureMap.java:102)
2013-03-29 18:07:42 [INFO] [STDERR] at net.minecraft.client.renderer.RenderEngine.refreshTextureMaps(RenderEngine.java:520)
2013-03-29 18:07:42 [INFO] [STDERR] at net.minecraft.client.Minecraft.startGame(Minecraft.java:440)
2013-03-29 18:07:42 [INFO] [STDERR] at net.minecraft.client.MinecraftAppletImpl.startGame(MinecraftAppletImpl.java:44)
2013-03-29 18:07:42 [INFO] [STDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:729)
2013-03-29 18:07:42 [INFO] [STDERR] at java.lang.Thread.run(Thread.java:680)