Block entity data is not pasted correctly
zly2006 opened this issue ยท 7 comments
To reproduce:
Observed behavior
In Place & Data Modify Mode
After pressing the operation key, we found 5 of the 16 chests has no block entity data.
This may be caused by some error during setblock command.
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.
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.
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.
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.
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.
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
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.