Wuppy’s Minecraft Forge Modding Tutorials for 1.6: Entity Part 1: Registry

In this tutorial series I’m going to show you how to add an Entity to Minecraft. There are quite a lot of different Entity types in Minecraft. There are Tile Entities, projectiles, peaceful mobs, hostile mobs, minecarts etc. In this tutorial series I will show you how to create a hostile mob.

In this tutorial I’m going to show you how to register the Entity we are going to make in another tutorial. To do this you will have to edit your mod file. This is the file I will start with.

There are several lines of code you will have to add to make a proper mob in your mod file.
First of all you have to make the game aware of your Entity. The code you use for that looks like this.

The first parameter in this method is the Entity class you are going to use. We will make this in the next tutorial.
The second parameter is a String which you give to your mob. Make sure that this is a unique one.
The third parameter is an id for the mob. These won’t conflict between mods so you can easily start at one. To make sure they don’t conflict you have the fourth parameter which is the mod file. To get the mod file you can simply use the word this in your mod file.
The fifth parameter is quite important. This is the tracking range of your mob. This will keep your mob loaded at a distance of that amount of blocks. Don’t make this too high or it will really slow down your game. Making it 80 is a pretty common thing to do.
The sixth parameter is the update frequency of the mob. This value also shouldn’t be made too high because it will slow down your game. Unless you make a really complicated mob 3 should be fine.
The final parameter is if the mob should send velocity updates. Simply set this to true for a proper mob.

The next few lines of code are a bit more difficult if you don’t know that much java.

The for loop goes through every possible biome in a list. The if makes sure that the biome for that index isn’t null. If it isn’t it will add the mob spawn to that biome.
The first parameter is again the mob. The second is the spawn frequency. If you make this higher it will spawn more often. The next 2 parameters are about group size. When the mob has been chosen to be spawned it will in this case spawn between 1 and 3 of them. The fifth parameter is the creature type. This makes sure the mob spawns in the right location and the right light level. If you want some special mob you can play around with the different creature types. The final parameter is simply the biome for the index i.
This code works if you want it to spawn in every biome. If you only want it in a few change the last parameter into BiomeGenBase.whateverBiomeYouWant.

There is one more line of code that you will have to add. That line looks like this.

This code is used to make sure that it doesn’t show the first string when you are killed by the mob, but the second one. The second String is simply the name of the mob in game, but the first one is a bit more important. The first bit is entity. then you get the modid. After that you get the exact entity name set in the registry and finally you add .name. If this String is any different from that it will not work.

The whole file should now look like this.

In the next tutorial we will be working on the Entity file.

You can download the source code and the assets folder overĀ here

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">