mojira.dev
MC-17851

Blocks requiring any support block (carpets, signs) placed on piston head break when sticky piston retracts

The bug

Blocks requiring any support block, like carpets or signs, normally do not drop when the supporting block is moved (see MC-8836 which may be intended), however they do break when the supporting block is the piston head which retracts even though a different block is pulled beneath them.

For carpets this happens as well when the carpet itself is moved because it is on top of an upwards facing piston.

See also the attached video

[media]

.

How to reproduce

  1. Place an upwards facing sticky piston

  2. Place a carpet on top

  3. Power the piston
    → The carpet drops

  4. Now place a slime block between the piston and carpet

  5. Power the piston
    → The carpet does not drop as expected

Code analysis

Based on 1.11.2 decompiled using MCP 9.37

The problem is that the methods BlockPistonBase.eventReceived(IBlockState, World, BlockPos, int, int) and BlockPistonBase.doMove(World, BlockPos, EnumFacing, boolean) update neighboring blocks when setting blockstates.

Suggested fix

Note: It would be good if someone familiar with expected piston behavior and their use in farms or slime block machines could verify that this fix solves this problem as expected.

net.minecraft.block.BlockPistonBase.eventReceived(IBlockState, World, BlockPos, int, int)

/**
 * Called on both Client and Server when World#addBlockEvent is called. On the Server, this may perform additional
 * changes to the world, like pistons replacing the block with an extended base. On the client, the update may
 * involve replacing tile entities, playing sounds, or performing other visual actions to reflect the server side
 * changes.
 */
public boolean eventReceived(IBlockState state, World worldIn, BlockPos pos, int id, int param)
{
    EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);

    // ...

    if (id == 0)
    {
        // ...
    }
    else if (id == 1)
    {
        // ...

        // Comment: Replaced this
        // worldIn.setBlockState(pos, Blocks.PISTON_EXTENSION.getDefaultState().withProperty(BlockPistonMoving.FACING, enumfacing).withProperty(BlockPistonMoving.TYPE, this.isSticky ? BlockPistonExtension.EnumPistonType.STICKY : BlockPistonExtension.EnumPistonType.DEFAULT), 3);
        worldIn.setBlockState(pos, Blocks.PISTON_EXTENSION.getDefaultState().withProperty(BlockPistonMoving.FACING, enumfacing).withProperty(BlockPistonMoving.TYPE, this.isSticky ? BlockPistonExtension.EnumPistonType.STICKY : BlockPistonExtension.EnumPistonType.DEFAULT), 2);
        worldIn.setTileEntity(pos, BlockPistonMoving.createTilePiston(this.getStateFromMeta(param), enumfacing, false, true));

        if (this.isSticky)
        {
            // ...

            if (!flag1 && iblockstate.getMaterial() != Material.AIR && canPush(iblockstate, worldIn, blockpos, enumfacing.getOpposite(), false) && (iblockstate.getMobilityFlag() == EnumPushReaction.NORMAL || block == Blocks.PISTON || block == Blocks.STICKY_PISTON))
            {
                this.doMove(worldIn, pos, enumfacing, false);
            }
            // Comment: Added this
            else {
                worldIn.setBlockToAir(pos.offset(enumfacing));
            }
        }
        else
        {
            worldIn.setBlockToAir(pos.offset(enumfacing));
        }

        worldIn.playSound((EntityPlayer)null, pos, SoundEvents.BLOCK_PISTON_CONTRACT, SoundCategory.BLOCKS, 0.5F, worldIn.rand.nextFloat() * 0.15F + 0.6F);
    }

    return true;
}

net.minecraft.block.BlockPistonBase.doMove(World, BlockPos, EnumFacing, boolean)

private boolean doMove(World worldIn, BlockPos pos, EnumFacing direction, boolean extending)
{
    if (!extending)
    {
        // Comment: Replaced this
        // worldIn.setBlockToAir(pos.offset(direction));
        worldIn.setBlockState(pos.offset(direction), Blocks.AIR.getDefaultState(), 2);
    }
    
    // ...
}

Related issues

Attachments

Comments

migrated
[media][media][media]
kumasasa

Confirmed

Ezekiel

Is this still a concern in the current Minecraft version? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

migrated

This is a similar bug. A carpet block under a sticky piston can be pull up, but when this happens the carpet breaks because there is no block under it. I think carpets shouldn't be able to be pulled up by pistons because the carpet block always breaks and the piston and the carpet don't even touch (visually).

migrated

If slabs can be pulled and pushed vertically even if they don't visually touch, so should carpets. I don't think what you described is a bug.

migrated

Still in 10c and 1.7.5

migrated

Confirmed for 14w17a

migrated

Confirmed for 14w18a

Kyiiel

Confirmed for 14w19a

Please update that is also happens when being pulled by a slime block.

migrated

Fixed in 14w25a

migrated

Not fixed for me in 14w25b.

migrated

Oh wait, I thought this was horizontal. This title should have been more specific. "Carpets can be pushed upwards by sticky pistons & slime block but not pulled back" would be a better title.

migrated

Yes, me too the first time.

migrated

14w26c confirmed

migrated

14w28b confirmed

migrated

confirmed for 1.8.7

wobst.michael

Can no longer reproduce in 1.13-pre3. Apparently this has been fixed in some of the 1.13 snapshot series.

ileon

(Unassigned)

Confirmed

carpet, pulled, pushed, sticky_piston

Snapshot 13w24b, Snapshot 13w26a, Minecraft 1.6.1, Minecraft 1.6.2, Minecraft 1.6.4, ..., Minecraft 1.11.2, Minecraft 1.12 Pre-Release 6, Minecraft 1.12, Minecraft 1.12.1, Minecraft 1.12.2

Minecraft 1.13-pre3

Retrieved