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/06/14 01:02] – more highlighting draylar | tutorial:blocks [2020/06/14 08:31] – dryfix fudge | ||
---|---|---|---|
Line 11: | Line 11: | ||
/* Declare and initialize our custom block instance. | /* Declare and initialize our custom block instance. | ||
- | We set out 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. |
| | ||
*/ | */ | ||
Line 30: | Line 30: | ||
public class ExampleMod implements ModInitializer { | public class ExampleMod implements ModInitializer { | ||
- | /* Declare and initialize our custom block instance. | ||
- | 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).hardness(4.0f)); | public static final Block EXAMPLE_BLOCK = new Block(FabricBlockSettings.of(Material.METAL).hardness(4.0f)); | ||
| | ||
Line 91: | Line 87: | ||
</ | </ | ||
- | The block model file defines the shape and texture of your block. Our model will parent | + | The block model file defines the shape and texture of your block. Our model will have '' |
<code JavaScript src/ | <code JavaScript src/ | ||
Line 102: | Line 98: | ||
</ | </ | ||
- | In most cases, you will want the block to look the same in item form. You can make an item model that parents | + | In most cases, you will want the block to look the same in item form. You can make an item model that has the block model file as a parent, which makes it appear exactly like the block: |
<code JavaScript src/ | <code JavaScript src/ | ||
Line 163: | Line 159: | ||
@Override | @Override | ||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { | public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { | ||
- | if(!world.isClient) { | + | if (!world.isClient) { |
player.sendMessage(new LiteralText(" | player.sendMessage(new LiteralText(" | ||
} | } | ||
Line 177: | Line 173: | ||
public class ExampleMod implements ModInitializer { | public class ExampleMod implements ModInitializer { | ||
- | /* Declare and initialize our custom block instance using our new ExampleBlock class. | ||
- | 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)); | public static final ExampleBlock EXAMPLE_BLOCK = new ExampleBlock(Block.Settings.of(Material.STONE).hardness(4.0f)); | ||
| | ||
Line 197: | Line 189: | ||
{{: | {{: | ||
- | To fix this, we have to define the //VoxelShape// of the new block: | + | To fix this, we have to define the '' |
< | < |
tutorial/blocks.txt · Last modified: 2023/11/18 08:34 by solidblock