User Tools

Site Tools


Sidebar

← Go back to the homepage

Fabric Tutorials

Setup

Basics

These pages are essential must-reads when modding with Fabric, and modding Minecraft in general, if you are new to modding, it is recommended you read the following.

Items

Blocks and Block Entities

Data Generation

World Generation

Commands

These pages will guide you through Mojang's Brigadier library which allows you to create commands with complex arguments and actions.

Events

These pages will guide you through using the many events included in Fabric API, and how to create your own events for you or other mods to use.

Entities

Fluids

Mixins & ASM

These pages will guide you through the usage of SpongePowered's Mixin library, which is a highly complex topic. We recommend you read these pages thoroughly.

Miscellaneous

Yarn

Contribute to Fabric

tutorial:1.14:blockappearance

Manipulating a Block's appearance (1.14)

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

Making a block transparent

You may have noticed that even if your block's texture is transparent, it still looks opaque. To fix this, override getRenderLayer and return BlockRenderLayer.TRANSLUCENT:

class MyBlock extends Block {
    @Environment(EnvType.CLIENT)
    @Override
    public BlockRenderLayer getRenderLayer() {
        return BlockRenderLayer.TRANSLUCENT;
    }
 
    [...]
}

You probably also want to make your block transparent. To do that, use the Material constructor to set blocksLight to false.

class MyBlock extends Block {
     private static final Material MY_MATERIAL = new Material(
            MaterialColor.AIR, // materialColor,
            false, // isLiquid,
            false, // isSolid,
            true, // blocksMovement,
            false, // blocksLight,  <----- Important part, the other parts change as you wish
            true, // !requiresTool,
            false, // burnable,
            false, // replaceable,
            PistonBehavior.NORMAL // pistonBehavior
    );
 
    public MyBlock() {
        super(Settings.of(MY_MATERIAL));
    }
 
    [...]
}

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/1.14/blockappearance.txt · Last modified: 2020/01/17 14:04 by jamieswhiteshirt