Alright, this is my first tutorial, so bear with me. What I'm going to be showing you in this tutorial is how to design (model) a mob and add the necessary code to have it as an actual animal in the world. Note that I will not be teaching you how to script AI for mobs, sufficient code examples can be found in other tutorials. In this tutorial, I will be showing you how to make a tiger.
Requirements:
Java experience (other modding experience is fine too.)
ModLoader Techne (for modelling, a great thanks to ZeuX and r4wk for this tool.)
Patience!
Steps:
First of all, you're going to want to create a "mod_*insert mod name here*" file. This will make your mob ModLoader compatible, which we all know is a necessity these days. For the tiger, I'm going to create our "mod_Tiger.java" class like so:
package net.minecraft.src;
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode
import java.util.*;
import java.util.Map;
public class mod_Tiger extends BaseMod
{
public mod_Tiger()
{
ModLoader.RegisterEntityID(EntityTiger.class, "Tiger", ModLoader.getUniqueEntityId()); // this registers the mob's ID, making it spawnable in-game
ModLoader.AddSpawn(EntityTiger.class, 2, EnumCreatureType.creature); // this adds the mob to the list of "to-spawn" mobs. The "2" is the rarity of the mob. The EnumCreatureType is what kind of mob it is. For example, squids are "waterCreature", enemies are "monster", and animals are "creature".
}
// RENDERERS
public void AddRenderer(Map map)
{
map.put(EntityTiger.class, new RenderTiger(new ModelTiger(), 0.5F)); // this assigns the Entity class to the appropriate renderer and model class.
}
public String Version()
{
return "| PROWNE's Tiger Mob Tutorial Test File for Beta 1.4_01!"; // you can put whatever you want here, it will show up in ModLoader logs.
}
}
Appropriate notes and tips will be found in the code examples.
Next, we'll create our entity class. This entity class will control what texture is used for the mob, sounds, AI, drops, and any other actions you want it to perform.
EntityTiger.java:
package net.minecraft.src;
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode
public class EntityTiger extends EntityAnimals
{
public EntityTiger(World world)
{
super(world);
texture = "/mob/tiger.png"; // this initializes the texture used for the mob.
setSize(1.5F, 1.9F); // this sets the HIT AREA of the mob.
}
public void writeEntityToNBT(NBTTagCompound nbttagcompound)
{
super.writeEntityToNBT(nbttagcompound); // this saves the mob to disk, so it can be loaded later
}
public void readEntityFromNBT(NBTTagCompound nbttagcompound)
{
super.readEntityFromNBT(nbttagcompound); // this retrieves saved data about the mob from the hard drive
}
protected String getLivingSound()
{
return null; // any sound your mob makes will be set here. Look in other Entity classes to see what code it uses.
}
protected String getHurtSound()
{
return null;
}
protected String getDeathSound()
{
return null;
}
protected float getSoundVolume()
{
return 0.4F;
}
protected int getDropItemId()
{
return 0; // this is the drop item ID for your mob. For example, set this to "return 278;" to drop a diamond pickaxe upon dying.
}
}
Now, we're going to set up the model and renderer classes. These are the last two needed for our new mob.
ModelTiger.java:
package net.minecraft.src;
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode
public class ModelTiger extends ModelQuadraped
{
public ModelTiger()
{
super(12, 0.0F); // since this class EXTENDS ModelQuadraped, it will automatically animate parts like the head and legs. All this code you see below was made using Techne, when you export your model using Techne, you will have to copy and paste that code here.
body = new ModelRenderer(0, 0); // this sets up the ModelRender part. The "0, 0" is the texture index (top left corner) where the part will start overlaying this texture onto itself
body.addBox(-5F, -4F, -7F, 10, 8, 15); // these set up offset, size, and scale. Rotation points in Techne are what's considered the center of the part, so try keeping the blue circles in the very center of the part (unless setting the rotation point inside another, like a neck or head)
body.setPosition(0F, 10F, -7); // this moves the part (from the rotation point) into the desired placement.
leg1 = new ModelRenderer(0, 0);
leg1.addBox(0F, 0F, 0F, 4, 8, 3);
leg1.setPosition(1F, 14F, -2);
leg2 = new ModelRenderer(0, 0);
leg2.addBox(0F, 0F, 0F, 4, 8, 3);
leg2.setPosition(-5F, 14F, -2);
leg3 = new ModelRenderer(0, 0);
leg3.addBox(0F, 0F, 0F, 4, 8, 3);
leg3.setPosition(1F, 14F, -13);
leg4 = new ModelRenderer(0, 0);
leg4.addBox(0F, 0F, 0F, 4, 8, 3);
leg4.setPosition(-5F, 14F, -13);
neck = new ModelRenderer(0, 0);
neck.addBox(0F, 0F, 0F, 4, 3, 3);
neck.setPosition(-2F, 3F, -13);
head = new ModelRenderer(0, 0);
head.addBox(-3F, -2F, -2F, 6, 5, 4);
head.setPosition(0F, 2F, -12);
nose = new ModelRenderer(0, 0);
nose.addBox(-1F, -1F, -2F, 2, 2, 4);
nose.setPosition(0F, 3F, -14);
ear1 = new ModelRenderer(0, 0);
ear1.addBox(0F, 0F, 0F, 2, 2, 1);
ear1.setPosition(-3F, -2F, -13);
ear2 = new ModelRenderer(0, 0);
ear2.addBox(0F, 0F, 0F, 2, 2, 1);
ear2.setPosition(1F, -2F, -13);
tail = new ModelRenderer(0, 0);
tail.addBox(-1F, 0F, 4F, 2, 1, 8);
tail.setPosition(0F, 7F, -4);
}
public void render(float f, float f1, float f2, float f3, float f4, float f5)
{
super.render(f, f1, f2, f3, f4, f5);
tail.render(f5); // whenever adding a part that ISN'T included in the EXTENDED class, you'll have to add the variable for that part down below, and also add one of these lines to have the model "draw" your new part. Without it, your part will not show up at runtime.
ear1.render(f5);
ear2.render(f5);
neck.render(f5);
nose.render(f5);
}
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5)
{
super.setRotationAngles(f, f1, f2, f3, f4, f5); // this calls the EXTENDED setRotationAngles function, it is used to animate the legs and head.
}
ModelRenderer tail; // add any new parts here that aren't initialized by the EXTENDED class
ModelRenderer ear1;
ModelRenderer ear2;
ModelRenderer neck;
ModelRenderer nose;
}
And finally, RenderTiger.java:
package net.minecraft.src;
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode
public class RenderTiger extends RenderLiving
{
public RenderTiger(ModelBase modelbase, float f)
{
super(modelbase, f); // try not to modify anything here, except the referenced class names, for example, "EntityTiger".
}
public void func_177_a(EntityTiger entitytiger, double d, double d1, double d2,
float f, float f1)
{
super.doRenderLiving(entitytiger, d, d1, d2, f, f1);
}
public void doRenderLiving(EntityLiving entityliving, double d, double d1, double d2,
float f, float f1)
{
func_177_a((EntityTiger)entityliving, d, d1, d2, f, f1);
}
public void doRender(Entity entity, double d, double d1, double d2,
float f, float f1)
{
func_177_a((EntityTiger)entity, d, d1, d2, f, f1);
}
}
Again, Techne is your friend. It is a great tool which I highly recommend. Feel free to copy these code examples and play around with them, though you will need to supply your own textures (or use existing ones). If you have any questions, feel free to ask.
- 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.
Texture mapping can be extremely hard. Techne used to have a feature where it showed you (in real time) where the texture was and gave you the ability to move it around, but ZeuX removed this for some reason. Honestly, the only real way is to make 6 sides (as if you're making and folding in a paper cube), then set the texture offset (found in the ModelRenderer(*x*, *y*); function. You have to set the X and Y to correspond with the top left corner of your part inside that texture. For example, because the default human head starts at the very first coordinates (0, 0) they are kept the same. It is confusing, but it's possible.
Rollback Post to RevisionRollBack
While I may be inactive, you can check up on what I'm doing on my website Gamer's Den.
This is helpful! I needed soemthing like this, I will give more input when I actually figure this all out, I've only kinda like read this, not actually tried anything...
Rollback Post to RevisionRollBack
Making a video game mod for minecraft. Going great. The idea? blocks when clicked open up a minigame that rewards you with ores and such based on your ingame score. Almost finished with beta version, which features a very basic pong game.
I may make an actual video on designing a mob with Techne, but not now. @Creepertird157, no, I will not help you make a Yeti. I have in the past split a model into two parts, so that I was able to make much bigger mobs with more intricate skins. Each "half" of the model was assigned it's own texture, depending on the ModelRenderer that was calling for it.
Rollback Post to RevisionRollBack
While I may be inactive, you can check up on what I'm doing on my website Gamer's Den.
The Meaning of Life, the Universe, and Everything.
Join Date:
2/27/2011
Posts:
57
Minecraft:
Appleman8977
Member Details
Where can i find the creature on the map. Has any of the code even covered that yet? if not then pleasse make that your next tutorial i want to see the thing i'm making. if you did than where is it? [] [] []
You totally should make a vid, and I'd make you a banner for this mod too if you did(It wouldn't be amazing pixle arty stuff, but it'd work well)... Except should be like a 3 part thing or something, and you should be more all inclusive...
Rollback Post to RevisionRollBack
Making a video game mod for minecraft. Going great. The idea? blocks when clicked open up a minigame that rewards you with ores and such based on your ingame score. Almost finished with beta version, which features a very basic pong game.
Yes and also, can you angle something with techne? And lastly, how do you know what your texture png should look? Like what shape... How do you know that? Because I"m WAY confused on textures, and as far as what the texture png should look like... I'm lost there... Need explanation...
Whats the difference between position and offset? Can't find one...
Rollback Post to RevisionRollBack
Making a video game mod for minecraft. Going great. The idea? blocks when clicked open up a minigame that rewards you with ores and such based on your ingame score. Almost finished with beta version, which features a very basic pong game.
Yes and also, can you angle something with techne? And lastly, how do you know what your texture png should look? Like what shape... How do you know that? Because I"m WAY confused on textures, and as far as what the texture png should look like... I'm lost there... Need explanation...
Whats the difference between position and offset? Can't find one...
Angles: must be set in your model class. Look in ModelQuadraped for the appropriate code.
Textures: those depend on how many boxes and the shape and size of them. You'll have to do some playing around to find the spot for each box.
Position: moves the blue sphere around.
Offset: moves the box around the blue sphere.
Rollback Post to RevisionRollBack
While I may be inactive, you can check up on what I'm doing on my website Gamer's Den.
Um okay... Is there a difference in the effect of offset and position?
Also, what is the rarity scale. You said the 2 is how rare it is, but would making it 5 make it rarer, or more common?
Rollback Post to RevisionRollBack
Making a video game mod for minecraft. Going great. The idea? blocks when clicked open up a minigame that rewards you with ores and such based on your ingame score. Almost finished with beta version, which features a very basic pong game.
Um okay... Is there a difference in the effect of offset and position?
Also, what is the rarity scale. You said the 2 is how rare it is, but would making it 5 make it rarer, or more common?
Basically what the blue sphere does is that it sets where the box rotates it around. This is useful when you're animating legs, arms, etc. Offset is used to ensure your box is in the right position whilst still orientated around the rotation point. The rarity scale exactly what you said. 20 (I think) is what sheep are set to, while 4 is what wolves are set to. I may be wrong, but that's what I've heard.
Rollback Post to RevisionRollBack
While I may be inactive, you can check up on what I'm doing on my website Gamer's Den.
Can you make an advanced tutorial link, that links to a post in this thread that explains:
-Rotation
-Other Animation stuff
-Rarity type stuff
-Everything else you can do with mobs
Rollback Post to RevisionRollBack
Making a video game mod for minecraft. Going great. The idea? blocks when clicked open up a minigame that rewards you with ores and such based on your ingame score. Almost finished with beta version, which features a very basic pong game.
Question: In Techne, a "block" equal what in the game? 10 Techne blocks = 1 Minecraft block? Something like that?
According to DrZhark, "1" in Techne (or Minecraft code) is equal to 1 pixel. So if each Minecraft block is 16 pixels cubed, I'm pretty sure you get it.
Quote from Appleman8977 »
Where can i find the creature on the map. Has any of the code even covered that yet? if not then pleasse make that your next tutorial i want to see the thing i'm making. if you did than where is it? [] [] []
If you mean "where can/will my mob spawn" instead of "on the map", that's determined by what class your Entity extends. You can also override that extended method by copying, pasting, and modifying it in your main Entity class.
Rollback Post to RevisionRollBack
While I may be inactive, you can check up on what I'm doing on my website Gamer's Den.
I think he just couldn't find any tigers... That would be because this mob is 2 x as rare as wolfs if you just copy and pasted his code.
Also, so if I set this as a water mob, would that mean it automatically has swimming programing and all? And maybe in the advanced tutorial I suggested you could explain how to customize our mob's movements/ect.
Rollback Post to RevisionRollBack
Making a video game mod for minecraft. Going great. The idea? blocks when clicked open up a minigame that rewards you with ores and such based on your ingame score. Almost finished with beta version, which features a very basic pong game.
I think he just couldn't find any tigers... That would be because this mob is 2 x as rare as wolfs if you just copy and pasted his code.
Also, so if I set this as a water mob, would that mean it automatically has swimming programing and all? And maybe in the advanced tutorial I suggested you could explain how to customize our mob's movements/ect.
Alright. As for the water mobs, setting them to "waterCreature" enables them to only move in water, and if they aren't they would be "beached" and unable to move.
Rollback Post to RevisionRollBack
While I may be inactive, you can check up on what I'm doing on my website Gamer's Den.
Allright... So would they automatically swim and crap? How would I customize it's movment(so it like always stay at the same level in water, unless it comes close to the waters edge, so it turns around..., and custumize it's animation so it's fins go up and down)... That is what I think your advance tutorial should be about.
Thanks for mak'n this, it's been a huge help, I've already made models for all these:
whale
Giant octopus
clam
turtle
(working on a) awesome boat that is much bigger.
I haven't programed most of those yet, but whale should be done first, then clam, then turtle, then boat, then giant octopus.
I'm making all this for my multi dimensions mod, for the world aquatica.
Rollback Post to RevisionRollBack
Making a video game mod for minecraft. Going great. The idea? blocks when clicked open up a minigame that rewards you with ores and such based on your ingame score. Almost finished with beta version, which features a very basic pong game.
There is a line of code you can use to make models bigger, the game actually has a HUGE giant programmed into the game, although, it's probably just a zombie, with out the attack code, and programed to be much bigger.
Rollback Post to RevisionRollBack
Making a video game mod for minecraft. Going great. The idea? blocks when clicked open up a minigame that rewards you with ores and such based on your ingame score. Almost finished with beta version, which features a very basic pong game.
There is a line of code you can use to make models bigger, the game actually has a HUGE giant programmed into the game, although, it's probably just a zombie, with out the attack code, and programed to be much bigger.
Yes. In the "addBox()" line, the very last variable is the scale of the model (0 being the default). If you increase that to 1, your model will be twice as large. Warning that increasing the scale can often make entities look fat and puffy, if you don't add spacing between each box when designing the model.
Quote from Hinaloth »
Okay, so my model being 100px tall would have made it a freaking giant. Thanks for the info.
Also, would you mind explaining the animations codes. What are the rules to follow in the .java classe, in the naming of parts of the model, all that?
If you extend the ModelQuadraped (which is used for pigs and cows) you'd name all four of your legs to be leg1, leg2, leg3, leg4, and the head just "head". You can also copy and paste the setRotationAngles code from the ModelQuadraped and just rename it, change some of the floating points, and paste it into your model class. I was fooling around with the tiger and made its tail swing back and forth, depending on how fast it's moving.
Rollback Post to RevisionRollBack
While I may be inactive, you can check up on what I'm doing on my website Gamer's Den.
Requirements:
Java experience (other modding experience is fine too.)
ModLoader
Techne (for modelling, a great thanks to ZeuX and r4wk for this tool.)
Patience!
Steps:
First of all, you're going to want to create a "mod_*insert mod name here*" file. This will make your mob ModLoader compatible, which we all know is a necessity these days. For the tiger, I'm going to create our "mod_Tiger.java" class like so:
Appropriate notes and tips will be found in the code examples.
Next, we'll create our entity class. This entity class will control what texture is used for the mob, sounds, AI, drops, and any other actions you want it to perform.
EntityTiger.java:
Now, we're going to set up the model and renderer classes. These are the last two needed for our new mob.
ModelTiger.java:
And finally, RenderTiger.java:
Again, Techne is your friend. It is a great tool which I highly recommend. Feel free to copy these code examples and play around with them, though you will need to supply your own textures (or use existing ones). If you have any questions, feel free to ask.
- PROWNE
plz help, it could make for a good tut.If you make a tut on this, please tell me( email at [email protected])
Whats the difference between position and offset? Can't find one...
Angles: must be set in your model class. Look in ModelQuadraped for the appropriate code.
Textures: those depend on how many boxes and the shape and size of them. You'll have to do some playing around to find the spot for each box.
Position: moves the blue sphere around.
Offset: moves the box around the blue sphere.
Also, what is the rarity scale. You said the 2 is how rare it is, but would making it 5 make it rarer, or more common?
Basically what the blue sphere does is that it sets where the box rotates it around. This is useful when you're animating legs, arms, etc. Offset is used to ensure your box is in the right position whilst still orientated around the rotation point. The rarity scale exactly what you said. 20 (I think) is what sheep are set to, while 4 is what wolves are set to. I may be wrong, but that's what I've heard.
Can you make an advanced tutorial link, that links to a post in this thread that explains:
-Rotation
-Other Animation stuff
-Rarity type stuff
-Everything else you can do with mobs
According to DrZhark, "1" in Techne (or Minecraft code) is equal to 1 pixel. So if each Minecraft block is 16 pixels cubed, I'm pretty sure you get it.
If you mean "where can/will my mob spawn" instead of "on the map", that's determined by what class your Entity extends. You can also override that extended method by copying, pasting, and modifying it in your main Entity class.
Also, so if I set this as a water mob, would that mean it automatically has swimming programing and all? And maybe in the advanced tutorial I suggested you could explain how to customize our mob's movements/ect.
Alright. As for the water mobs, setting them to "waterCreature" enables them to only move in water, and if they aren't they would be "beached" and unable to move.
Thanks for mak'n this, it's been a huge help, I've already made models for all these:
whale
Giant octopus
clam
turtle
(working on a) awesome boat that is much bigger.
I haven't programed most of those yet, but whale should be done first, then clam, then turtle, then boat, then giant octopus.
I'm making all this for my multi dimensions mod, for the world aquatica.
Yes. In the "addBox()" line, the very last variable is the scale of the model (0 being the default). If you increase that to 1, your model will be twice as large. Warning that increasing the scale can often make entities look fat and puffy, if you don't add spacing between each box when designing the model.
If you extend the ModelQuadraped (which is used for pigs and cows) you'd name all four of your legs to be leg1, leg2, leg3, leg4, and the head just "head". You can also copy and paste the setRotationAngles code from the ModelQuadraped and just rename it, change some of the floating points, and paste it into your model class. I was fooling around with the tiger and made its tail swing back and forth, depending on how fast it's moving.