tutorial:blocks
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:blocks [2020/06/14 00:57] – fix header sizes draylar | tutorial:blocks [2020/06/14 01:00] – fix highlighting + more comments draylar | ||
---|---|---|---|
Line 27: | Line 27: | ||
Blocks should be registered under the '' | Blocks should be registered under the '' | ||
- | <code java [enable_line_numbers=" | + | <code java [enable_line_numbers=" |
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=" | + | <code java [enable_line_numbers=" |
public class ExampleMod implements ModInitializer { | public class ExampleMod implements ModInitializer { | ||
- | // an instance of our new block | + | /* Declare and initialize |
+ | We set out block material to METAL, which requires a pickaxe to efficiently break. | ||
+ | | ||
+ | */ | ||
public static final Block EXAMPLE_BLOCK = new Block(FabricBlockSettings.of(Material.METAL)); | public static final Block EXAMPLE_BLOCK = new Block(FabricBlockSettings.of(Material.METAL)); | ||
| | ||
Line 174: | Line 177: | ||
public class ExampleMod implements ModInitializer { | public class ExampleMod implements ModInitializer { | ||
- | // an instance | + | /* Declare and initialize our custom block instance |
- | public static final ExampleBlock EXAMPLE_BLOCK = new ExampleBlock(Block.Settings.of(Material.STONE)); | + | We set out block material to METAL, which requires a pickaxe to efficiently break. |
+ | | ||
+ | */ | ||
+ | public static final ExampleBlock EXAMPLE_BLOCK = new ExampleBlock(Block.Settings.of(Material.STONE).hardness(4.0f)); | ||
| | ||
@Override | @Override |
tutorial/blocks.txt · Last modified: 2024/04/15 01:52 by solidblock