Block Break When Nothing is Below

Started by ThrillerGriller on

Topic category: Help with modding (Data Packs)

Last seen on 03:44, 11. Aug 2023
Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Block Break When Nothing is Below

I've created a carpet block. The problem I'm having is when I break the block under it, it doesn't break like a normal carpet would. Instead, it just floats like if it was a block of stone or wood.

 

Carpet block is floating instead of breaking. Can be placed even if there is no block underneath.

 

I think here are the properties:

public class LeafPileBlock extends Block {

    public LeafPileBlock() {
        super(BlockBehaviour.Properties.of(Material.CLOTH_DECORATION).sound(SoundType.MOSS_CARPET).strength(0.1f).noOcclusion()
                .isRedstoneConductor((bs, br, bp) -> false));

    }

    @Override
    public boolean shouldDisplayFluidOverlay(BlockState state, BlockAndTintGetter world, BlockPos pos, FluidState fluidstate) {
        return true;
    }

    @Override
    public boolean propagatesSkylightDown(BlockState state, BlockGetter reader, BlockPos pos) {
        return true;
    }

    @Override
    public int getLightBlock(BlockState state, BlockGetter worldIn, BlockPos pos) {
        return 0;
    }

    @Override
    public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
        Vec3 offset = state.getOffset(world, pos);
        return box(0, 0, 0, 16, 1, 16)

                .move(offset.x, offset.y, offset.z);
    }

    @Override
    public int getFlammability(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
        return 60;
    }

    @Override
    public PushReaction getPistonPushReaction(BlockState state) {
        return PushReaction.DESTROY;
    }

    @OnlyIn(Dist.CLIENT)
    public static void registerRenderLayer() {
        ItemBlockRenderTypes.setRenderLayer(GamemodModBlocks.LEAF_PILE.get(), renderType -> renderType == RenderType.cutout());
    }

}