Fix issue with offset/origin when pasting a clipboard via API without wrapping into a BlockArrayClipboard

This commit is contained in:
dordsor21 2021-12-30 16:05:16 +00:00
parent f30ea96268
commit 0994ea1e67
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
3 changed files with 11 additions and 7 deletions

View File

@ -220,13 +220,17 @@ public class FaweDelegateRegionManager {
Clipboard clipB = Clipboard.create(regionB, UUID.randomUUID());
ForwardExtentCopy copyA = new ForwardExtentCopy(sessionA, regionA, clipA, clipA.getMinimumPoint());
ForwardExtentCopy copyB = new ForwardExtentCopy(sessionB, regionB, clipB, clipB.getMinimumPoint());
copyA.setCopyingBiomes(true);
copyB.setCopyingBiomes(true);
try {
Operations.completeLegacy(copyA);
Operations.completeLegacy(copyB);
clipA.paste(sessionB, swapPos.getBlockVector3(), true);
clipB.paste(sessionA, pos1.getBlockVector3(), true);
sessionA.flushQueue();
sessionB.flushQueue();
clipA.flush();
clipB.flush();
clipA.paste(sessionB, swapPos.getBlockVector3(), true, true, true);
clipB.paste(sessionA, pos1.getBlockVector3(), true, true, true);
sessionA.close();
sessionB.close();
} catch (MaxChangedBlocksException e) {
e.printStackTrace();
}

View File

@ -276,7 +276,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
int offsetZ = byteBuffer.getShort(20);
region.shift(BlockVector3.at(offsetX, offsetY, offsetZ));
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, this);
clipboard.setOrigin(getOrigin());
clipboard.setOrigin(getOrigin().add(offset));
return clipboard;
} catch (Throwable e) {
e.printStackTrace();
@ -289,7 +289,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
int ox = byteBuffer.getShort(10);
int oy = byteBuffer.getShort(12);
int oz = byteBuffer.getShort(14);
return BlockVector3.at(ox, oy, oz);
return BlockVector3.at(ox, oy, oz).subtract(offset);
}
@Override

View File

@ -7,10 +7,10 @@ import com.sk89q.worldedit.regions.Region;
public abstract class SimpleClipboard implements Clipboard {
protected BlockVector3 offset;
private final BlockVector3 size;
private final int area;
private final int volume;
private BlockVector3 offset;
private BlockVector3 origin;
SimpleClipboard(BlockVector3 dimensions, BlockVector3 offset) {