This one is only for a biped model (player model and like a zombie), ill do a custom modeled mob soon!
This custom mob wont do anything special besides attack the player...
For this tut im using this picture for the mob: https://www.dropbox....5nz5xm6/MOB.png
First lets start with the entity!
Make a class called EntityYOURMOB
First extends "EntityMob"
Then add your constructor:
public EntityYOURMOB(World par1World) { super(par1World); }
Now add the size (the hitbox) and the AI's (to make them do something) into your constructor
public EntityYOURMOB(World par1World) { super(par1World); this.setSize(1.5F, 2.0F); this.tasks.addTask(1, new EntityAISwimming(this)); this.tasks.addTask(4, new EntityAIAttackOnCollide(this, 1.0D, false)); this.tasks.addTask(5, new EntityAIWander(this, 0.8D)); this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(6, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true)); this.targetTasks.addTask(2, new EntityAIHurtByTarget(this, false)); }
This will give it sounds and activate your AI code... If you followed my tut for the custom sounds, then this is where you can use it
@Override protected String getLivingSound() { return Sound.YOURSOUND; } @Override protected String getHurtSound() { return Sound.YOURSOUND; } @Override protected String getDeathSound() { return Sound.YOURSOUND; } @Override protected boolean isAIEnabled() { return true; }
And if you didnt want to use custom sounds and just want to use vanilla sounds, this is for a zombie for eg:
@Override protected String getLivingSound() { return "mob.zombie.say"; } @Override protected String getHurtSound() { return "mob.zombie.hurt"; } @Override protected String getDeathSound() { return "mob.zombie.death"; }
Now for the health/strength ect, You change those to be what you want,
@Override protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(THE HEALTH.0D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.53000000417232513D); //Recomended speed this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(ATTACKDAMAGE.0D); this.getEntityAttribute(SharedMonsterAttributes.followRange).setAttribute(AMOUNT OF BLOCKS THAT IT FOLLOWS YOU.0D); }
Time to add the drop that it drops apon death! The example is a diamond...
@Override protected int getDropItemId() { return Item.diamond.blockID; }
This will check if it is spawning where it is dark enough!
@Override protected boolean isValidLightLevel() { return true; }
Now time for the render!
The render is pretty strait forward..
Because we are doing a biped mob (that looks like steve aka the player) we will extends "RenderBiped"
public class RenderYOURMOB extends RenderBiped{
Now add the constructor!:
public RenderYOURMOB(ModelBiped var1, float shadow) { super(var1, shadow); }
As you can see, it will ask for a ModelBiped when you register it later on...
And now, the basic render callback:
public void renderYOURMOB(EntityYOURMOB var1, double var2, double var4, double var6, float var8, float var9) { super.doRenderLiving(var1, var2, var4, var6, var8, var9); } public void doRenderLiving(EntityLiving var1, double var2, double var4, double var6, float var8, float var9) { this.renderYOURMOB((EntityYOURMOB)var1, var2, var4, var6, var8, var9); } public void doYOURMOB(Entity var1, double var2, double var4, double var6, float var8, float var9) { this.renderYOURMOB((EntityYOURMOB)var1, var2, var4, var6, var8, var9); }
Now to add the texture:
@Override protected ResourceLocation getEntityTexture(Entity entity) { return texture; }
Add this above your constructor:
public static ResourceLocation texture = new ResourceLocation("MODID" + ":" + "textures/mobs/MOB.png");
That will get the texture from: "assets/modid/textures/mobs/MOB.png"
Now time to register your entity!
Add this into your PreInit method into your main class (basemod class)
EntityRegistry.registerModEntity(EntityYOURMOB.class, "YOURMOBSNAME", 5, this, 10, 10, true); RenderingRegistry.registerEntityRenderingHandler(EntityYOURMOB.class, new RenderYOURMOB(new ModelBiped(), 0.4F)); LanguageRegistry.instance().addStringLocalization("entity." + "YOURMOBSNAME" + ".name", "Your Mobs Actual Name");
The LanguageRegistry will add the mobs name, The EntityRegistry will register you entity, and lastly we have the RenderingRegistry...
That binds your Entity with your Render, that will make sure you get the mob you want..
Make the mob spawn!
To make a mob spawn, In you 'preInit' Method, Type: "EntityRegistry.addSpawn"
You will get something like this:
EntityRegistry.addSpawn(entityClass, weightedProb, min, max, typeOfCreature, biomes);
The "entityClass" Means You will need to add the EntityClass.class meaning, for this tutorial its going to be "EntityYOURMOB.class"
The "weightedProb" means how many groups will spawn in each chunk.. (Chunk meaning 16 * 16 blocks)
so lets just say 3 groups will spawn in the chunk.
the "min/max" means how many minimum and how many maximum in a group, so if i say "1, 3" It would randomize between 1 - 3 in a group (the maximum in the group could be three or it could just be one or two of your mob spawning in the group)
The "typeOfCreature" will determine if it will spawn during the night/day so because we are making a monster mob i would put "EnumCreatureType.monster" if you want it to be spawning during the day, just put "EnumCreatureType.creature"
And lastly, the "biomes", So if you want it to spawn in any biome, just go "BiomeGenBase." And pick a biome, if you want it to spawn in more than one biome, just put for example:
"BiomeGenBase.plains, BiomeGenBase.desert"
You can add more biomes by just putting in a commar after you did the last biome..
So in the final code it should look something like this:
EntityRegistry.addSpawn(EntityYOURMOB.class, 3, 1, 3, EnumCreatureType.monster, BiomeGenBase.plains, BiomeGenBase.desert);
So hopefully you should have you mob spawn in the night in the "plains" and the "desert" biome!
Im pretty sure thats it, if anyone has any questions or and suggestions for the next tutorial, ill be glad to help in any way that i can
1
1
1
1
1
1
You should add the pictures to your original post though.
Also; Your font on your original post is too big its blocking some text lol.
1
2
Edit: People won't click if there isn't pictures. + I will make a banner sig for your mod if you have pictures.
1
1