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
Next revisionBoth sides next revision
tutorial:blocks [2020/06/14 00:58] – copy comments to bottom code block draylartutorial:blocks [2020/06/14 01:00] – fix highlighting + more comments draylar
Line 27: Line 27:
 Blocks should be registered under the ''Block.REGISTRY'' registry. Call //Registry.register// and pass in the appropriate arguments. Blocks should be registered under the ''Block.REGISTRY'' registry. Call //Registry.register// and pass in the appropriate arguments.
  
-<code java [enable_line_numbers="true",highlight_lines_extra="8"]>+<code java [enable_line_numbers="true",highlight_lines_extra="11"]>
 public class ExampleMod implements ModInitializer { public class ExampleMod implements ModInitializer {
  
Line 49: Line 49:
 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 Registry.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 Registry.ITEM. The registry name of the item should usually be the same as the registry name of the block.
  
-<code java [enable_line_numbers="true",highlight_lines_extra="9"]>+<code java [enable_line_numbers="true",highlight_lines_extra="12"]>
 public class ExampleMod implements ModInitializer { public class ExampleMod implements ModInitializer {
  
-    // an instance of our new block+    /* Declare and initialize our custom block instance. 
 +       We set out block material to METAL, which requires a pickaxe to efficiently break. 
 +       Hardness represents how long the break takes to break. Stone has a hardness of 1.5f, while Obsidian has a hardness of 50.0f. 
 +    */
     public static final Block EXAMPLE_BLOCK = new Block(FabricBlockSettings.of(Material.METAL));     public static final Block EXAMPLE_BLOCK = new Block(FabricBlockSettings.of(Material.METAL));
          
tutorial/blocks.txt · Last modified: 2024/04/15 01:52 by solidblock