How to make a block with the properties you choose (Minecraft mod)
Everything about how a block behaves in the world lives in its properties, a builder you pass when you register it (BlockBehaviour.Properties; on 1.12.2 these are methods on the block instead): how long it takes to break and how well it withstands explosions, its sound, light, friction, speed and jump factor, whether things walk through it, what pistons do to it and more. Choose any of them here and Make it writes the builder chain.
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.
- Start from the block’s properties builder (BlockBehaviour.Properties.of()).
- Chain the properties you want, for example .strength(3.0F).sound(SoundType.METAL).
- Pass the properties when you register the block.
- If it needs a tool to drop, also add it to a mineable block tag.
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.3
Section titled “Fabric 1.16.5 to 26.3”Uses:
Registry.registerBuiltInRegistries.BLOCKBuiltInRegistries.ITEMBlockBehaviour.Properties.ofBlockItem
It’s registered like any other block: see a new block.
NeoForge 1.20.1 to 26.3, Forge 1.17.1 to 1.20.1
Section titled “NeoForge 1.20.1 to 26.3, Forge 1.17.1 to 1.20.1”Uses:
DeferredRegister.createBlocksDeferredRegister.Blocks.registerSimpleBlockDeferredRegister.Items.registerSimpleBlockItemDeferredBlockBlockBehaviour.Properties.of
It’s registered like any other block: see a new block.
Forge 1.16.5
Section titled “Forge 1.16.5”Uses:
DeferredRegister.createForgeRegistries.BLOCKSRegistryObjectAbstractBlock.Properties.of
It’s registered like any other block: see a new block.
Forge 1.12.2
Section titled “Forge 1.12.2”Uses:
Block.setHardnessBlock.setResistanceBlock.setLightLevelBlock.setSoundTypeMaterial
1.12.2 has no Block.Properties: the settings are methods on the block (setHardness, setResistance, setLightLevel, setSoundType, …), the material is the constructor argument.
It’s registered like any other block: see a new block.
Sources
Section titled “Sources”- https://docs.fabricmc.net/1.21.1/develop/blocks/first-block
- https://docs.neoforged.net/docs/1.21.1/blocks/
Related how-tos
Section titled “Related how-tos”- A block that changes over time with random ticks
- A block that gives off light
- A new block
- A block that can hold water
- A block that faces the player
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.