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/12 13:08] – fix typo juuztutorial:blockappearance [2022/08/14 04:02] – Inline Yarn codes haykam
Line 1: Line 1:
 ====== Manipulating a Block's appearance ====== ====== Manipulating a Block's appearance ======
  
-//This is the 1.15+ (1.16 and 1.17 work fine too) version of this tutorial. For the 1.14 version, see [[tutorial:1.14:blockappearance|Manipulating a Block's appearance (1.14)]].//+//This is the 1.15+ (1.161.17, 1.18, and 1.19 work fine too) version of this tutorial. For the 1.14 version, see [[tutorial:1.14:blockappearance|Manipulating a Block's appearance (1.14)]].//
  
 ===== Making a block transparent ===== ===== Making a block transparent =====
Line 8: Line 8:
  
 In a [[documentation:entrypoint|client-sided mod initializer]], add: In a [[documentation:entrypoint|client-sided mod initializer]], add:
-<code java> 
-BlockRenderLayerMap.INSTANCE.putBlock(ExampleMod.MY_BLOCK, RenderLayer.getCutout()); 
-// Replace `RenderLayer.getCutout()` with `RenderLayer.getTranslucent()` if you have a translucent texture. 
-</code> 
  
-You probably also want to make your block transparent. To do that, use the ''nonOpaque'' method on your block settings. +<yarncode java> 
-<code java> +BlockRenderLayerMap.INSTANCE.putBlock(ExampleMod.MY_BLOCK, class_1921.method_23581()); 
-class MyBlock extends Block {+// Replace `class_1921.method_23581()` with `class_1921.method_23583()` if you have a translucent texture. 
 +</yarncode> 
 + 
 +You probably also want to make your block transparent. To do that, use the ''<yarn method_22488>'' method on your block settings. 
 + 
 +<yarncode java> 
 +class MyBlock extends class_2248 {
     public MyBlock() {     public MyBlock() {
-        super(Settings.of(Material.STONE).nonOpaque());+        super(class_2251.of(class_3614.field_15914).method_22488());
     }     }
  
     [...]     [...]
 } }
- +</yarncode>
-</code>+
  
 If you do not mark your block as non-opaque like this, then block faces behind the block will not render and you will be able to see through the world. If you do not mark your block as non-opaque like this, then block faces behind the block will not render and you will be able to see through the world.
  
-Be sure to add your client entrypoint to fabric.mod.json. +Be sure to add your client entrypoint to fabric.mod.json. You can do this like so:
-You can do this like so: +
-<code json>+
  
 +<code json>
   "entrypoints": {   "entrypoints": {
     "main": [     "main": [
Line 41: Line 41:
 </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 thiswe override ''<yarn method_9604>'' in our block class and return ''<yarn class_2464>.<yarn field_11455>'': 
-<code java>+ 
 +<yarncode java>
     @Override     @Override
-    public BlockRenderType getRenderType(BlockState blockState) { +    public class_2464 method_9604(class_2680 state) { 
-        return BlockRenderType.INVISIBLE;+        return class_2464.field_11455;
     }     }
-</code+</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>'': 
-<code java>+ 
 +<yarncode java>
     @Override     @Override
-    public VoxelShape getOutlineShape(BlockState blockStateBlockView blockView, BlockPos blockPosEntityContext entityContext) { +    public class_265 method_9530(class_2680 stateclass_1922 blockView, class_2338 posclass_3726 context) { 
-       return VoxelShapes.empty();+       return class_259.method_1073();
     }     }
-</code>+</yarncode>
tutorial/blockappearance.txt · Last modified: 2024/02/05 16:03 by haykam