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 01:02] – more highlighting draylartutorial: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.
        Hardness represents how long the break takes to break. Stone has a hardness of 1.5f, while Obsidian has a hardness of 50.0f.        Hardness represents how long the break takes to break. Stone has a hardness of 1.5f, while Obsidian has a hardness of 50.0f.
     */     */
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. 
-       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).hardness(4.0f));     public static final Block EXAMPLE_BLOCK = new Block(FabricBlockSettings.of(Material.METAL).hardness(4.0f));
          
Line 91: Line 87:
 </code> </code>
  
-The block model file defines the shape and texture of your block. Our model will parent ''block/cube_all'', which applies the texture set as ''all'' to //all// sides of the block.+The block model file defines the shape and texture of your block. Our model will have ''block/cube_all''as a parent, which applies the texture ''all'' to //all// sides of the block.
  
 <code JavaScript src/main/resources/assets/tutorial/models/block/example_block.json> <code JavaScript src/main/resources/assets/tutorial/models/block/example_block.json>
Line 102: Line 98:
 </code> </code>
  
-In most cases, you will want the block to look the same in item form. You can make an item model that parents the block model file, which makes it appear exactly like the block:+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/main/resources/assets/tutorial/models/item/example_block.json> <code JavaScript src/main/resources/assets/tutorial/models/item/example_block.json>
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("Hello, world!"), false);             player.sendMessage(new LiteralText("Hello, world!"), false);
         }         }
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. 
-       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 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:
 {{:tutorial:voxelshape_wrong.png?200|}} {{:tutorial:voxelshape_wrong.png?200|}}
  
-To fix this, we have to define the //VoxelShape// of the new block:+To fix this, we have to define the ''VoxelShape'' of the new block:
  
 <code> <code>
tutorial/blocks.txt · Last modified: 2023/11/18 08:34 by solidblock