Minecraft 1.15 modding with forge – 5 – Custom basic block

Hello everyone,

Today I’m going to show you how to make a custom block using the new DeferredRegister

For a block to work, have a texture, drop something and have a name the following things need to be done:

  • The block needs to registered
  • The block needs a blockstate json (this to map different variants, like rotation, to a model)
  • The block needs at least 1 model json (can be more if you have multiple variants)
  • The block needs at least 1 texture
  • The block needs to have a loot table json (to make the block drop something)
  • The block needs to have an entry in the lang file

Blocks are registered in almost the same way as items. I’ll put everything block related in a ModBlocks class but you can do it wherever you want.
Create a public static final DeferredRegister variable and call it BLOCKS, initialize it to a new DeferredRegister instance. As a first argument pass it the registry you want to register to, which is ForgeRegistries.BLOCKS in this case. The second argument will be your modid, which I can get using TutorialMod.MOD_ID

public static final DeferredRegister<Block> BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, TutorialMod.MOD_ID);

Now to register a block to this DeferredRegister all you need to do is call BLOCKS.register(registryname, () -> blockinstance);. The registryname has to be all lowercase and can only contain the following characters: a-z 0-9 / . _ –.

Now create a public static final RegistryObject variable, I will name it TUTORIAL_BLOCK and initialize it to the BLOCKS.register call.
To create an instance of the Block class you need to pass in a Block.Properties instance. You can call methods on this instance to set things like the harvestLevel, hardness, etc. To create a Block.Properties instance you need to call Block.Properties#create and pass in a Material.

public static final RegistryObject<Block> TUTORIAL_BLOCK = BLOCKS.register("tutorial_block", () -> new Block(Block.Properties.create(Material.ROCK)));

Now, let’s add the ItemBlock, you do this by instead of instantiating an Item you instantiate the ItemBlock, in here you need to pass in a reference to your block and the Item.Properties you want. For more information go to my previous tutorial about items. To get the reference to your block you should call ModBlocks.TUTORIAL_BLOCK.get().

In the assets/modid/ folder create a new folder called blockstates, in the model and texture folder you also need to create a block folder.
In the textures/block folder, you can add a texture (make sure its size is a power of 2, 16×16, 32×32, etc.). It doesn’t matter what you call it but it has to be lowercase and you have to remember the name. I will call it tutorial_block.png and I will use this texture:
In the models/block folder create a new JSON file, and add the following JSON:

Of course, you need to replace the words in caps with whatever your values are. The texture name should be without the extension. Save this model, and remember the name (make sure the name is lowercase)

In the blockstates folder create a new JSON file. In the JSON file add the following JSON code:

Remember to save it as NAME.json. You have to replace the words in capslock with the corresponding values, NAME should be the same as the block’s registry name.
Your item also needs a specific model so it looks like a block, you do this by creating a file in the models/item and adding the following JSON:

Make sure the file name matches the registry name!

To make your block drop something you have to add a loot table, to do this create a JSON file named REGISTRY_NAME.json in the resources/data/MODID/loot_tables/blocks folder.
Make sure each pool has a unique name or it won’t work! For more information about loot tables check the wiki.

You may have noticed that the name isn’t displaying correctly. In the lang file (assets/modid/lang/en_us.json) add a new entry, like this:

"block.modid.registryname": "Block Name"

Now you can start the game and you should have a block with texture and name, and an item to place it!

Well, that was it for this part! Click here to browse the project for this tutorial!
As always if you have any question don’t hesitate to ask in the comments! Also if you saw any errors in the tutorial please let me know so I can fix it!

~suppergerrie2

Posted in Forge tutorial, Forge Tutorial 1.15.

14 Comments

  1. For some reason it’s not showing up in the Creative Tab, my custom Creative Tab for my mod, and I can’t give it to myself. How do I check why it’s not loading?

    • Is there an error in the log? Did you make sure to register the deferred register in your constructor?

  2. Hey, I’m having a problem with the textures. The item texture is fine and all, but when i place the block it’s textureless. I’ve been trying every thing, but nothing works. I even looked at the documentation for the JSON files.
    Thanks in advance for any help.

  3. Very informative and easy to follow, thanks for the effort.
    One question… what steps are required to have a custom block spawn naturally like iron ore and some of the similar type blocks?

  4. Is there any way to put many RegistryObjects into an Arraylist to register many similar blocks with just a short java-class?

    • You could do something like this:

      public static final RegistryObject[] blocks = new RegistryObject[] {
      BLOCKS.register(“botmanager_block”,
      () -> new Block(… properties …)))
      };
      But that does give you a warning cus unchecked assigments and im not sure how to fix that.

Leave a Reply to Alexander Zetzsche Cancel reply

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