User Tools

Site Tools


Sidebar

Setup

Basics

Items and Item Groups

Blocks and Block Entities

Fluids

Entities

World Generation

Miscellaneous

Mixins

Advanced

Tutorials for Minecraft 1.14

Documentation

Examples


Fabric Сontributors

If you'd like to contribute to Fabric, you might be interested in these links:


Extremely Strange People


Wiki Meta

  • Wiki Meta - Starting point for contributing to the wiki
  • Wiki Agenda - See what is on the current agenda, and what other contributors are currently working on.
tutorial:blockappearance

Manipulating a Block's appearance

This is the 1.15 version of this tutorial. For the 1.14 version, see Manipulating a Block's appearance (1.14).

Making a block transparent

You may have noticed that even if your block's texture is transparent, it still looks opaque. To fix this, you need to set your block's render layer to cutout or transparent.

In a client-sided mod initializer, add:

BlockRenderLayerMap.INSTANCE.putBlock(ExampleMod.MY_BLOCK, RenderLayer.getCutout());
// Replace `RenderLayer.getCutout()` with `RenderLayer.getTranslucent()` if you have a translucent texture.

You probably also want to make your block transparent. To do that, use the nonOpaque method on your block settings.

class MyBlock extends Block {
    public MyBlock() {
        super(Settings.of(Material.STONE).nonOpaque());
    }
 
    [...]
}

Making a block invisible

First we need to make the block appear invisible. To do this we override getRenderType in our block class and return BlockRenderType.INVISIBLE:

    @Override
    public BlockRenderType getRenderType(BlockState blockState) {
        return BlockRenderType.INVISIBLE;
    }

We then need to make our block unselectable by making its outline shape be non-existent. So override getOutlineShape and return an empty VoxelShape:

    @Override
    public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPos, EntityContext entityContext) {
       return VoxelShapes.empty;
    }
tutorial/blockappearance.txt · Last modified: 2020/01/17 13:54 by juuz