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 ...

Get Minecraft Modding with Forge now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.