From 0994ea1e67e702c9bb652d0986297250b070f5f1 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 30 Dec 2021 16:05:16 +0000 Subject: [PATCH] Fix issue with offset/origin when pasting a clipboard via API without wrapping into a BlockArrayClipboard --- .../plotsquared/FaweDelegateRegionManager.java | 12 ++++++++---- .../extent/clipboard/DiskOptimizedClipboard.java | 4 ++-- .../core/extent/clipboard/SimpleClipboard.java | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateRegionManager.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateRegionManager.java index 61f1943b1..d50300106 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateRegionManager.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateRegionManager.java @@ -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(); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java index 6ace08060..efde68a56 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java @@ -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 diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/SimpleClipboard.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/SimpleClipboard.java index 8847d0434..b3494e6d2 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/SimpleClipboard.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/SimpleClipboard.java @@ -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) {