Block Break When Nothing is Below

Started by ThrillerGriller on

Topic category: Help with modding (Java Edition)

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());
    }

}

 

I accidently posted this on the datapacks section, would be great if someone could tell me how to delete it if you can. 

Last seen on 11:34, 9. Oct 2022
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Put this in the tick update…
Wed, 07/27/2022 - 08:21

Put this in the tick update trigger of the block

🟦=> air

 

if [is {get block at x y-1 z} material type (air)

         remove block at x y z

 

 

Explanation: 

checks if block below (x y-1 z) it is of material type air then it'll break itself (which is the block at x y z its own relative positions)

Last seen on 11:34, 9. Oct 2022
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
interesting block idea tho
Wed, 07/27/2022 - 08:23

interesting block idea tho