In this tutorial, I am going to show you how you can create your mobs. I'm using Eclipse as my IDE. I will not be teaching you how to model in Techne. There tutorials on how to create a model. Here's one I recommend:
Required
Have a java file exported from Techne ready
Have a texture of your mob ready.
Let's get started.
Step 1: Importing and adjusting model class
We need to import our java file into our workspace. Drag your java file into a package named model in your Package Explorer. Once you have dragged the java file, open it up. There will errors, fix the errors like the name of the class and import the necessary files with Ctrl-Shift-O. If you have any extras parts, extensions of the head, chest etc, example, a helmet make sure the .setRotationPoint are zeros. Example below
tophelmet = new ModelRenderer(this, 32, 0);
tophelmet.addBox(-4F, -9F, -4F, 8, 1, 8);
tophelmet.setRotationPoint(0F, 0F, 0F); // this line
tophelmet.setTextureSize(64, 64);
tophelmet.mirror = true;
setRotation(tophelmet, 0F, 0F, 0F);
Once you have changed those extensions's rotationPoint to zeros, we are going to addChild. AddingChild is where a part's rotation point share the same rotation point as the parent, an example is the head and helmet, the head is the parent while the helmet is the child. The helmet will share the same rotation point as the head AND the rotation point of the parent sets the origin of the child which is WHY it is crucial to change the extensions' rotationPoint to zero. Code below is how you addChild
Once you have done add child, time to move on to the render method. Add entity to the last parameter of setRotationAngles in the render method. Time to create the if-then-else statement.
What this does is that it renders only the parts that are parents. Parts like helmets will not be here as it will render an additional helmet.
Next, override the method setRotationAngles,
This is where you will set the rotation angles of the parent parts. Why I say parent parts is because the child parts will follow the parent's rotation angles. In simple terms, it means the child parts will rotate the same way as the parent, if the head turns left, the helmet will turn left. It will be hard to explain each one so I'm commenting on the code.
I won't be going too much for creating a entity class. This tutorial only shows you how to create your own mobs, not create your own AI etc.
I want my mob to be able to trade like the villagers so I extend EntityVillager. Once you extend you will need to add 2 constructors, EntityJayGarrick(world) and EntityJayGarrick(world, int) and in your EntityJayGarrick(world), call the EntityJayGarrick(world, int). Your code should look something like this.
public class EntityJayGarrick extends EntityVillager
{
public EntityJayGarrick(World world)
{
this(world, 0);
}
public EntityJayGarrick(World world, int professionId)
{
super(world, professionId);
}
}
That's it for the Entity class. As I said earlier, I will not go deep on Entity class, I am just showing you how the basic Entity class will look like. Next rendering and registrations.
Step 3: Rendering and registration
Let's start with the rendering. Create a class which extends RenderLiving.
public class RenderJayGarrick extends RenderLiving<EntityJayGarrick>
{
}
You will receive an error. Not to worry. Create a constructor with RenderManager in it's parameters and type super() in the constructor. In the super parameters, type the argument of RenderManager, create a new object of your Model class and the last parameter will be a float, this float is the shadow size of your entity, so have something like 0.5F. Create a new method called getMainModel()
public ModelJayGarrick getMainModel()
{
}
This method decides which model the render class will load. So return super.getMainModel() with casting the super with the ModelJayGarrick in my case. Then override a method getEntityTexture
This method will give the model the texture. In the beginning of the class, create a private static final ResourceLocation with new ResourceLocation and the directory of the texture in the parameter of new ResourceLocation.
private static final ResourceLocation texture = new ResourceLocation(Reference.MOD_ID + ":textures/entity/jaygarrick.png");
You need to specify textures/folder/name of texture.png if you don't specify "textures", Minecraft will load the texture with the location "assets.modid.entity.jaygarrick.png".
Override a protected void preRenderCallback method
The code in the preRenderCallback varies depending on what your mob will look like (i think) as mine is similar to the villager, I follow the villager's render.
Now for the registration, it's best if you create a class for registering entity and name it RegisterEntities or whatever you want to name it. In the class, create a private static int with 0 assigned to it. Best to label as id
private static int id = 0;
Then, create a public static void method, I will be naming this method register(). This method is where we will register our entity. Then create another public static void method called registerRenders(), this method will be where we register our EntityRenders. In your register() method, call EntityRegistry#registerModEntity, in the registerModEntity, the parameters goes like this, Class<!--? extends Entity--> entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates, int eggPrimary, int eggSecondary, the first param is obviously your Entity class, the second param is name of your entity, the third param is the id, the 4th param is the instance of your main class, the 5th, 6th and 7th params are very important, you find the ints for the entities in the RenderManager, from there, you can choose what the ints will be, the last 2 params are the colours, these will decided how your egg will look like, the eggs can be found in the Miscellaneous creative tab in-game. An example:
The reason why I do 0x5a0000 in the last 2 params is becasue I want to use the rgb code, "5a0000" is the rgb code. To register your renders, you need to call RenderingRegistry#registerEntityRenderingHandler. It's difficult for me to explain the 2nd param, but the 1st param is the Entity class. Best to show.
RenderingRegistry.registerEntityRenderingHandler(EntityJayGarrick.class, new IRenderFactory()
{
@Override
public Render<? super EntityJayGarrick> createRenderFor(RenderManager manager)
{
return new RenderJayGarrick(manager);
}
});
Make sure you call RegisterEntities.register(); in the preInit method of your main mod class and call the RegisterEntities.registerRenders() in the preInit method of your ClientProxy
Okay that's it!
If you got any problems, ask here. I will be creating an FAQ section when there are questions commonly asked in this thread. I hope this tutorial help you people. I think this tutorial will work for 1.8, if not just ask here too! ^^
Thanks for reading this tutorial. If I missed anything out, please tell me in this thread or PMs and I will have it edited! If this tutorial helped, give me a like!
Click here to go to my Git to see the files.
Give me feedback on how I can improve, examples: format of tutorial etc. See ya! Credits
sky_01 - helping to correct my mistakes in my model class
EtsyTheDragon - although it was help on the 3D armor, without him, I would not be able to fix my model class.
In this tutorial, I am going to show you how you can create your mobs. I'm using Eclipse as my IDE. I will not be teaching you how to model in Techne. There tutorials on how to create a model. Here's one I recommend:
Required
Let's get started.
Step 1: Importing and adjusting model class
We need to import our java file into our workspace. Drag your java file into a package named model in your Package Explorer. Once you have dragged the java file, open it up. There will errors, fix the errors like the name of the class and import the necessary files with Ctrl-Shift-O. If you have any extras parts, extensions of the head, chest etc, example, a helmet make sure the .setRotationPoint are zeros. Example below
Once you have changed those extensions's rotationPoint to zeros, we are going to addChild. AddingChild is where a part's rotation point share the same rotation point as the parent, an example is the head and helmet, the head is the parent while the helmet is the child. The helmet will share the same rotation point as the head AND the rotation point of the parent sets the origin of the child which is WHY it is crucial to change the extensions' rotationPoint to zero. Code below is how you addChild
Once you have done add child, time to move on to the render method. Add entity to the last parameter of setRotationAngles in the render method. Time to create the if-then-else statement.
What this does is that it renders only the parts that are parents. Parts like helmets will not be here as it will render an additional helmet.
Next, override the method setRotationAngles,
This is where you will set the rotation angles of the parent parts. Why I say parent parts is because the child parts will follow the parent's rotation angles. In simple terms, it means the child parts will rotate the same way as the parent, if the head turns left, the helmet will turn left. It will be hard to explain each one so I'm commenting on the code.
There we go for the Model class. Next step!
Step 2: Creating Entity class class
I want my mob to be able to trade like the villagers so I extend EntityVillager. Once you extend you will need to add 2 constructors, EntityJayGarrick(world) and EntityJayGarrick(world, int) and in your EntityJayGarrick(world), call the EntityJayGarrick(world, int). Your code should look something like this.
That's it for the Entity class. As I said earlier, I will not go deep on Entity class, I am just showing you how the basic Entity class will look like. Next rendering and registrations.
Step 3: Rendering and registration
You will receive an error. Not to worry. Create a constructor with RenderManager in it's parameters and type super() in the constructor. In the super parameters, type the argument of RenderManager, create a new object of your Model class and the last parameter will be a float, this float is the shadow size of your entity, so have something like 0.5F. Create a new method called getMainModel()
This method decides which model the render class will load. So return super.getMainModel() with casting the super with the ModelJayGarrick in my case. Then override a method getEntityTexture
This method will give the model the texture. In the beginning of the class, create a private static final ResourceLocation with new ResourceLocation and the directory of the texture in the parameter of new ResourceLocation.
You need to specify textures/folder/name of texture.png if you don't specify "textures", Minecraft will load the texture with the location "assets.modid.entity.jaygarrick.png".
Override a protected void preRenderCallback method
The code in the preRenderCallback varies depending on what your mob will look like (i think) as mine is similar to the villager, I follow the villager's render.
Now for the registration, it's best if you create a class for registering entity and name it RegisterEntities or whatever you want to name it. In the class, create a private static int with 0 assigned to it. Best to label as id
Then, create a public static void method, I will be naming this method register(). This method is where we will register our entity. Then create another public static void method called registerRenders(), this method will be where we register our EntityRenders. In your register() method, call EntityRegistry#registerModEntity, in the registerModEntity, the parameters goes like this, Class<!--? extends Entity--> entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates, int eggPrimary, int eggSecondary, the first param is obviously your Entity class, the second param is name of your entity, the third param is the id, the 4th param is the instance of your main class, the 5th, 6th and 7th params are very important, you find the ints for the entities in the RenderManager, from there, you can choose what the ints will be, the last 2 params are the colours, these will decided how your egg will look like, the eggs can be found in the Miscellaneous creative tab in-game. An example:
The reason why I do 0x5a0000 in the last 2 params is becasue I want to use the rgb code, "5a0000" is the rgb code. To register your renders, you need to call RenderingRegistry#registerEntityRenderingHandler. It's difficult for me to explain the 2nd param, but the 1st param is the Entity class. Best to show.
Make sure you call RegisterEntities.register(); in the preInit method of your main mod class and call the RegisterEntities.registerRenders() in the preInit method of your ClientProxy
Okay that's it!
If you got any problems, ask here. I will be creating an FAQ section when there are questions commonly asked in this thread. I hope this tutorial help you people. I think this tutorial will work for 1.8, if not just ask here too! ^^
Thanks for reading this tutorial. If I missed anything out, please tell me in this thread or PMs and I will have it edited! If this tutorial helped, give me a like!
Click here to go to my Git to see the files.
Give me feedback on how I can improve, examples: format of tutorial etc. See ya!
Credits
I will check it out! but i think i will use tabula instead of techne, do you think that will work?
I'm not sure about tabula, but from screenshots of tabula, the controls are similar if not most of the features are the same. Try Techne.