3

modding tutorial 5: mobs

3 diamonds

Get Embed Code

Forum:
HTML:
Link:
avatar waterskier
Level 49 : Master Pony
Posted 05/12/12 10:16:27 pm
05/12/12
Hey everyone I have another tutorial for you. In this one I will teach you how to make a new mob.

In this one we need 2 classes
mod_waterskier.class
waterskier.class
mod_waterskier
of course we need make it extend basemod
then like always we need load, and getversion
but in this one we need to add 2 lines in load
ModLoader.registerEntityID(waterskier.class, "waterskier", ModLoader.getUniqueEntityId());
                ModLoader.addSpawn(waterskier.class, 12, 14, 18, EnumCreatureType.creature);
what this is saying is that we are registering a new entity and its called waterskier. 
and also it needs to get a new entity id so it doesn't take one that has already been used.
then it will add spawning for it 12,14,18 says how much it spawns you can play around with this but put them in increasing order for example this wouldn't work 3,2,1
the we are saying that it is non-hostile, if you want it hostile replace the creature with monster
IMPORTANT PLEASE READ
you NEED to put waterskier.class not just waterskier

after you finish that put 
public void addRenderer(Map map)
        {
                map.put(waterskier.class, new RenderBiped(new ModelBiped(), 0.5F));
        }
after this your mod_waterskier is done and should look like this
mod_waterskier finished
package net.minecraft.src;

import java.util.Map;

public class mod_waterskier extends BaseMod
{
        
        public void load()
        {       
                ModLoader.registerEntityID(waterskier.class, "waterskier", ModLoader.getUniqueEntityId());
                ModLoader.addSpawn(waterskier.class, 12, 14, 18, EnumCreatureType.monster);
        }
        
        public void addRenderer(Map map)
        {
                map.put(waterskier.class, new RenderBiped(new ModelBiped(), 0.5F));
        }
        
        public String getVersion()
        {
                return "1.2.5";
        }

}
waterskier.class
in this class we need it to extend EntityMob to be hostile, and EntityCreature to be peacful
then we need this method and everything there is self explanitory exept attack strength.
Take attack strength out if you want a peacful mob
public waterskier(World world)
        {
                super(world);
                texture = "/waterskier.png";
                moveSpeed = 0.5F;
        attackStrength = 4;
        }
then we need all of these. Also self explanitory. If you don't understand any of it comment on witch one
        public int getMaxHealth()
        {
                return 20;
        }

        protected String getLivingSound()
        {
                return "mob.villager.default";
        }

        protected String getHurtSound()
        {
                return "mob.villager.defaulthurt";
        }

        protected String getDeathSound()
        {
                return "mob.villager.defaultdeath";
        }

        protected int getDropItemId()
        {
                return Item.pickaxeDiamond.shiftedIndex;
        }
        
        protected boolean canDespawn()
        {
                return false;
        }

}
after that you are done with your waterskier.class, here is what it should look like
waterskier finished
package net.minecraft.src;

import java.util.Random;

public class waterskier extends EntityCreature
{
        public waterskier(World world)
        {
                super(world);
                texture = "/waterskier.png";
                moveSpeed = 0.5F;
        attackStrength = 4; //take this line out if this class doesn't extend EntityMob.
        }

        public int getMaxHealth()
        {
                return 20;
        }

        protected String getLivingSound()
        {
                return "mob.villager.default";
        }

        protected String getHurtSound()
        {
                return "mob.villager.defaulthurt";
        }

        protected String getDeathSound()
        {
                return "mob.villager.defaultdeath";
        }

        protected int getDropItemId()
        {
                return Item.pickaxeDiamond.shiftedIndex;
        }
        
        protected boolean canDespawn()
        {
                return false;
        }

}
thanks for reading! Leave any error code in the comments along with suggestions for future tutorials,and as always diamond and subscribe!

Additional Details

Tags:Tutorial

More Blogs by waterskierView All

2012-06-08 04:12:52
by waterskier

Join us to post comments.

Comments : 26

1 - 26 of 26

Sellotaper
Level 40
Master Skinner
September 26, 2012, 3:43 am

Help... It says: "Cannot find server 5mds !!"
when i do reobfuscate...

How do you do it i did all of the classes should i do anithing else befor reobfuscate? Please answer quick. Thanks, by the way epic tut. diamond for you.

mathiasrocker
Level 10
Journeyman Architect
July 22, 2012, 8:21 am

i get errors when i maked this

public void addRenderer(Map map)

{

map.put(waterskier.class, new RenderBiped(new ModelBiped(), 0.5F));

}

 

can someone tell me it's it right????

 

this is the mod_ file

waterskier
Level 49
Master Pony
July 23, 2012, 5:33 pm

what line? it may be that 
1 you didn't change waterskier on that to your mobs name.
2 you havent made the other class for your mob yet (errors will be resolved when you make it.
3 possibly an error that I just didn't see, what line is the error on?

iCraftedYou
Level 37
Artisan Bunny
June 2, 2012, 1:49 am

where can I find the .class of a wolf, i can only find the .java but i don't know what to do with the .java

waterskier
Level 49
Master Pony
June 2, 2012, 10:52 am

it should be .java

iCraftedYou
Level 37
Artisan Bunny
June 2, 2012, 1:25 am

How do you make the texture of the mob? 

waterskier
Level 49
Master Pony
June 2, 2012, 1:34 am

download mcskin3d to edit skins. Then just use that skin for the texture; make sure the name is right!!!

iCraftedYou
Level 37
Artisan Bunny
June 2, 2012, 1:43 am

thanx :)

waterskier
Level 49
Master Pony
June 2, 2012, 1:47 am

sure, these tutorials will continue on my youtube channel, so subscribe to it if you want to see more
http://www.youtube.com/user/waterskier420?feature=guide

felixmc
Level 69
High Grandmaster Programmer
May 19, 2012, 9:07 pm

I was wondering how to make a mob use the pig model? I'm trying to make a new type of pig

sed11
Forum Moderator
Level 57
Grandmaster Creeper
May 16, 2012, 6:47 pm

I can't get my mob to use the endermen sounds....whenver I hit them in-game it doesn't make a noise....


*The hurt sound is mob.endermen.scream1. Did I write it wrong?I also got audio mod.....*

waterskier
Level 49
Master Pony
May 16, 2012, 7:49 pm

check the enderman classes to find their sound, I don't think it's mob.enderman.scream1
and you would only need adiomod if you were going to use custom sounds

sed11
Forum Moderator
Level 57
Grandmaster Creeper
May 16, 2012, 8:44 pm

Oh.

I got audio mod because I post a thread about it and someone thought I need a sound mod enabler.
OK I'll try..

waterskier
Level 49
Master Pony
May 16, 2012, 8:44 pm

can you do me a favor? it wont take more than a minute

waterskier
Level 49
Master Pony
May 16, 2012, 8:54 pm

sed11
Forum Moderator
Level 57
Grandmaster Creeper
May 16, 2012, 8:53 pm

Ok.

And the sounds are working now

waterskier
Level 49
Master Pony
May 16, 2012, 8:54 pm

thanks dude

sed11
Forum Moderator
Level 57
Grandmaster Creeper
May 16, 2012, 8:58 pm

K flagged it.

sed11
Forum Moderator
Level 57
Grandmaster Creeper
May 16, 2012, 5:37 pm

How rare would a monster be if its spawn rate was 2, 5, 7?

waterskier
Level 49
Master Pony
May 16, 2012, 5:43 pm

about average

Sellotaper
Level 40
Master Skinner
May 15, 2012, 7:46 am

Where does one put the
mob texture, in wich folder?

Fraggles
Level 14
Journeyman Mountaineer
May 13, 2012, 10:06 pm

Thanks for doing this one, and quick questions how fast does a wolf run and how fast can Steve sprint?

waterskier
Level 49
Master Pony
May 13, 2012, 10:13 pm

I'm not sure look for the EntityWolf class and it should have it there. And again im not sure about how fast steve can sprint, It's prbly somewhere around 1F.

felixmc
Level 69
High Grandmaster Programmer
May 12, 2012, 10:09 pm

Wait, where is the entity ID?

waterskier
Level 49
Master Pony
May 12, 2012, 10:46 pm

this line makes it avoid figuring out an untaken entity id
ModLoader.getUniqueEntityId());

this is a cool thing modloader has where it looks at all entity id's and chooses one that hasn't been taken yet

1 - 26 of 26