Litematica

Litematica

9M Downloads

Block entity data is not pasted correctly

zly2006 opened this issue ยท 7 comments

commented

To reproduce:

  1. Make a schema in single player mode, with 16 chests full of stones
    expected
  2. paste it to a server.

Observed behavior

In Place & Data Modify Mode

0-not-pasted
After pressing the operation key, we found 5 of the 16 chests has no block entity data.
1-empty
3-all-empty
This may be caused by some error during setblock command.
error
I used the following code to see what is wrong but there is not much information.

@Mixin(SetBlockCommand.class)
public class MixinSetBlockCommand {
    @Inject(method = "execute", at = @At(value = "INVOKE", target = "Lcom/mojang/brigadier/exceptions/SimpleCommandExceptionType;create()Lcom/mojang/brigadier/exceptions/CommandSyntaxException;"))
    private static void onError(ServerCommandSource source, BlockPos pos, BlockStateArgument block, SetBlockCommand.Mode mode, Predicate<CachedBlockPosition> condition, CallbackInfoReturnable<Integer> cir) {
        System.out.println("SetBlockCommand failed, pos=" + pos + ", block=" + block.getBlockState() + ", mode=" + mode);
        System.out.println("Current block state: " + source.getWorld().getBlockState(pos));
        BlockEntity be = source.getWorld().getBlockEntity(pos);
        if (be != null) {
            System.out.println("Current block entity: " + be.toInitialChunkDataTag());
        }
    }
}

Logs here:

[00:24:58] [Server thread/INFO] (Minecraft) [Steve47876: Changed the block at 4, 72, 69]
[00:24:58] [Server thread/INFO] (Minecraft) [Steve47876: Changed the block at 6, 68, 77]
[00:24:58] [Server thread/INFO] (Minecraft) [STDOUT]: SetBlockCommand failed, pos=BlockPos{x=-1, y=72, z=69}, block=Block{minecraft:air}, mode=REPLACE
[00:24:58] [Server thread/INFO] (Minecraft) [STDOUT]: Current block state: Block{minecraft:air}
[00:24:58] [Server thread/INFO] (Minecraft) [Steve47876: Changed the block at 6, 68, 78]
[00:24:58] [Server thread/INFO] (Minecraft) [STDOUT]: SetBlockCommand failed, pos=BlockPos{x=6, y=72, z=69}, block=Block{minecraft:air}, mode=REPLACE
[00:24:58] [Server thread/INFO] (Minecraft) [STDOUT]: Current block state: Block{minecraft:air}
[00:24:58] [Server thread/INFO] (Minecraft) [Steve47876: Changed the block at 6, 68, 79]
[00:24:58] [Server thread/INFO] (Minecraft) [STDOUT]: SetBlockCommand failed, pos=BlockPos{x=-2, y=72, z=70}, block=Block{minecraft:air}, mode=REPLACE
[00:24:58] [Server thread/INFO] (Minecraft) [STDOUT]: Current block state: Block{minecraft:air}
[00:24:58] [Server thread/INFO] (Minecraft) [Steve47876: Changed the block at 7, 68, 77]

In Place & Clone Mode

In this mode, the behavior if more strange: even the block state cannot be pasted correctly. however the block entity data is correct, if the block is successfully placed.
clone

Some error during setblock command is also reported by my code, log here:

[00:35:17] [Server thread/INFO] (Minecraft) [STDOUT]: SetBlockCommand failed, pos=BlockPos{x=-6, y=75, z=67}, block=Block{minecraft:air}, mode=REPLACE
[00:35:17] [Server thread/INFO] (Minecraft) [STDOUT]: Current block state: Block{minecraft:air}
[00:35:17] [Server thread/INFO] (Minecraft) [STDOUT]: SetBlockCommand failed, pos=BlockPos{x=2, y=75, z=67}, block=Block{minecraft:air}, mode=REPLACE
[00:35:17] [Server thread/INFO] (Minecraft) [STDOUT]: Current block state: Block{minecraft:air}

Also thanks to @tangsu99 for discovering this bug.

commented

My commandLimitPerTick is just the default value 64.

I checked out your pre-rewrite/fabric/1.19.x, and i confirm this can reproduce with the default command limit and i am not moving.

commented

What is your commandLimitPerTick set to? You may be running out of the temporary block positions around the player for the NBT smuggling operation? I think the setblock with air would point to that, as it gets rid of those temporary blocks with a setblock air command, and if there was no block placed. That might happen if the player moved and intersected the temp position, or maybe if there were no valid temp positions? Although I don't think it would try to get rid of it if it failed to find a valid position in the first place.

And yeah the Place & Data Modify is the only option that actually works properly... when it works properly... :p The clone option can't get the correct block state if there are any neighbor connections etc. And the teleport option (if it was still there?) just doesn't work at all.

commented

The default command limit is often way too high even without NBT restore. With NBT restore I'd recommend dropping it to maybe 4 commands per tick or even lower, otherwise you will likely run out of the temp positions around the player.

commented

mod version: litematica-fabric-1.19.4-0.14.3

also tested with only these mods:
- fabric-resource-loader-v0 0.6.0+6bee109e90
- fabricloader 0.14.9
- java 17
- lazydfu 0.1.3
- litematica-server-paster 1.1.1-SHAPSHOT
- litematica-fabric-1.19.2-0.12.5
- minecraft 1.19.2
and this bug can be reproduced

commented

09b18fe10830197c2a80d15f121fd336
bc25f7deb5bf47e4862b50deb8f43f4f
it doesn't seem to be working.....

commented

And i am sure in my commit 5962fe1, it can succeed even if you are moving and using 64 as the command limit per tick.
I mean, maybe you want to test that commit and i ll open a pr for it.

commented

And in Place & Clone mode, i fixed missing blocks, even the block states are still wrong but now they can be placed properly.

like this: