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 [2023/05/04 11:31] solidblocktutorial:blockappearance [2024/08/26 08:28] (current) solidblock
Line 1: Line 1:
 ====== Manipulating a Block's appearance ====== ====== Manipulating a Block's appearance ======
  
-//This is the 1.15+ (1.16, 1.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)]].//+//This is the 1.15+ 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 or translucent ===== 
-You may have noticed that even if your block's texture is transparent, it still looks opaque. +You may have noticed that even if your block's texture is transparent or translucent, it still looks opaque. 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]]: In a [[documentation:entrypoint|client-sided mod initializer]]:
  
 <yarncode java> <yarncode java>
-@Environment(EnvType.CLIENT_+@Environment(EnvType.CLIENT)
 public class ExampleModClient implements ClientModInitializer() { public class ExampleModClient implements ClientModInitializer() {
     public void onInitializeClient() {     public void onInitializeClient() {
-         BlockRenderLayerMap.INSTANCE.putBlock(ExampleMod.MY_BLOCK, class_1921.method_23581()); +        // To make some parts of the block transparent (like glass, saplings and doors): 
-         // Replace `class_1921.method_23581()` with `class_1921.method_23583()` if you have a translucent texture.+        BlockRenderLayerMap.INSTANCE.putBlock(TutorialBlocks.MY_BLOCK, class_1921.method_23581()); 
 +         
 +        // To make some parts of the block translucent (like ice, stained glass and portal) 
 +        BlockRenderLayerMap.INSTANCE.putBlock(TutorialBlocks.MY_BLOCK, class_1921.method_23583());
     }     }
 } }
 </yarncode> </yarncode>
  
-You probably also want to make your block transparent. To do that, use the ''<yarn method_22488>'' method on your block settings.+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.
  
 <yarncode java> <yarncode java>
-     public static final Block MY_BLOCK = new Block(FabricBlockSettings.of(...).method_22488());+     public static final Block MY_BLOCK = new Block(AbstractBlock.Settings.create().method_22488());
 </yarncode> </yarncode>
  
 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. You can do this like so: +Be sure to add your client entrypoint to [[documentation:fabric_mod_json|fabric.mod.json]]. You can do this like so: 
- +<code javascript> 
-<code json>+
 +  [...]
   "entrypoints": {   "entrypoints": {
     "main": [     "main": [
-      "mod.fabricmc.examplemod.ExampleMod"+      "net.fabricmc.example.ExampleMod"
     ],     ],
     "client": [     "client": [
-      "mod.fabricmc.examplemod.ExampleModClient"+      "net.fabricmc.example.ExampleModClient"
     ]     ]
   },   },
 +  [...]
 +}
 </code> </code>
  
Line 53: Line 58:
 </yarncode> </yarncode>
  
-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>'':+We may also 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.1683199875.txt.gz · Last modified: 2023/05/04 11:31 by solidblock