mojira.dev
MC-50166

Game states that "The block couldn't be placed" when using /setblock to place air in a space occupied by a tile entity, despite working

When using /setblock to place air blocks, the game will state "The block couldn't be placed" in red text, despite clearly working. On the right of the chest in the attachment was another chest (to make it a large chest), but the error message appeared after I removed it by /setblock-ing down air in an area with a chest.

Also affects the /fill command with barrier blocks.


Code analysis by @unknown can be found in this comment.

Related issues

Attachments

Comments

migrated
[media][media][media][media]
kumasasa

Please provide the exact command you've used.

migrated

/setblock ~-1 ~ ~ air

migrated

It works fine for me.

migrated

Fill it to the brim.

kumasasa

Confirmed.

migrated

Still happens in 14w11b.

shufboyardee

still in 27b.

migrated

Note that it also doesn't do a block update when this happens.

migrated

Confirmed for minecraft 1.8.1

migrated

Confirmed for 1.8.2-pre4.

mrpingouin1

It also put a wrong stat value

marcono1234

Confirmed for

  • 15w34d

migrated

Confirmed for 15w38a

marcono1234

The reason for that seems to be that the setBlockState(BlockPos pos, IBlockState newState, int flags) method of the /Client/src/net/minecraft/world/World.java class (MCP 1.8 names) is called twice from the processCommand(ICommandSender sender, String[] args) method in the /Client/src/net/minecraft/command/server/CommandSetBlock.java class:

public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length < 4)
    {
        throw new WrongUsageException("commands.setblock.usage", new Object[0]);
    }
    else
    {
        //...
        
         if (!var6.isBlockLoaded(var3))
        {
            throw new CommandException("commands.setblock.outOfWorld", new Object[0]);
        }
        else
        {
            //...
            
            TileEntity var13 = var6.getTileEntity(var3);

            if (var13 != null)
            {
                if (var13 instanceof IInventory)
                {
                    ((IInventory)var13).clearInventory();
                }

                // This can be removed
                //var6.setBlockState(var3, Blocks.air.getDefaultState(), var4 == Blocks.air ? 2 : 4);
            }

            IBlockState var10 = var4.getStateFromMeta(var5);

            if (!var6.setBlockState(var3, var10, 2))
            {
                throw new CommandException("commands.setblock.noChange", new Object[0]);
            }
            else
            {
                //...
            }
        }
    }
}

This causes the block the be set to air first and as it is already air the second call will return false.

Note: The same happens for the /fill command except with barrier blocks

marcono1234

Could you please include that?

migrated

Confirmed for 15w51b

NeunEinser

Confirmed for 16w06a.

marcono1234

Confirmed for

  • 1.9.1-pre3

Also affects the /fill command with barrier blocks

migrated

Confirm for 1.9.3-pre2.

migrated

This bug also causes conditional command blocks to fail when they should succeed, and seems to affect all tileentities (not just chests).

migrated

Confirmed for 1.9.4.

I also found out about it because of conditional command blocks, in my case it was signs I was trying to replace. /fill works as a placeholder.

migrated

Can confirm for 1.11.

migrated

I think that is because minecraft destory that block and then setted air but there was already air. ( air is placed if block is destroyed )

if so maybe this can be fixed by testing if block is "air" and mode is "destroy" then only calculate size and no setblocking / filling. 😃

sorry for my bad English I am Czech.

SunCat

@unknown, the cause of this bug is already explained in this comment

migrated

SunCat, sorry I mised that comment. 😃

NeunEinser

Can confirm for 1.11.2

migrated

ays the status is resolved but this still seems to happen for me in 1.12.2

kumasasa

@unknown, 1.12.2 is no longer supported, please test this is in the latest release 1.13.1

migrated

migrated

Confirmed

Minecraft 14w08a, Minecraft 14w11b, Minecraft 14w27b, Minecraft 1.8, Minecraft 1.8.1, ..., Minecraft 1.9.3 Pre-Release 2, Minecraft 1.9.4, Minecraft 1.10.2, Minecraft 1.11, Minecraft 1.11.2

Minecraft 1.12 Pre-Release 1

Retrieved