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 [2022/08/14 04:00] – Use Yarn code blocks haykamtutorial:blockappearance [2022/12/16 02:21] solidblock
Line 7: Line 7:
 To fix this, you need to set your block's render layer to cutout or transparent. To fix this, you need to set your block's render layer to cutout or transparent.
  
-In a [[documentation:entrypoint|client-sided mod initializer]], add:+In a [[documentation:entrypoint|client-sided mod initializer]]:
  
 <yarncode java> <yarncode java>
-BlockRenderLayerMap.INSTANCE.putBlock(ExampleMod.MY_BLOCK, class_1921.method_23581()); +public class ExampleModClient implements ClientModInitializer() { 
-// Replace `class_1921.method_23581()` with `class_1921.method_23583()` if you have a translucent texture.+    public void onInitializeClient() { 
 +         BlockRenderLayerMap.INSTANCE.putBlock(ExampleMod.MY_BLOCK, class_1921.method_23581()); 
 +         // Replace `class_1921.method_23581()` with `class_1921.method_23583()` if you have a translucent texture. 
 +    } 
 +}
 </yarncode> </yarncode>
  
Line 17: Line 21:
  
 <yarncode java> <yarncode java>
-class MyBlock extends class_2248 { +     public static final Block MY_BLOCK = new Block(FabricBlockSettings.of(...).method_22488());
-    public MyBlock() { +
-        super(class_2251.of(class_3614.field_15914).method_22488()); +
-    } +
- +
-    [...] +
-}+
 </yarncode> </yarncode>
  
Line 41: Line 39:
 </code> </code>
  
-Note: For non-transparent blocks that are not full, you may have to override the ''getOutlineShape'' method to return a non-full shape to avoid seeing through the world.+Note: For non-transparent blocks that are not full, you may have to override the ''<yarn method_9530>'' method to return a non-full shape to avoid seeing through the world.
  
 ===== Making a block invisible ===== ===== Making a block invisible =====
  
-First we need to make the block appear invisible. To do this, we override ''getRenderType'' in our block class and return ''BlockRenderType.INVISIBLE'':+First we need to make the block appear invisible. To do this, we override ''<yarn method_9604>'' in our block class and return ''<yarn class_2464>.<yarn field_11455>'':
  
 <yarncode java> <yarncode java>
Line 54: Line 52:
 </yarncode> </yarncode>
  
-We then need to make our block unselectable by making its outline shape be non-existent. So override ''getOutlineShape'' and return an empty ''VoxelShape'':+We then need to make our block unselectable by making its outline shape be non-existent. So override ''<yarn method_9530>'' and return an empty ''<yarn class_265>'':
  
 <yarncode java> <yarncode java>
tutorial/blockappearance.txt · Last modified: 2024/02/05 16:03 by haykam