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
tutorial:blockappearance [2024/08/26 08:28] solidblocktutorial:blockappearance [2026/03/05 19:25] (current) – Mojang mappings cassiancc
Line 1: Line 1:
 +~~REDIRECT>https://docs.fabricmc.net/develop/blocks/transparency-and-tinting~~
 ====== Manipulating a Block's appearance ====== ====== Manipulating a Block's appearance ======
  
Line 8: Line 9:
 In a [[documentation:entrypoint|client-sided mod initializer]]: In a [[documentation:entrypoint|client-sided mod initializer]]:
  
-<yarncode java> +//For version 1.21.5 and before:// 
-@Environment(EnvType.CLIENT+<yarncode java ExampleModClient.java> 
-public class ExampleModClient implements ClientModInitializer() {+public class ExampleModClient implements ClientModInitializer { 
 +    public void onInitializeClient() { 
 +        // To make some parts of the block transparent (like glass, saplings and doors): 
 +        BlockRenderLayerMap.INSTANCE.putBlock(TutorialBlocks.MY_BLOCK, RenderLayer.cutout()); 
 +         
 +        // To make some parts of the block translucent (like ice, stained glass and portal) 
 +        BlockRenderLayerMap.INSTANCE.putBlock(TutorialBlocks.MY_BLOCK, RenderLayer.translucent()); 
 +    } 
 +
 +</yarncode> 
 + 
 +//For version 1.21.6 and after: // 
 +<yarncode java ExampleModClient.java> 
 +public class ExampleModClient implements ClientModInitializer {
     public void onInitializeClient() {     public void onInitializeClient() {
         // To make some parts of the block transparent (like glass, saplings and doors):         // To make some parts of the block transparent (like glass, saplings and doors):
-        BlockRenderLayerMap.INSTANCE.putBlock(TutorialBlocks.MY_BLOCK, class_1921.method_23581());+        BlockRenderLayerMap.putBlock(TutorialBlocks.MY_BLOCK, RenderType.CUTOUT);
                  
         // To make some parts of the block translucent (like ice, stained glass and portal)         // To make some parts of the block translucent (like ice, stained glass and portal)
-        BlockRenderLayerMap.INSTANCE.putBlock(TutorialBlocks.MY_BLOCK, class_1921.method_23583());+        BlockRenderLayerMap.putBlock(TutorialBlocks.MY_BLOCK, RenderType.TRANSLUCENT);
     }     }
 } }
 </yarncode> </yarncode>
  
-You probably also want to make your block non-opaque. To do that, use the ''<yarn method_22488>'' method on your block settings. This will also make sides render inside.+You probably also want to make your block non-opaque. To do that, use the ''noOcclusion'' method on your block settings. This will also make sides render inside.
  
 <yarncode java> <yarncode java>
-     public static final Block MY_BLOCK = new Block(AbstractBlock.Settings.create().method_22488());+     public static final Block MY_BLOCK = new Block(BlockBehaviour.Properties.of().noOcclusion());
 </yarncode> </yarncode>
  
Line 53: Line 67:
 <yarncode java> <yarncode java>
     @Override     @Override
-    public class_2464 method_9604(class_2680 state) { +    public RenderShape getRenderShape(BlockState state) { 
-        return class_2464.field_11455;+        return RenderShape.INVISIBLE;
     }     }
 </yarncode> </yarncode>
Line 62: Line 76:
 <yarncode java> <yarncode java>
     @Override     @Override
-    public class_265 method_9530(class_2680 state, class_1922 blockView, class_2338 pos, class_3726 context) { +    public VoxelShape getShape(BlockState state, BlockGetter blockView, BlockPos pos, CollisionContext context) { 
-       return class_259.method_1073();+       return Shapes.empty();
     }     }
 </yarncode> </yarncode>
tutorial/blockappearance.1724660896.txt.gz · Last modified: 2024/08/26 08:28 by solidblock