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 [2020/01/17 13:53] – 1.15 juuz | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Manipulating a Block' | ====== Manipulating a Block' | ||
+ | |||
+ | //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, override | + | To fix this, you need to set your block's render layer to cutout or transparent. |
+ | |||
+ | In a client-sided mod initializer, | ||
<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; | + | |
- | } | + | |
- | + | ||
- | | + | |
- | } | + | |
</ | </ | ||
Line 18: | Line 16: | ||
<code java> | <code java> | ||
class MyBlock extends Block { | class MyBlock extends Block { | ||
- | | + | |
- | MaterialColor.AIR, | + | MaterialColor.AIR, |
- | false, | + | false, // isLiquid, |
false, // isSolid, | false, // isSolid, | ||
true, // blocksMovement, | true, // blocksMovement, | ||
- | false,// blocksLight, | + | false, // blocksLight, |
- | true,// | + | true, // !requiresTool, |
- | false, // burnable, | + | false, // burnable, |
- | false,// | + | false, // replaceable, |
- | PistonBehavior.NORMAL// | + | PistonBehavior.NORMAL // pistonBehavior |
); | ); | ||
public MyBlock() { | public MyBlock() { | ||
- | super(Settings.of(myMaterial); | + | super(Settings.of(MY_MATERIAL)); |
} | } | ||
- | | + | |
} | } | ||
Line 48: | Line 46: | ||
} | } | ||
</ | </ | ||
- | 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