mojira.dev
MC-222212

Carpets can be placed on top of light blocks

The Bug

Light blocks are meant to be completely non-solid for all non-mapmaking purposes, yet carpets consider them a suitable block for placement atop, which is not the case for air. This does not seem intended.

Steps to Reproduce

  • Build the setup as shown in the attachment below. setup.png

  • Obtain a light block and a carpet.

    /give @s minecraft:light
    /give @s minecraft:white_carpet
  • Place down the light block on top of the diamond block.

  • Place down the carpet on top of the light block by looking at the gold block.

  • Take note as to whether or not carpets can be placed on top of light blocks.

Observed Behavior

Carpets can be placed on top of light blocks.

Expected Behavior

Carpets would not be able to be placed on top of light blocks.

Linked issues

Attachments

Comments 20

Can confirm, however this is likely intended. This actually very useful. This is the first time that it is possible to have floating carptets with a block below that cannot be broken in survival mode (structure void can be broken in survival, see MC-102908) and has no collision box unlike barriers. You can place carpets on top of any block that is not air, which is intended per MC-17833.

Can confirm in 21w14a.

Can confirm in 21w15a.

Can confirm in 21w16a.

Duplicate of MC-17833

10 more comments

Here's a code analysis of this issue.

Code Analysis:

The following is based on a decompiled version of Minecraft 1.18.1 using MCP-Reborn.

net.minecraft.world.level.block.CarpetBlock.java

public class CarpetBlock extends Block {
   ...
   public boolean canSurvive(BlockState $bs, LevelReader $lr, BlockPos $bp) {
      return !$lr.isEmptyBlock($bp.below());
   }
}

net.minecraft.world.level.LevelReader.java

public interface LevelReader extends BlockAndTintGetter, CollisionGetter, BiomeManager.NoiseBiomeSource {
   ...
   default boolean isEmptyBlock(BlockPos $bp) {
      return this.getBlockState($bp).isAir();
   }
   ...

If we look at the above classes, we can see that in order for a carpet block to survive, the block directly below it must not be air. If it is air, the carpet cannot be placed/will be destroyed. Since a light block isn't air, carpets can be supported by them, resulting in this problem occurring.

Can confirm in 1.18.2.

Can confirm in 1.19.

Can confirm in 1.19.2.

Can confirm in 1.19.4

muzikbike

(Unassigned)

Confirmed

Platform

Normal

Block states

carpet, light, placement-and-support

21w13a, 21w14a, 21w15a, 21w16a, 21w17a, ..., 1.20 Pre-release 1, 1.20.1, 23w32a, 23w33a, 1.20.4

Retrieved