Wuppy’s Minecraft Forge Modding Tutorials for 1.7: Updating 1.6 to 1.7 Part 3: Blocks

In this tutorial I will show you how to update your Block code from 1.6 to 1.7. The file we will start with looks as follows.

There are a lot of things you have to do in this file. First of all, remove both parameters from the constructor. Remove the id from the super and replace material with Material.[the material you want]. This will create an error in this line from the mod file.

Remove both parameters from this line. Also, cut the setBlockName method and paste it as the first line under super in the Block class. The line in the Tutorial class will now look as follows.

Next, add an @Override above every single method you overwrite from Block. In this case, that is every single method. This doesn’t fix any current errors, but will help you fix future ones. Right now the method is overwritten, when the method name changes the code in the method will no longer be used which could break your Block. @Override will tell you when the name doesn’t match by giving you an error. This really helps a lot when updating your code.

Now, replace Icon with IIcon and IconRegister with IIconRegister.

You will now notice an error under registerIcons which can be fixed by removing the @Override method. This means that registerIcons isn’t working anymore, because the name changed. To fix this, change the method name into registerBlockIcons.

Another method with the same error is getSubBlocks. To fix this one, change the first parameter from an int to an Item.

Now, all of the errors in your Block are gone, but the getSubBlocks line has several yellow underlined pieces of code which are warnings. To fix those hover over them and select Add @SurpressWarning annotation to getSubBlocks.

BlockTutorialBlock will now look like this.

Because this is a metadata Block the ItemBlock will have to be updated as well. This is what the one from 1.6 looks like.

The only thing you have to do in here is change the parameter from an int to a Block. I’ve also renamed the variable to block and added @Override annotation which makes the file look like this.

In the next tutorial I will show you how to update Items to 1.7.

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="">