User Tools

Site Tools


tutorial:blocks

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
tutorial:blocks [2025/04/02 01:13] – [Giving your Block Visuals] solidblocktutorial:blocks [2025/12/07 16:13] (current) mcgambingpro
Line 5: Line 5:
 Adding blocks to your mod follows a similar process to [[tutorial:items|adding an item]]. You can create an instance of ''Block'' or a custom class, and then register it under ''Registries.BLOCK'' (for 1.19.3 and above) or ''Registry.BLOCK'' (for 1.19.2 and below). You also need to provide a texture and blockstate/model file to give your block visuals. For more information on the block model format, view the [[https://minecraft.wiki/Model|Minecraft Wiki Model page]]. Adding blocks to your mod follows a similar process to [[tutorial:items|adding an item]]. You can create an instance of ''Block'' or a custom class, and then register it under ''Registries.BLOCK'' (for 1.19.3 and above) or ''Registry.BLOCK'' (for 1.19.2 and below). You also need to provide a texture and blockstate/model file to give your block visuals. For more information on the block model format, view the [[https://minecraft.wiki/Model|Minecraft Wiki Model page]].
  
-===== Creating a Block (before 1.21.2=====+===== Creating a Block before 1.21.2 =====
 :!: If you are using 1.21.2 or later versions, please directly see [[#Registering blocks in 1.21.2+]]. :!: If you are using 1.21.2 or later versions, please directly see [[#Registering blocks in 1.21.2+]].
  
Line 37: Line 37:
 </code> </code>
  
-===== Registering your Block (before 1.21.2=====+===== Registering your Block before 1.21.2 =====
  
 Blocks should be registered under the ''Registries.BLOCK'' registry. Similar to registering [[items]], just call ''Registry.//register//'' and pass in the appropriate arguments. You can either register the block in ''onInitialize'' method or directly when creating the block instance in the static context, as the ''register'' method returns the block instance as well. Blocks should be registered under the ''Registries.BLOCK'' registry. Similar to registering [[items]], just call ''Registry.//register//'' and pass in the appropriate arguments. You can either register the block in ''onInitialize'' method or directly when creating the block instance in the static context, as the ''register'' method returns the block instance as well.
Line 65: Line 65:
 Your custom block will //not// be accessible as an item yet, but it can be seen in-game by using the command ''/setblock <position> tutorial:example_block''. Your custom block will //not// be accessible as an item yet, but it can be seen in-game by using the command ''/setblock <position> tutorial:example_block''.
  
-===== Registering an Item for your Block (before 1.21.2=====+===== Registering an Item for your Block before 1.21.2 =====
  
 In most cases, you want to be able to place your block using an item. To do this, you need to register a corresponding BlockItem in the item registry. You can do this by registering an instance of BlockItem under ''Registries.ITEM''. The registry name of the item should usually be the same as the registry name of the block. In most cases, you want to be able to place your block using an item. To do this, you need to register a corresponding BlockItem in the item registry. You can do this by registering an instance of BlockItem under ''Registries.ITEM''. The registry name of the item should usually be the same as the registry name of the block.
Line 94: Line 94:
 </code> </code>
  
-===== Best practice of registering blocks befor 1.21.2 =====+===== Best practice of registering Blocks before 1.21.2 =====
 :!: This section does not apply to versions 1.21.2 and later. :!: This section does not apply to versions 1.21.2 and later.
  
Line 123: Line 123:
 </code> </code>
  
-===== Registering blocks in 1.21.2+ =====+===== Registering Blocks in 1.21.2+ =====
 In 1.21.2+, ''RegistryKey'' should be added into the ''AbstractBlock.Settings'' for the block, as well as ''Item.Settings'' for the item. It looks troublesome, but luckily, Minecraft's ''Blocks.//register//'' and ''Items.//register//'' helps you do that. In 1.21.2+, ''RegistryKey'' should be added into the ''AbstractBlock.Settings'' for the block, as well as ''Item.Settings'' for the item. It looks troublesome, but luckily, Minecraft's ''Blocks.//register//'' and ''Items.//register//'' helps you do that.
  
tutorial/blocks.txt · Last modified: 2025/12/07 16:13 by mcgambingpro