mojira.dev
MC-221603

Light blocks block blocks pushed by piston

When a piston tries to push some blocks, a light block in the way will prevent the push, like obsidian does.

How to reproduce

  1. Build this

    [media]
  2. Power the piston
    → ❌ It won't push

Expected result
It pushes through the light block just like air

Linked issues

Attachments

Comments 16

Can confirm. The light block is basically unmovable by pistons. Would make sense if it gets destroyed. On bedrock it can be moved like a normal block. MCPE-59059

Light blocks in general cannot be pushed or pulled, unlike in bedrock. This doesn't require the additional block.

Can confirm in 21w14a.

Can confirm in 21w15a.

6 more comments

Can confirm in 1.18.2.

Can confirm in 1.19.

Can confirm in 1.19.2.

Code analysis (Mojang mappings, 1.20.2): This is because pistons can't push blocks that are unbreakable (have a destroy time of -1):

net.minecraft.world.level.block.piston.PistonBaseBlock.java

...
   public static boolean isPushable(...) {
        ...
        if ($$0.is(Blocks.PISTON) || $$0.is(Blocks.STICKY_PISTON)) {
            ...
        } else {
            if ($$0.getDestroySpeed($$1, $$2) == -1.0f) {
                return false;
            }
            ...
        }
        return !$$0.hasBlockEntity();
    }
...

Since light blocks have a destroy speed of -1, they can't be pushed. This could be fixed by adding a check for light blocks before:

if (blockState.is(Blocks.LIGHT)) {
      return true;
   }

This, of course, assumes that light blocks should be able to be pushed by pistons, which is what occurs in Bedrock Edition.

Alternate solution, make blocks that block pistons a block tag (and blocks that break when moved, and blocks that don't stick to sticky surfaces).

tryashtar

(Unassigned)

Confirmed

Platform

Normal

Block states

light, vanilla-parity

21w13a, 21w14a, 21w15a, 21w16a, 21w17a, ..., 1.19.3, 23w06a, 1.19.4, 1.20.2, 1.20.4

Retrieved