tutorial:blocks
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
tutorial:blocks [2020/08/16 17:09] – who tf wrote this section? java 101 when leocth2 | tutorial:blocks [2021/01/30 12:04] – updating to latest mappings and fixing continuity errors leocth2 | ||
---|---|---|---|
Line 11: | Line 11: | ||
/* Declare and initialize our custom block instance. | /* Declare and initialize our custom block instance. | ||
- | We set our block material to METAL, which requires a pickaxe to efficiently break. | + | We set our block material to `METAL`, which requires a pickaxe to efficiently break. |
- | | + | |
+ | | ||
+ | | ||
+ | Stone has a hardness of 1.5f and a resistance of 6.0f, while Obsidian has a hardness of 50.0f and a resistance of 1200.0f. | ||
+ | |||
+ | You can find the stats of all vanilla blocks in the class `Blocks`, where you can also reference other blocks. | ||
*/ | */ | ||
- | public static final Block EXAMPLE_BLOCK = new Block(FabricBlockSettings.of(Material.METAL).hardness(4.0f)); | + | public static final Block EXAMPLE_BLOCK = new Block(FabricBlockSettings.of(Material.METAL).strength(4.0f)); |
| | ||
@Override | @Override | ||
Line 25: | Line 30: | ||
==== Registering your Block ==== | ==== Registering your Block ==== | ||
- | 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 { | ||
- | public static final Block EXAMPLE_BLOCK = new Block(FabricBlockSettings.of(Material.METAL).hardness(4.0f)); | + | public static final Block EXAMPLE_BLOCK = new Block(FabricBlockSettings.of(Material.METAL).strength(4.0f)); |
| | ||
@Override | @Override | ||
Line 48: | Line 53: | ||
public class ExampleMod implements ModInitializer { | public class ExampleMod implements ModInitializer { | ||
- | | + | public static final Block EXAMPLE_BLOCK = new Block(FabricBlockSettings.of(Material.METAL).strength(4.0f)); |
- | We set out block material to METAL, which requires a pickaxe to efficiently break. | + | |
- | | + | |
- | */ | + | |
- | | + | |
| | ||
@Override | @Override | ||
public void onInitialize() { | public void onInitialize() { | ||
Registry.register(Registry.BLOCK, | Registry.register(Registry.BLOCK, | ||
- | Registry.register(Registry.ITEM, | + | Registry.register(Registry.ITEM, |
} | } | ||
} | } |
tutorial/blocks.txt · Last modified: 2023/11/18 08:34 by solidblock