mojira.dev
MC-231566

/clone with barrier filter will gain fail result

To trying to cloning an area of barriers, it gets the fail result

No blocks were cloned

What I expect to happen:
There will get the result

Successfully cloned 4 blocks

and the barrier structures will successfully cloned to the new place.

If using "execute store result" to get the result, will get the count of barriers in the source area.
What actually happened was...:
The game sent the fail result, but do be successfully cloned the structures.
However, because of the fail result, execute store wouldn't gain any successful count.
No matter there was using normal, force or move.
Steps to Reproduce:
1.Place some barriers in the source area.
2.Do the clone command with barrier filter:

/clone <begin> <end> <destination> filtered barrier [force|move|normal]

3.There you will get the fail result.

Screenshot:

[media][media]

Attachments

Comments 2

Before the target area's blocks are changed, the game sets all these block to barriers. So when cloning barrier block, it will fail beacause a barrier is already there. Here's the source code about this bug:

clone method in net.minecraft.server.commands.CloneCommans.class:
    ...
    for (CloneBlockInfo cloneBlockInfo : list5) {
      ...
      serverLevel.setBlock(cloneBlockInfo.pos, Blocks.BARRIER.defaultBlockState(), 2);
    }
    int k = 0;
    for (CloneBlockInfo cloneBlockInfo : list4)
      if (serverLevel.setBlock(cloneBlockInfo.pos, cloneBlockInfo.state, 2)) k++; 
    ...

To fix this bug, just make it success if the to-be-cloned block is a barrier. Change the next-to-last line to:

if (cloneBlockInfo.state.getBlock() == Blocks.BARRIER || serverLevel.setBlock(cloneBlockInfo.pos, cloneBlockInfo.state, 2)) k++

wanted to add that because of the fail result this won't trigger any subsequent chain command blocks even though the clone does take place.

SY91419

(Unassigned)

Confirmed

Platform

Low

Commands

/clone, /execute

1.17.1, 1.21

Retrieved