In this tutorial I will show you how to make the Block file that you will need to add a basic Block to minecraft. This is the code in the mod file from the last tutorial.
In this tutorial all you don’t have to do anything in the mod file. Just click on the package of this mod or hover your mouse over the BlockTutorialBlock error and create a class with that name.
When you create the file it will probably look like this.
The first thing that you will have to do is make BlockTutorialBlock extend Block. Do this by adding this to the file.
When you do this you will get an error under BlockTutorialBlock. To fix this you will have to add this method.
public BlockTutorialBlock(int id, Material par2Material)
You need to make sure that the method is public FileName and that it contains 1 integer and 1 Material inside of the brackets. You can change the names of those 2 variables into anything you want, but the names they have right now are their functions.
The line inside of the method with super tells the Block file what the id of the block is. It also tells Block which kind of material it is made out of. In this case the material is rock. Making it minable by certain items, but not with others. Material can also add some other interesting properties like making it impossible to be moved by a piston, but that doesn’t count for cloth. To find out all the materials go to the Material file.
Another line that you might want to add is on which creative tab in the creative menu it should be shown. To do this you have to add this line inside of the method.
CreativeTabs is the file that contains all the tabs from the creative inventory and tabBlock is the one you start out in when you open up the inventory on creative mode.
The whole file should now look like this.
You can download the source code over here.
In the next tutorials I will show you how to add some special settings to a block like being able to walk through it etc.