tutorial:blockappearance
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
tutorial:blockappearance [2019/07/25 09:06] – created fudge | tutorial:blockappearance [2024/08/26 08:28] (current) – solidblock | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Manipulating a Block' | ====== Manipulating a Block' | ||
- | ===== Making a block transparent ===== | ||
- | You may have noticed that even if your block' | ||
- | To fix this, override '' | ||
- | <code java> | ||
- | class MyBlock extends Block { | ||
- | @Override | ||
- | public BlockRenderLayer getRenderLayer() { | ||
- | return BlockRenderLayer.TRANSLUCENT; | ||
- | } | ||
- | | + | //This is the 1.15+ version of this tutorial. For the 1.14 version, see [[tutorial: |
- | } | + | |
- | </ | + | ===== Making a block transparent or translucent ===== |
+ | You may have noticed that even if your block' | ||
- | You probably also want to make your block transparent. To do that, use the '' | + | In a [[documentation: |
- | <code java> | + | |
- | class MyBlock extends Block { | + | |
- | | + | |
- | MaterialColor.AIR, | + | |
- | false, | + | |
- | false, // isSolid, | + | |
- | true, // blocksMovement, | + | |
- | false,// blocksLight, | + | |
- | true,// | + | |
- | false, // burnable, | + | |
- | false,// | + | |
- | PistonBehavior.NORMAL// | + | |
- | ); | + | |
- | | + | < |
- | | + | @Environment(EnvType.CLIENT) |
+ | public | ||
+ | public void onInitializeClient() { | ||
+ | | ||
+ | BlockRenderLayerMap.INSTANCE.putBlock(TutorialBlocks.MY_BLOCK, | ||
+ | |||
+ | // To make some parts of the block translucent | ||
+ | BlockRenderLayerMap.INSTANCE.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. | ||
+ | |||
+ | Be sure to add your client entrypoint to [[documentation: | ||
+ | <code javascript> | ||
+ | { | ||
+ | [...] | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | ] | ||
+ | }, | ||
+ | [...] | ||
+ | } | ||
</ | </ | ||
+ | |||
+ | Note: For non-transparent blocks that are not full, you may have to override the ''< | ||
===== Making a block invisible ===== | ===== Making a block invisible ===== | ||
- | First we need to make the block appear invisible. | + | |
- | To do this we override '' | + | First we need to make the block appear invisible. To do this, we override '' |
- | <code java> | + | |
+ | <yarncode | ||
@Override | @Override | ||
- | public | + | public |
- | return | + | return |
} | } | ||
- | </code> | + | </yarncode> |
- | We then need to make our block unselectable by making its `outlineShape` | + | |
- | So override '' | + | We may also need to make our block unselectable by making its outline shape be non-existent. So override '' |
- | <code java> | + | |
+ | <yarncode | ||
@Override | @Override | ||
- | public | + | public |
- | | + | |
} | } | ||
- | </code> | + | </yarncode> |
tutorial/blockappearance.1564045618.txt.gz · Last modified: 2019/07/25 09:06 by fudge