Well, I've been trying to mod for a few days, and found a guide to creating mods with Modloader. I tried to create a block using the code from it, but when I attempt to craft it in game, nothing happens. If I click on the box that you use to recieve other items, the same thing (nothing) happens. I'm hoping that someone can find the error in the code - here it is:
BlockExample.java
package net.minecraft.src;
import java.util.Random;
public class BlockExample extends Block
{
public BlockExample(int i, int j)
{
super(i, j, Material.ground);
}
public int idDropped(int i, Random random)
{
return 0;
}
}
mod_Tutorial1.java
package net.minecraft.src;
public class mod_Tutorial1 extends BaseMod{
public static final Block example = (new BlockExample(120, 0).setBlockName("Example"));
public mod_Tutorial1()
{
ModLoader.RegisterBlock(example);
example.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/tex2.png");
ModLoader.AddName(example, "Example Block");
ModLoader.AddRecipe(new ItemStack(example), new Object[] {"##", Character.valueOf('#'), Block.dirt});
}
public String Version() {
return "1.8.1";
}
}
I believe that if you use AddRecipe you need to specify something for all nine slots. You can put some other character in there and not define it to leave it as empty. For example, I have a recipe in the next version of my mod that looks like:
ModLoader.AddRecipe(new ItemStack(factoryWrenchItem, 1), new Object[]
{
"S S", " S ", " S ",
Character.valueOf('S'), steelIngotItem
}
);
Since I don't give a meaning for the space, it comes up as not requiring anything in those slots. If you want to have your recipe work when you put two dirt anywhere (like how dying wool works), look into AddShapelessRecipe.
Honestly I've never gotten startclient to work due to bizarre classpath issues; I only test on the actual game after reobfuscation. Does your game's ModLoader.txt mention your mod is being loaded? My bet is it's just not finding it.
Honestly I've never gotten startclient to work due to bizarre classpath issues; I only test on the actual game after reobfuscation. Does your game's ModLoader.txt mention your mod is being loaded? My bet is it's just not finding it.
Yes, it is not loading it. Do I need to add something to the 'mods' file to make it load it?
Your name in .setBlockName and ModLoader functions are not the same, in .setBlockName you have "Example" but in your ModLoader functions you use "example"
Make sure your capital letters match up, that is very important.
Next your recipe needs to look like this:
ModLoader.AddRecipe(new ItemStack(example, 1), new Object[] {"## ", Character.valueOf('#'), Block.dirt});
You didn't specify the number of items the recipe produces, and I believe you need to use up all 3 slots in the recipe row. So if you are using two dirt blocks to make your new block, then it will be "## " not "##"
Your name in .setBlockName and ModLoader functions are not the same, in .setBlockName you have "Example" but in your ModLoader functions you use "example"
Make sure your capital letters match up, that is very important.
Next your recipe needs to look like this:
ModLoader.AddRecipe(new ItemStack(example, 1), new Object[] {"## ", Character.valueOf('#'), Block.dirt});
You didn't specify the number of items the recipe produces, and I believe you need to use up all 3 slots in the recipe row. So if you are using two dirt blocks to make your new block, then it will be "## " not "##"
Good luck!
A couple minor corrections - an ItemStack with just an Item or a Block as its argument will have a quantity of 1, so if he only wants one that code is correct; and the name on setBlockName does not need to match the human-readable name as it's only used internally (unlike AddName). Plus server-side mods don't even have AddName. I'm not entirely sure why setBlockName is even there, all it seems to do is break things if it isn't unique to every block.
Simply copying and pasting the ModLoader files into minecraft.jar. Also, when I attempt to run it in game after making the corrections you gave me (from cecilhowe) it still does not work. Obviously, I'm probably just doing something wrong with the installation of Modloader.
So in your minecraft jar you have ModLoader as well as your mod_Tutorial1.class and BlockExample.class? And you got the latter two from reobf/minecraft/ in your MCP install?
So in your minecraft jar you have ModLoader as well as your mod_Tutorial1.class and BlockExample.class? And you got the latter two from reobf/minecraft/ in your MCP install?
java.lang.Exception: Image not found: /mymod/tex2.png
Well that looks like it's probably your problem there (your jar is missing that sprite).
I'm not using that anymore. Those were all old files. I found out what to do about that now and have the tex2.png in the correct location for the mod I'm working on currently.
Honestly my only guess is that maybe somehow having a "1" in your mod's class name is throwing off the algorithm modloader uses to find mods. If that doesn't fix it I'm out of ideas.
BlockExample.java
mod_Tutorial1.java
Edit: Wrong section, sorry....
Since I don't give a meaning for the space, it comes up as not requiring anything in those slots. If you want to have your recipe work when you put two dirt anywhere (like how dying wool works), look into AddShapelessRecipe.
INFORMATION WANTS TO BE WRONG
Is it possible that I installed Modloader incorrectly? Or anything else wrong with the code?
INFORMATION WANTS TO BE WRONG
It does not show up in TooManyItems. It looks like the errors with the code are worse than I thought. :sad.gif:
Edit: I ran this using startclient.bat, and it worked fine. Am I installing the mod wrong when I put it in the normal client then?
INFORMATION WANTS TO BE WRONG
Yes, it is not loading it. Do I need to add something to the 'mods' file to make it load it?
Make sure your capital letters match up, that is very important.
Next your recipe needs to look like this:
You didn't specify the number of items the recipe produces, and I believe you need to use up all 3 slots in the recipe row. So if you are using two dirt blocks to make your new block, then it will be "## " not "##"
Good luck!
How are you installing it right now?
A couple minor corrections - an ItemStack with just an Item or a Block as its argument will have a quantity of 1, so if he only wants one that code is correct; and the name on setBlockName does not need to match the human-readable name as it's only used internally (unlike AddName). Plus server-side mods don't even have AddName. I'm not entirely sure why setBlockName is even there, all it seems to do is break things if it isn't unique to every block.
INFORMATION WANTS TO BE WRONG
INFORMATION WANTS TO BE WRONG
Yes.
INFORMATION WANTS TO BE WRONG
Alright, well here it is. All that I can find is stuff from previous mods...
Perhaps I should delete my Minecraft files, use cleanup.bat on the MCP files, and try again with all of this from there?
Well that looks like it's probably your problem there (your jar is missing that sprite).
INFORMATION WANTS TO BE WRONG
I'm not using that anymore. Those were all old files. I found out what to do about that now and have the tex2.png in the correct location for the mod I'm working on currently.
INFORMATION WANTS TO BE WRONG
Also, this is the last post I can make until September 30th, so I'll probably edit this one as an answer to other posts...
Edit: I'm going to go ahead and completely reinstall it all. Hope for the best...
Got it! Thanks for the help, I probably wouldn't of figured it out without your help, power crystals. :smile.gif:
Honestly my only guess is that maybe somehow having a "1" in your mod's class name is throwing off the algorithm modloader uses to find mods. If that doesn't fix it I'm out of ideas.
INFORMATION WANTS TO BE WRONG
ModLoader.AddRecipe(new ItemStack(Sword, 1), new Object[] {
" * ", " * ", " r ", Character.valueOf('*'), Block.obsidian,Character.valueOf('r'),Item.ingotIron
});