How to make a new block in a Minecraft mod
A block is registered once in the game’s block registry with its properties, and a block item lets players hold and place it. It also needs a blockstate file, a block model, an item model, a 16x16 texture, a loot table so it drops itself, and an English name.
Works on Minecraft 1.20.1 to 26.3 on NeoForge; Minecraft 1.16.5 to 26.3 on Fabric; Minecraft 1.16.5 to 1.20.1 on Forge; Minecraft 1.12.2 on Forge. Each example was compiled against its loader and version before it shipped in Linen.
- Register the block with its properties in your blocks class.
- Register a block item for it in your items class.
- Add its blockstate, block model and item model, and a 16x16 texture.
- Add a loot table so it drops itself when mined.
- Give it an English name in the lang file (en_us.json, or en_us.lang on 1.12.2).
For each loader and version
Section titled “For each loader and version”The example mod is examplemod in the package com.example.examplemod. Use your own mod id and package.
Fabric 1.16.5 to 26.2
Section titled “Fabric 1.16.5 to 26.2”Uses:
Registry.registerBuiltInRegistries.BLOCKBuiltInRegistries.ITEMBlockBehaviour.Properties.ofBlockItem
NeoForge 1.20.1 to 1.21, Forge 1.17.1 to 1.20.1
Section titled “NeoForge 1.20.1 to 1.21, Forge 1.17.1 to 1.20.1”Uses:
DeferredRegister.createForgeRegistries.BLOCKSForgeRegistries.ITEMSRegistryObjectBlockBehaviour.Properties.of
NeoForge 1.21.1 to 26.3
Section titled “NeoForge 1.21.1 to 26.3”Uses:
DeferredRegister.createBlocksDeferredRegister.Blocks.registerSimpleBlockDeferredRegister.Items.registerSimpleBlockItemDeferredBlockBlockBehaviour.Properties.of
Fabric 26.3
Section titled “Fabric 26.3”Uses:
Registry.registerBuiltInRegistries.BLOCKResourceKey.createBlockBehaviour.Properties.setIdBlockBehaviour.Properties.ofBlockItem
Forge 1.16.5
Section titled “Forge 1.16.5”Uses:
DeferredRegister.createForgeRegistries.BLOCKSRegistryObjectAbstractBlock.Properties.ofBlockItemItem.Properties.tab
Forge 1.12.2
Section titled “Forge 1.12.2”Uses:
RegistryEvent.Register<Block>Block.setRegistryNameBlock.setUnlocalizedNameItemBlockBlock.setCreativeTab
In 1.12.2 a block is registered in a RegistryEvent.Register<Block> handler (event.getRegistry().register(block)) with setRegistryName and setUnlocalizedName; its item is an ItemBlock registered in the item event, and both need a model (blockstate JSON, ModelLoader for the item).
Sources
Section titled “Sources”- https://docs.fabricmc.net/1.21.1/develop/blocks/first-block
- https://docs.neoforged.net/docs/1.21.1/blocks/
- https://docs.neoforged.net/docs/1.21.1/items/
Related how-tos
Section titled “Related how-tos”- A new item
- A block that changes over time with random ticks
- A block that gives off light
- A block with the properties you choose
- A sound of your own
In Linen
Section titled “In Linen”Linen’s How-tos library has this page too, with the example for your own mod’s loader and Minecraft version. Hover a name in your code and Linen points to the how-tos that explain it. Both are free. Download Linen.