tutorial:blockappearance
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:blockappearance [2019/07/25 09:06] – created fudge | tutorial:blockappearance [2021/09/09 15:57] – Link client-sided mod initializer to documentation:entrypoint daomephsta | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Manipulating a Block' | ====== Manipulating a Block' | ||
+ | |||
+ | //This is the 1.15+ (1.16 and 1.17 work fine too) 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, override | + | To fix this, you need to set your block's render layer to cutout or transparent. |
+ | |||
+ | In a [[documentation: | ||
<code java> | <code java> | ||
- | class MyBlock extends Block { | + | BlockRenderLayerMap.INSTANCE.putBlock(ExampleMod.MY_BLOCK, RenderLayer.getCutout()); |
- | @Override | + | // Replace `RenderLayer.getCutout()` with `RenderLayer.getTranslucent()` if you have a translucent texture. |
- | public BlockRenderLayer getRenderLayer() { | + | |
- | return BlockRenderLayer.TRANSLUCENT; | + | |
- | } | + | |
- | + | ||
- | | + | |
- | } | + | |
</ | </ | ||
- | You probably also want to make your block transparent. To do that, use the '' | + | You probably also want to make your block transparent. To do that, use the '' |
<code java> | <code java> | ||
class MyBlock extends Block { | class MyBlock extends Block { | ||
- | | ||
- | MaterialColor.AIR, | ||
- | false, | ||
- | false, // isSolid, | ||
- | true, // blocksMovement, | ||
- | false,// blocksLight, | ||
- | true,// | ||
- | false, // burnable, | ||
- | false,// | ||
- | PistonBehavior.NORMAL// | ||
- | ); | ||
- | |||
public MyBlock() { | public MyBlock() { | ||
- | super(Settings.of(myMaterial); | + | super(Settings.of(Material.STONE).nonOpaque()); |
} | } | ||
- | | + | |
} | } | ||
</ | </ | ||
+ | |||
+ | 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. | ||
===== Making a block invisible ===== | ===== Making a block invisible ===== | ||
Line 48: | Line 36: | ||
} | } | ||
</ | </ | ||
- | We then need to make our block unselectable by making its `outlineShape` | + | We then need to make our block unselectable by making its outline shape be non-existent. |
- | So override '' | + | So override '' |
<code java> | <code java> | ||
@Override | @Override | ||
public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPos, EntityContext entityContext) { | public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPos, EntityContext entityContext) { | ||
- | | + | |
} | } | ||
</ | </ |
tutorial/blockappearance.txt · Last modified: 2024/02/05 16:03 by haykam