User Tools

Site Tools


tutorial:blockappearance

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
tutorial:blockappearance [2020/01/17 13:53] – 1.15 juuztutorial:blockappearance [2020/03/30 17:30] – [Making a block invisible] liach
Line 13: Line 13:
 </code> </code>
  
-You probably also want to make your block transparent. To do that, use the ''Material'' constructor to set ''blocksLight'' to false.+You probably also want to make your block transparent. To do that, use the ''nonOpaque'' method on your block settings.
 <code java> <code java>
 class MyBlock extends Block { class MyBlock extends Block {
-     private static final Material MY_MATERIAL = new Material( 
-            MaterialColor.AIR, // materialColor, 
-            false, // isLiquid, 
-            false, // isSolid, 
-            true, // blocksMovement, 
-            false, // blocksLight,  <----- Important part, the other parts change as you wish 
-            true, // !requiresTool, 
-            false, // burnable, 
-            false, // replaceable, 
-            PistonBehavior.NORMAL // pistonBehavior 
-    ); 
- 
     public MyBlock() {     public MyBlock() {
-        super(Settings.of(MY_MATERIAL));+        super(Settings.of(Material.STONE).nonOpaque());
     }     }
  
Line 51: Line 39:
     @Override     @Override
     public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPos, EntityContext entityContext) {     public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPos, EntityContext entityContext) {
-       return VoxelShapes.empty;+       return VoxelShapes.empty();
     }     }
 </code> </code>
tutorial/blockappearance.txt · Last modified: 2024/02/05 16:03 by haykam