tutorial:blockappearance
                Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tutorial:blockappearance [2023/11/18 08:39] – [Making a block transparent] update solidblock | tutorial:blockappearance [2025/06/10 16:40] (current) – solidblock | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Manipulating a Block' | ====== Manipulating a Block' | ||
| - | //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: | + | //This is the 1.15+ version of this tutorial. For the 1.14 version, see [[tutorial: | 
| - | ===== Making a block transparent ===== | + | ===== Making a block transparent | 
| - | You may have noticed that even if your block' | + | You may have noticed that even if your block' | 
| - | To fix this, you need to set your block' | + | |
| In a [[documentation: | In a [[documentation: | ||
| - | < | + | //For version 1.21.5 and before:// | 
| - | @Environment(EnvType.CLIENT_ | + | < | 
| - | public class ExampleModClient implements ClientModInitializer() { | + | @Environment(EnvType.CLIENT) | 
| + | public class ExampleModClient implements ClientModInitializer { | ||
| public void onInitializeClient() { | public void onInitializeClient() { | ||
| - | BlockRenderLayerMap.INSTANCE.putBlock(ExampleMod.MY_BLOCK, | + | // To make some parts of the block transparent (like glass, saplings and doors): | 
| - |  | + |  | 
| + | |||
| + |  | ||
| + | BlockRenderLayerMap.INSTANCE.putBlock(TutorialBlocks.MY_BLOCK, RenderLayer.getTranslucent()); | ||
| } | } | ||
| } | } | ||
| </ | </ | ||
| - | You probably also want to make your block transparent. To do that, use the ''< | + | //For version 1.21.6 and after: // | 
| + | < | ||
| + | @Environment(EnvType.CLIENT) | ||
| + | public class ExampleModClient implements ClientModInitializer { | ||
| + | public void onInitializeClient() { | ||
| + | // To make some parts of the block transparent (like glass, saplings and doors): | ||
| + | BlockRenderLayerMap.putBlock(TutorialBlocks.MY_BLOCK, | ||
| + | |||
| + | // To make some parts of the block translucent (like ice, stained glass and portal) | ||
| + | BlockRenderLayerMap.putBlock(TutorialBlocks.MY_BLOCK, | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | You probably also want to make your block non-opaque. To do that, use the ''< | ||
| < | < | ||
| - |  | + |  | 
| </ | </ | ||
| 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: | 
| - | + | < | |
| - | < | + | { | 
| + | [...] | ||
| " | " | ||
| " | " | ||
| - | "mod.fabricmc.examplemod.ExampleMod" | + | "net.fabricmc.example.ExampleMod" | 
| ], | ], | ||
| " | " | ||
| - | "mod.fabricmc.examplemod.ExampleModClient" | + | "net.fabricmc.example.ExampleModClient" | 
| ] | ] | ||
| }, | }, | ||
| + | [...] | ||
| + | } | ||
| </ | </ | ||
| Line 53: | Line 73: | ||
| </ | </ | ||
| - | We then need to make our block unselectable by making its outline shape be non-existent. So override ''< | + | We may also need to make our block unselectable by making its outline shape be non-existent. So override ''< | 
| < | < | ||
tutorial/blockappearance.1700296745.txt.gz · Last modified: 2023/11/18 08:39 by solidblock
                
                