public class VerticalSlabBlock extends HorizontalFacingBlock { // the codec is required since 1.20.5 however not actually used in Minecraft yet. public static final MapCodec CODEC = Block.createCodec(VerticalSlabBlock::new); public VerticalSlabBlock(Settings settings) { super(settings); setDefaultState(getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH)); } @Override protected MapCodec getCodec() { return CODEC; } @Override protected void appendProperties(StateManager.Builder builder) { builder.add(Properties.HORIZONTAL_FACING); } @Override public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext ctx) { Direction dir = state.get(FACING); return switch (dir) { case NORTH -> VoxelShapes.cuboid(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.5f); case SOUTH -> VoxelShapes.cuboid(0.0f, 0.0f, 0.5f, 1.0f, 1.0f, 1.0f); case EAST -> VoxelShapes.cuboid(0.5f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); case WEST -> VoxelShapes.cuboid(0.0f, 0.0f, 0.0f, 0.5f, 1.0f, 1.0f); default -> VoxelShapes.fullCube(); }; } @Override public BlockState getPlacementState(ItemPlacementContext ctx) { return super.getPlacementState(ctx).with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite()); } }