O'Reilly logo

Minecraft Modding with Forge by Arun Gupta, Aditya Gupta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. New Block

Have you ever wanted to add a new block to the game? Most modders want to. Whether it’s because the regular blocks are too mundane, or you have a great idea for a new block, making a new block is fun, and there are a lot of features that you can customize. This chapter will explain how to create a new block and will have an ender theme. However, you can make tons of other kinds of blocks, such as stairs or teleporters, and variations like those will be explained here.

The new block that we will create will be called an Enderium Block, but you can change the name if you change the block. For example, if you change the block to be glass stairs, you would rename the block Glass Stairs.

This mod will be a bit different from all the other ones so far, because it does not use event handlers. Instead, it uses a new class to store all of the block’s details, and then registers it to the game registry. Making a new block also allows for a lot of customization, so a few variations of the block will be shown as well.

Creating the Block Class

The first thing you will need is a new class that stores all of the block’s information, like the hardness, resistance, and creative tab. Make a new class called EnderBlock in your package. The first thing you need to do is make the class extend from Block. This means EnderBlock becomes a child class, and Block is the parent class. Block is a Java class in Minecraft that enables any Java class to look and act like a block.

Replace ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required