Sorry I have been gone for so long, truth be told I don't mod much anymore. I happened to check up on modloader's changes tho, and here is an update to the tutorial so people can start modding again, at least for a little while.
Note: It looks as though spawnlist was merged with Modloader, so there is no longer a need to use it. For people updating mods, please remove it from the src folder before recompiling. The only change you should need to make is to remove the bit about spawnlist in the mod_file and replace it with
ModLoader.AddSpawn(EntityPigman.class, 8, EnumCreatureType.creature);//not sure what the 8 does, play around with it if you want
I am creating this guide as more of an update to this guide: viewtopic.php?f=25&t=102487 by Club559. I have his permission to recreate this guide.
As his guide says, you need Modloader and Spawnlist. You will also need Minecraft Coder Pack.
Modloader: viewtopic.php?f=25&t=80246&hilit
MCP: http://mcp.ocean-labs.de/index.php/MCP_Releases
You will also be using his tutorial files(I really see no reason to reupload the same files), and a clean minecraft.jar.
Once you have these five things, here is what you do:
1. Add all of the contents of Modloader to your minecraft.jar
2.SKIP THIS STEP Add spawnlist.class to your minecraft.jar.
3. Add your entire bin folder to the jars folder in MCP.
4. Run decompile.bat.
5. Open the sources folder in MCP. Open all subfolders, and eventually src.
6. Copy the files from the sources for mcp folder of your tutorial folder(excluding Basemod, spawnlist, and Modloader)into the src folder in MCP.
7. Open EntityPigman.java(from the src folder of MCP) with any java editing program.(I use Netbeans).
8. Replace Pigman with the name of your mob(you can call it whatever you want, as long as it is the same everywhere, and code is ALWAYS case sensitive.)Also replace mymob.png with the name of your mob.(Make sure this is the same as the filename of your mob skin. for example: If your mod is called mod_Vaultboy, you would probably want to call your picture Vaultboy.png(it has to be a .png file btw) and so you would write Vaultboy.png where mymob.png is written.) If you would like your mob to drop something other than pork, check Item.java for a list of item ID's. If you want it to drop a block replace
return Item.porkCooked.shiftedIndex;
with this
return Block.nameofblock.blockID;
9. Save it.(If using Netbeans, DO NOT Save As to rename it, as this will not save as a .java file. Idk if all java editors are like this. Instead, Save, and close. Rename it externally.)
10. Open mod_Pigman.java(from the src folder of MCP).
11. This time you need to change a bit more code. In fact, you will be replacing all of it. Copy this code
package net.minecraft.src;
import java.lang.reflect.Method;
import java.util.Map;
public class mod_Pigman extends BaseMod
{
public String Version()
{
//not sure exactly what this does, but I know that you can write pretty much anything you want in there.
return "mod_Pigman version 0.3";
}
public mod_Pigman()
{
ModLoader.RegisterEntityID(EntityPigman.class, "Pigman", ModLoader.getUniqueEntityId());
ModLoader.AddSpawn(EntityPigman.class, 8, EnumCreatureType.creature);//not sure what the 8 does, play around with it if you want
}
//this part gives your mob a human model. This part is necessary if you want your mob to be able to carry stuff.
public void AddRenderer(Map map)
{
map.put(EntityPigman.class, new RenderBiped(new ModelBiped(), 0.5F));
}
}
Now, of course, replace Pigman with the name of your mob. If you would like to change where you mob spawns, open up spawnlist.java(from src in MCP) for a list of different biomes, and replace Surface biomes(In this file, not spawnlist.java) with what you want.
12.Save this file. Rename it externally.
13.Run recompile.bat.(Found in the MCP folder).
14.If recompile.bat did not return any errors, skip step 14.b.
14.b)If recompile.bat did return an error, make sure to go through both of your mod's files and check for spelling and capitalization errors, and make sure you followed these steps exactly.
15.Open the conf folder, and open clientobfuscation.txt.
16.Erase what is written there, and write the names of your mod files, one per line. Ex: If your file is called mod_Pigman.java, you would write mod_Pigman
17.Save.
18.Run reobf.bat.(If there is an error here chances are you have a spelling error in clientobfuscation.txt.)
19.This is important. Running test.bat will not work because you do not have all of the modloader files, so you have to take the files from your final_out/minecraft folder, and put them directly into your minecraft.jar(the one in your .minecraft/bin folder). If you are uncomfortable with testing this mod on your world, create a new one to test it out(having single player commands really helps test this). I am 99% sure this can not wreck a save, but play it safe if you are worried.
20.Put your mob skin into the mob folder of your minecraft.jar.
21.Enjoy your mod.
*NOTE: You do not need to compile Entitylist, modloader, basemod or spawnlist. You only need to compile mod_Yourmob and EntityYourmob. You will still need the latest spawnlist and modloader to run your mod(all modloader files will be needed).
Please feel free to post any errors you find, questions and concerns. I will check back from time to time. I hope this helps a lot.
For those of you looking to create custom sounds for your mobs, while I can't explain the process, I can tell you how to add them to your mob.
replace "mob" with the name of the folder your sounds are in, and after the period comes the name of the sound. if you have a couple different sounds for each thing, just name them the same with 2, 3, 4, etc. the folder path should be .minecraft/resources/mod/sound/yourfolder.this code makes your mod dependent on audiomod.
Alright, so you've created your mob, but now your world is flooded with these things. Well, here's what you do.
Somewhere in your EntityYourmob file, add this little chunk of code
public boolean getCanSpawnHere()
{
if(worldObj.countEntities(this.getClass()) >= 15){
return false;
}
int i = MathHelper.floor_double(posX);
int j = MathHelper.floor_double(boundingBox.minY);
int k = MathHelper.floor_double(posZ);
int l = worldObj.getBlockId(i, j - 1, k);
return worldObj.checkIfAABBIsClear(boundingBox) && worldObj.getCollidingBoundingBoxes(this, boundingBox).size() == 0 && worldObj.getBlockLightValue(i, j, k) > 8 && !worldObj.getIsAnyLiquid(boundingBox);
}
Change the 15 in the first line to whatever you would like, and that will effectively regulate how many of your mobs can exist in your world at once. 15's a pretty good number to me though. Also if you are having a problem with your mobs not being spread out enough, try implementing this code
public int getMaxSpawnedInChunk()
{
return 1;
}
Again obviously change that number to whatever you want(as long as it's less than the max amount of entities that can exist...). I'm pretty sure you can figure out what that code does and it can go pretty much anywhere, just make sure you don't put it inside another code... Lol.
Rollback Post to RevisionRollBack
GENERATION 25: The first time you see this, copy it into your sig on any forum and add 1 to the generation.
replace "mob" with the name of the folder your sounds are in, and after the period comes the name of the sound. if you have a couple different sounds for each thing, just name them the same with 2, 3, 4, etc. that should work. anyways the folder path should be .minecraft/resources/mod/sound/yourfolder.
Rollback Post to RevisionRollBack
GENERATION 25: The first time you see this, copy it into your sig on any forum and add 1 to the generation.
Is there a way to add multiple mobs to the same mod_name file? I was going to copy the same mob code in the file, but looking at sources of other mods(such as mo creatures) it didn't seem like the thing to do, so thought i'd ask here, also, great tutorial, works perfectly :biggrin.gif:
To have multiple mobs run through the same mod_ file, simply replicate this code:
Yay, got everything of mine working, only problem is I'm not sure what Entity attributes work or not. EntityZombie has attackStrength but the compiler says there's no such string when I put it in my mob. I also don't know how to make the mob passive aggressive rather than passive OR aggressive.
This also isn't working right.
public boolean getCanSpawnHere()
{
if(worldObj.countEntities(this.getClass()) >= 1){
return false;
}
int i = MathHelper.floor_double(posX);
int j = MathHelper.floor_double(boundingBox.minY);
int k = MathHelper.floor_double(posZ);
int l = worldObj.getBlockId(i, j - 1, k);
return worldObj.checkIfAABBIsClear(boundingBox) && worldObj.getCollidingBoundingBoxes(this, boundingBox).size() == 0 && worldObj.getBlockLightValue(i, j, k) > 8 && !worldObj.getIsAnyLiquid(boundingBox);
}
Fantastic guide! I've been having trouble with the older guide and this is exactly what I needed! Would there be any way of giving me a hint on how to create custom behaviours for the NPC?
Thanks for the guide and all your help!
- PROWNE
Rollback Post to RevisionRollBack
While I may be inactive, you can check up on what I'm doing on my website Gamer's Den.
Also is there a way to make the mob drops specific numbers of items, being either 1 specific item every death or more than 1 type of item every death or even randomly drop either a certain item or another certain item.
Yay, got everything of mine working, only problem is I'm not sure what Entity attributes work or not. EntityZombie has attackStrength but the compiler says there's no such string when I put it in my mob. I also don't know how to make the mob passive aggressive rather than passive OR aggressive.
This also isn't working right.
public boolean getCanSpawnHere()
{
if(worldObj.countEntities(this.getClass()) >= 1){
return false;
}
int i = MathHelper.floor_double(posX);
int j = MathHelper.floor_double(boundingBox.minY);
int k = MathHelper.floor_double(posZ);
int l = worldObj.getBlockId(i, j - 1, k);
return worldObj.checkIfAABBIsClear(boundingBox) && worldObj.getCollidingBoundingBoxes(this, boundingBox).size() == 0 && worldObj.getBlockLightValue(i, j, k) > 8 && !worldObj.getIsAnyLiquid(boundingBox);
}
I have it set to 1, I've run into a group of 4-5.
Where are you putting that code, maybe post your source so I can better help you, because I know without a doubt that that code works. The attackStrength thing is most likely due to what your mob extends. If it extends EntityCreature attackStrength will not work, you will need to find a way to replicate it(I would look at EntityMobs and see how attackStrength is declared, and implemented.) As for passive agressive, once you get the attackStrength worked out have a look at zombie pigman's code, and perhaps the spiders code(during daytime) for some hints. I copied a lot of the code for my mob from other mods, so I can't release that code to you with a clear conscience lol.
Rollback Post to RevisionRollBack
GENERATION 25: The first time you see this, copy it into your sig on any forum and add 1 to the generation.
Fantastic guide! I've been having trouble with the older guide and this is exactly what I needed! Would there be any way of giving me a hint on how to create custom behaviours for the NPC?
Thanks for the guide and all your help!
- PROWNE
Honestly the best way to do it is trial and error, try looking at the codes of all the other mobs that are already in the game, and figuring out what code makes each one do something unique. Other than that no I can't really help you, I'm actually not even close to pro at this lol. I just remember how to do things I've already done quite well. Lol.
Rollback Post to RevisionRollBack
GENERATION 25: The first time you see this, copy it into your sig on any forum and add 1 to the generation.
Here's the coding so far, this is the one that still gives me groups of 2 of the mob here and there, which should only be spawning 1.
package net.minecraft.src;
public class EntitySenku extends EntityMobs
{
public EntitySenku(World world)
{
super(world);
//This is the texture for your mob
texture = "/mob/senku.png";
moveSpeed = 1.0F;
attackStrength = 6;
health = 20;
isImmuneToFire = true;
}
protected Entity findPlayerToAttack()
{
float f = getEntityBrightness(15.0F);
if(f < 0.5F)
{
double d = 16D;
return worldObj.getClosestPlayerToEntity(this, d);
} else
{
return null;
}
}
protected int getDropItemId()
{
// Replace with custom sword when it's created
return Item.swordGold.shiftedIndex;
}
public boolean getCanSpawnHere()
{
if(worldObj.countEntities(this.getClass()) > 1)
{
return false;
}
int i = MathHelper.floor_double(posX);
int j = MathHelper.floor_double(boundingBox.minY);
int k = MathHelper.floor_double(posZ);
int l = worldObj.getBlockId(i, j - 1, k);
return worldObj.checkIfAABBIsClear(boundingBox) && worldObj.getCollidingBoundingBoxes(this, boundingBox).size() == 0 && worldObj.getBlockLightValue(i, j, k) > 8 && !worldObj.getIsAnyLiquid(boundingBox);
}
public ItemStack getHeldItem()
{
return defaultHeldItem;
}
private static final ItemStack defaultHeldItem;
static // Replace with custom sword when it's created
{
defaultHeldItem = new ItemStack(Item.swordGold, 1);
}
}
I don't fully trust the spider attack code since it goes by lighting, but at least it currently attacks me in sunlight if I smack it, though sometimes it stops attacking me too as well as when I buried it in dirt it attacked me when I unburied it. Still need it to ALWAYS drop 1 of the getDropItem.
Is there a way to add multiple mobs to the same mod_name file? I was going to copy the same mob code in the file, but looking at sources of other mods(such as mo creatures) it didn't seem like the thing to do, so thought i'd ask here, also, great tutorial, works perfectly :biggrin.gif:
<Snip>
Thanks! Worked perfectly :biggrin.gif: However, at night, the mobs which are like the pigs, sheep and so on seem to mass spawn, (I need to add the limit code yet) however, is there a way to stop this from happening? They literally roam the place frightening creepers :tongue.gif:
Adding the limit code is the only way I can think to do this. Also if you would like limit their spawns AND spread them out a bit, add this code somewhere too
public int getMaxSpawnedInChunk()
{
return 1;
}
that can go anywhere(not under the getCanSpawnHere code) and it's pretty self explanatory what that does.
Rollback Post to RevisionRollBack
GENERATION 25: The first time you see this, copy it into your sig on any forum and add 1 to the generation.
Note: It looks as though spawnlist was merged with Modloader, so there is no longer a need to use it. For people updating mods, please remove it from the src folder before recompiling. The only change you should need to make is to remove the bit about spawnlist in the mod_file and replace it with
I am creating this guide as more of an update to this guide: viewtopic.php?f=25&t=102487 by Club559. I have his permission to recreate this guide.
As his guide says, you need Modloader and Spawnlist. You will also need Minecraft Coder Pack.
Modloader: viewtopic.php?f=25&t=80246&hilit
MCP: http://mcp.ocean-labs.de/index.php/MCP_Releases
You will also be using his tutorial files(I really see no reason to reupload the same files), and a clean minecraft.jar.
Once you have these five things, here is what you do:
1. Add all of the contents of Modloader to your minecraft.jar
2.SKIP THIS STEP Add spawnlist.class to your minecraft.jar.
3. Add your entire bin folder to the jars folder in MCP.
4. Run decompile.bat.
5. Open the sources folder in MCP. Open all subfolders, and eventually src.
6. Copy the files from the sources for mcp folder of your tutorial folder(excluding Basemod, spawnlist, and Modloader)into the src folder in MCP.
7. Open EntityPigman.java(from the src folder of MCP) with any java editing program.(I use Netbeans).
8. Replace Pigman with the name of your mob(you can call it whatever you want, as long as it is the same everywhere, and code is ALWAYS case sensitive.)Also replace mymob.png with the name of your mob.(Make sure this is the same as the filename of your mob skin. for example: If your mod is called mod_Vaultboy, you would probably want to call your picture Vaultboy.png(it has to be a .png file btw) and so you would write Vaultboy.png where mymob.png is written.) If you would like your mob to drop something other than pork, check Item.java for a list of item ID's. If you want it to drop a block replace with this
9. Save it.(If using Netbeans, DO NOT Save As to rename it, as this will not save as a .java file. Idk if all java editors are like this. Instead, Save, and close. Rename it externally.)
10. Open mod_Pigman.java(from the src folder of MCP).
11. This time you need to change a bit more code. In fact, you will be replacing all of it. Copy this code
Now, of course, replace Pigman with the name of your mob. If you would like to change where you mob spawns, open up spawnlist.java(from src in MCP) for a list of different biomes, and replace Surface biomes(In this file, not spawnlist.java) with what you want.
12.Save this file. Rename it externally.
13.Run recompile.bat.(Found in the MCP folder).
14.If recompile.bat did not return any errors, skip step 14.b.
14.b)If recompile.bat did return an error, make sure to go through both of your mod's files and check for spelling and capitalization errors, and make sure you followed these steps exactly.
15.Open the conf folder, and open clientobfuscation.txt.
16.Erase what is written there, and write the names of your mod files, one per line. Ex: If your file is called mod_Pigman.java, you would write mod_Pigman
17.Save.
18.Run reobf.bat.(If there is an error here chances are you have a spelling error in clientobfuscation.txt.)
19.This is important. Running test.bat will not work because you do not have all of the modloader files, so you have to take the files from your final_out/minecraft folder, and put them directly into your minecraft.jar(the one in your .minecraft/bin folder). If you are uncomfortable with testing this mod on your world, create a new one to test it out(having single player commands really helps test this). I am 99% sure this can not wreck a save, but play it safe if you are worried.
20.Put your mob skin into the mob folder of your minecraft.jar.
21.Enjoy your mod.
*NOTE: You do not need to compile Entitylist, modloader, basemod or spawnlist. You only need to compile mod_Yourmob and EntityYourmob. You will still need the latest spawnlist and modloader to run your mod(all modloader files will be needed).
Please feel free to post any errors you find, questions and concerns. I will check back from time to time. I hope this helps a lot.
For those of you looking to create custom sounds for your mobs, while I can't explain the process, I can tell you how to add them to your mob.
put this in EntityYourmob
replace "mob" with the name of the folder your sounds are in, and after the period comes the name of the sound. if you have a couple different sounds for each thing, just name them the same with 2, 3, 4, etc. the folder path should be .minecraft/resources/mod/sound/yourfolder.this code makes your mod dependent on audiomod.
Alright, so you've created your mob, but now your world is flooded with these things. Well, here's what you do.
Somewhere in your EntityYourmob file, add this little chunk of code Change the 15 in the first line to whatever you would like, and that will effectively regulate how many of your mobs can exist in your world at once. 15's a pretty good number to me though. Also if you are having a problem with your mobs not being spread out enough, try implementing this code
Again obviously change that number to whatever you want(as long as it's less than the max amount of entities that can exist...). I'm pretty sure you can figure out what that code does and it can go pretty much anywhere, just make sure you don't put it inside another code... Lol.
YES
YES
YOU ARE THE BEST. It fixed all of the problems I was having trying to get this to work. Thank you a ton!
:smile.gif: Glad I could help.
Yes and I will add it to the OP at some point. put this in EntityYourmob
replace "mob" with the name of the folder your sounds are in, and after the period comes the name of the sound. if you have a couple different sounds for each thing, just name them the same with 2, 3, 4, etc. that should work. anyways the folder path should be .minecraft/resources/mod/sound/yourfolder.
And suddenly a barrage of pointless mobs descended upon my world.
You're awesome. Again, thank you.
To have multiple mobs run through the same mod_ file, simply replicate this code:
and this code
replacing the names as needed.
ex:
This also isn't working right.
I have it set to 1, I've run into a group of 4-5.
Thanks for the guide and all your help!
- PROWNE
1 question though how do i set its spawn rate and how to i set it passive-aggresive?
You can set the spawn rate by copying and pasting the code miztakay put in the OP:
Just put this in the "Entity[MobName].java" file.
(Change the 15 to however many you want, if you want just one change the entire line to
Also is there a way to make the mob drops specific numbers of items, being either 1 specific item every death or more than 1 type of item every death or even randomly drop either a certain item or another certain item.
Where are you putting that code, maybe post your source so I can better help you, because I know without a doubt that that code works. The attackStrength thing is most likely due to what your mob extends. If it extends EntityCreature attackStrength will not work, you will need to find a way to replicate it(I would look at EntityMobs and see how attackStrength is declared, and implemented.) As for passive agressive, once you get the attackStrength worked out have a look at zombie pigman's code, and perhaps the spiders code(during daytime) for some hints. I copied a lot of the code for my mob from other mods, so I can't release that code to you with a clear conscience lol.
Honestly the best way to do it is trial and error, try looking at the codes of all the other mobs that are already in the game, and figuring out what code makes each one do something unique. Other than that no I can't really help you, I'm actually not even close to pro at this lol. I just remember how to do things I've already done quite well. Lol.
but how do i set it to when you attack it it attacks you
also how do i set its damage
I don't fully trust the spider attack code since it goes by lighting, but at least it currently attacks me in sunlight if I smack it, though sometimes it stops attacking me too as well as when I buried it in dirt it attacked me when I unburied it. Still need it to ALWAYS drop 1 of the getDropItem.
Adding the limit code is the only way I can think to do this. Also if you would like limit their spawns AND spread them out a bit, add this code somewhere too
that can go anywhere(not under the getCanSpawnHere code) and it's pretty self explanatory what that does.