After hours upon hours of scouring the web for tutorials on making mods SMP-compatible to no avail, I spent all night trying things out and finally found a way to make it work with MCP, Modloader, and ModloaderMP. I'm not going to go into specific stuff here, but I will go through the steps I took which allowed me to successfully create a working client and server mod which adds a new block to world generation, as well as a new item to be harvested from that block. Hopefully this will save some of you the hours of searching I spent!
Note: This was done with version 1.6.5 of minecraft and 3.3 of MCP.
First off, follow existing tutorials to set your MCP up to decompile a minecraft.jar already loaded with Modloader and ModloaderMP. Plenty of tutorials out there detailing that, so I won't detail it here. But now is where we do some stuff differently:
Step 1 - Getting decompiled ModloaderMP server files
1. First, download the minecraft_server.jar and place it in your \mcp\jars folder. This is the regular procedure for decompiling it.
2. Add the ModloaderMP server classes to that minecraft_server.jar. Normally, you should only use an unmodded server.jar with MCP, and we'll see what shortly.
3. Run decompile.bat. This will spit out an error at the end about an exception on the server.java file. If you're curious, you'll see that it is indeed messed up if you go look at it in the \mcp\src folder. But ignore that error for now, here's the important step:
4. Navigate to your \mcp\src\server\minecraft_server\net\src\minecraft\src folder and copy all of the .java files there. There are only 8 needed, but I can't remember which ones they are. I'll update this thread another time with the exact files.
5. Copy these files to a new folder somewhere (NOT within the mcp\src folders).
6. Run cleanup.bat
Step 2 - Adding ModloaderMP server files to a working server decompile
1. Go back and replace the modded minecraft_server.jar with a vanilla unmodded one and decompile again
2. Paste all those .java files you copied before into the new \mcp\src\server\minecraft_server\net\src\minecraft\src folder; you can select "don't replace -> do for all" on Windows to save some time.
3. Run recompile.bat and then updatemd5.bat
You're now ready to begin modding. Follow existing guides on adding blocks and items through Modloader, but there's one major difference: you will not be using the Modloader.AddName function on your server files. Here's some client code for an example new block that generates on the world and can have a new ore harvested from it:
mod_Content.java
package net.minecraft.src;
import java.util.Random;
public class mod_Content extends BaseModMp
{
public static final Block TinOre = new BlockTinOre(97, 0).setHardness(2.0F).setResistance(5.0F).setBlockName("TinOre");
public static final Item RawTin = new Item(2000).setItemName("RawTin");
public mod_Content()
{
ModLoader.RegisterBlock(TinOre);
TinOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/textures/blocks/Loam.png");
RawTin.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/items/Loamlump.png");
ModLoader.AddName(TinOre, "Tin Ore");
ModLoader.AddName(RawTin, "Raw Tin");
}
public void GenerateSurface(World world, Random rand, int chunkX, int chunkZ)
{
for(int i = 0; i < 120; i++)
{
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(100);
int randPosZ = chunkZ + rand.nextInt(16);
(new WorldGenMinable(mod_Content.TinOre.blockID, 4)).generate(world, rand, randPosX, randPosY, randPosZ);
}
}
public String Version()
{
return "1.6.5";
}
}
BlockTinOre.java
package net.minecraft.src;
import java.util.Random;
public class BlockTinOre extends Block
{
protected BlockTinOre(int i, int j)
{
super(i, j, Material.iron);
}
public int idDropped(int i, Random random)
{
return mod_Content.RawTin.shiftedIndex;
}
}
RawTin.java
package net.minecraft.src;
public class RawTin extends Item {
public RawTin (int i)
{
super(i);
maxStackSize = 64;
}
}
All of this is very basic, and you can simply copy and paste these three files into both your client src folder and your server src folder. HOWEVER, you will have to remove those Modloader.AddName lines from the server's copy. The server's copy would look like this:
mod_Content.java
package net.minecraft.src;
import java.util.Random;
public class mod_Content extends BaseModMp
{
public static final Block TinOre = new BlockTinOre(97, 0).setHardness(2.0F).setResistance(5.0F).setBlockName("TinOre");
public static final Item RawTin = new Item(2000).setItemName("RawTin");
public mod_Content()
{
ModLoader.RegisterBlock(TinOre);
TinOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/textures/blocks/Loam.png");
RawTin.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/items/Loamlump.png");
}
public void GenerateSurface(World world, Random rand, int chunkX, int chunkZ)
{
for(int i = 0; i < 120; i++)
{
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(120);
int randPosZ = chunkZ + rand.nextInt(16);
(new WorldGenMinable(mod_Content.TinOre.blockID, 4)).generate(world, rand, randPosX, randPosY, randPosZ);
}
}
public String Version()
{
return "1.6.5";
}
}
Now, barring any code errors, you should be able to recompile and reobfuscate your new class files just fine. One important note, though; you will not be able to test your mod by using the startserver.bat file within MCP, as that file doesn't take Modloader functions into account. To test your mod, you will have to do normal procedures of adding your appropriate client and server class files into their respective .jar's and removing the META-INF folder from the client .jar.
I hope this helps some of you new modders out, and good luck coding the next big thing! But let's not forget, the greatest mod anyone could ever make would simply be fully-commented source code. :tongue.gif:
This is a good post, I've been looking for this for a while so I can make some more building blocks for my server!
But I've reached a problem while decompiling, when I open decompile the console shows this:
== MCP v5.0 ==
> Creating Retroguard config files
== Decompiling Client ==
!! Modified jar detected. Unpredictable results !!
> Creating SRGS for client
> Applying Retroguard to client
what are the names of the decompiled ModLoaderMP classes?
i have them all exept for abm, ajq, and dr.
if any one can tell me what .java files i need that would be great!
Sorry, i'm not sure what you mean. I am by no means an experienced modder. Is something going wrong while you're trying to do the tutorial? I followed it just fine and everything worked.
Great tutorial man, thanks a lot. It worked, I got it all in my src folders and stuff then transferred my mods to my server src like you said. Changed BaseMod to BaseModMp and got rid of the addname lines. Went to test it and I could give myself the items using tmi and the damage outputs worked and everything but I can't craft them. I put the materials in the crafting table and it comes up like it should, like click it to make it but I can't actually click it. A better explanation would be I can click it and actually see the icon move as if I were going to drag it to my inventory but it immediately goes back to the slot and being "unclicked" I'm assuming this is just a minor problem somewhere in my code. Can someone help please? Let me know if you need to see some code.
Note: This was done with version 1.6.5 of minecraft and 3.3 of MCP.
First off, follow existing tutorials to set your MCP up to decompile a minecraft.jar already loaded with Modloader and ModloaderMP. Plenty of tutorials out there detailing that, so I won't detail it here. But now is where we do some stuff differently:
Step 1 - Getting decompiled ModloaderMP server files
1. First, download the minecraft_server.jar and place it in your \mcp\jars folder. This is the regular procedure for decompiling it.
2. Add the ModloaderMP server classes to that minecraft_server.jar. Normally, you should only use an unmodded server.jar with MCP, and we'll see what shortly.
3. Run decompile.bat. This will spit out an error at the end about an exception on the server.java file. If you're curious, you'll see that it is indeed messed up if you go look at it in the \mcp\src folder. But ignore that error for now, here's the important step:
4. Navigate to your \mcp\src\server\minecraft_server\net\src\minecraft\src folder and copy all of the .java files there. There are only 8 needed, but I can't remember which ones they are. I'll update this thread another time with the exact files.
5. Copy these files to a new folder somewhere (NOT within the mcp\src folders).
6. Run cleanup.bat
Step 2 - Adding ModloaderMP server files to a working server decompile
1. Go back and replace the modded minecraft_server.jar with a vanilla unmodded one and decompile again
2. Paste all those .java files you copied before into the new \mcp\src\server\minecraft_server\net\src\minecraft\src folder; you can select "don't replace -> do for all" on Windows to save some time.
3. Run recompile.bat and then updatemd5.bat
You're now ready to begin modding. Follow existing guides on adding blocks and items through Modloader, but there's one major difference: you will not be using the Modloader.AddName function on your server files. Here's some client code for an example new block that generates on the world and can have a new ore harvested from it:
mod_Content.java
BlockTinOre.java
RawTin.java
All of this is very basic, and you can simply copy and paste these three files into both your client src folder and your server src folder. HOWEVER, you will have to remove those Modloader.AddName lines from the server's copy. The server's copy would look like this:
mod_Content.java
Now, barring any code errors, you should be able to recompile and reobfuscate your new class files just fine. One important note, though; you will not be able to test your mod by using the startserver.bat file within MCP, as that file doesn't take Modloader functions into account. To test your mod, you will have to do normal procedures of adding your appropriate client and server class files into their respective .jar's and removing the META-INF folder from the client .jar.
I hope this helps some of you new modders out, and good luck coding the next big thing! But let's not forget, the greatest mod anyone could ever make would simply be fully-commented source code. :tongue.gif:
Honestly though : it was really helpful
That part can take a long time. Wait for a bit.
Mjölnir Hammer Mod
i have them all exept for abm, ajq, and dr.
if any one can tell me what .java files i need that would be great!