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
is duplicated by
relates to
Attachments
Comments


Please provide the exact command you've used.

/setblock ~-1 ~ ~ air

It works fine for me.

Fill it to the brim.

Confirmed.

Still happens in 14w11b.

still in 27b.

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

Confirmed for minecraft 1.8.1

Confirmed for 1.8.2-pre4.

It also put a wrong stat value

Confirmed for
15w34d

Confirmed for 15w38a

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

Could you please include that?

Confirmed for 15w51b
Confirmed for 16w06a.

Confirmed for
1.9.1-pre3
Also affects the /fill
command with barrier blocks

Confirm for 1.9.3-pre2.

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

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.

Can confirm for 1.11.

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.

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

SunCat, sorry I mised that comment. 😃
Can confirm for 1.11.2

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

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