tutorial:blocks
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
tutorial:blocks [2024/04/15 01:37] – [Creating a Block] update solidblock | tutorial:blocks [2024/04/15 01:45] – [Registering an Item for your Block] solidblock | ||
---|---|---|---|
Line 43: | Line 43: | ||
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)); | + | |
- | public static final Block EXAMPLE_BLOCK = new Block(FabricBlockSettings.create().strength(4.0f)); | + | |
+ | | ||
+ | | ||
+ | // For versions since 1.20.5: | ||
+ | public static final Block EXAMPLE_BLOCK = new Block(Block.Settings.create().strength(4.0f)); | ||
| | ||
@Override | @Override | ||
Line 62: | Line 66: | ||
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)); | + | |
- | public static final Block EXAMPLE_BLOCK | + | |
+ | | ||
+ | | ||
+ | // For versions since 1.20.5: | ||
+ | public static final Block EXAMPLE_BLOCK = new Block(Block.Settings.create().strength(4.0f)); | ||
| | ||
@Override | @Override | ||
public void onInitialize() { | public void onInitialize() { | ||
Registry.register(Registries.BLOCK, | Registry.register(Registries.BLOCK, | ||
- | Registry.register(Registries.ITEM, | + | |
+ | // Registry.register(Registries.ITEM, | ||
+ | // For versions since 1.20.5: | ||
+ | Registry.register(Registries.ITEM, | ||
} | } | ||
} | } | ||
Line 170: | Line 181: | ||
</ | </ | ||
- | For the harvest level tags ('' | + | For the harvest level tags ('' |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
- | | + | public static final Block EXAMPLE_BLOCK = new ExampleBlock(Block.Settings.create().strength(4.0f).requiresTool()); |
- | public static final Block EXAMPLE_BLOCK = new ExampleBlock(FabricBlockSettings.create().strength(4.0f).requiresTool()); | + | |
</ | </ | ||
Line 199: | Line 209: | ||
} | } | ||
+ | // For versions below 1.20.5, the parameters should be " | ||
@Override | @Override | ||
- | public ActionResult onUse(BlockState state, | + | public ActionResult onUse(World world, PlayerEntity player, BlockHitResult hit) { |
if (!world.isClient) { | if (!world.isClient) { | ||
player.sendMessage(Text.literal(" | player.sendMessage(Text.literal(" |
tutorial/blocks.txt · Last modified: 2024/04/15 01:52 by solidblock