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

Dieser Commit ist enthalten in:
dordsor21 2021-12-30 16:05:16 +00:00
Ursprung f30ea96268
Commit 0994ea1e67
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
3 geänderte Dateien mit 11 neuen und 7 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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