From 237edb701f26cf54ca4de3c0c860a5d61fa2ce50 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Sun, 10 May 2026 16:57:48 +0100 Subject: [PATCH 1/2] fix: correct lazycopy dimensions and world usage --- .../core/extent/clipboard/SimpleClipboard.java | 12 +++++++++++- .../extent/clipboard/WorldCopyClipboard.java | 18 ++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) 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 f902f60070..a6a51bb72e 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 @@ -17,7 +17,8 @@ public abstract class SimpleClipboard implements Clipboard { this.size = dimensions; this.offset = offset; long longVolume = (long) getWidth() * (long) getHeight() * (long) getLength(); - if (longVolume >= Integer.MAX_VALUE) { + long maxSize = getMaxSize(); + if (maxSize != -1 && longVolume >= maxSize) { throw new IllegalArgumentException("Dimensions are too large for this clipboard format."); } this.area = getWidth() * getLength(); @@ -25,6 +26,15 @@ public abstract class SimpleClipboard implements Clipboard { this.origin = BlockVector3.ZERO; } + /** + * Get the maximum size allowed by this clipboard implementation + * + * @return maximum size in blocks of this clipboard implementation. + */ + public long getMaxSize() { + return Integer.MAX_VALUE; + } + SimpleClipboard(Region region) { this(region.getDimensions(), region.getMinimumPoint()); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/WorldCopyClipboard.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/WorldCopyClipboard.java index b4e30abacd..14e598d120 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/WorldCopyClipboard.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/WorldCopyClipboard.java @@ -1,5 +1,8 @@ package com.fastasyncworldedit.core.extent.clipboard; +import com.fastasyncworldedit.core.Fawe; +import com.fastasyncworldedit.core.queue.implementation.SingleThreadQueueExtent; +import com.fastasyncworldedit.core.util.ExtentTraverser; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSessionBuilder; import com.sk89q.worldedit.WorldEdit; @@ -39,10 +42,7 @@ public WorldCopyClipboard(Supplier supplier, Region region) { */ @Deprecated(forRemoval = true, since = "2.13.0") public WorldCopyClipboard(Supplier supplier, Region region, boolean hasEntities, boolean hasBiomes) { - super(region); - this.hasBiomes = hasBiomes; - this.hasEntities = hasEntities; - this.extent = supplier.get(); + this(supplier.get(), region, hasEntities, hasBiomes); } private WorldCopyClipboard(Extent extent, Region region, boolean hasEntities, boolean hasBiomes) { @@ -50,6 +50,11 @@ private WorldCopyClipboard(Extent extent, Region region, boolean hasEntities, bo this.hasBiomes = hasBiomes; this.hasEntities = hasEntities; this.extent = extent; + if (new ExtentTraverser<>(extent).find(SingleThreadQueueExtent.class) != null) { + // If we have a SingleThreadQueueExtent present, uncache so it cannot be used again for pasting (and therefore + // potentially resetting the world) + Fawe.instance().getQueueHandler().unCache(); + } } public static WorldCopyClipboard of(Extent extent, Region region) { @@ -64,6 +69,11 @@ public static WorldCopyClipboard of(Extent extent, Region region, boolean hasEnt return new WorldCopyClipboard(extent, region, hasEntities, hasBiomes); } + @Override + public long getMaxSize() { + return -1; + } + public Extent getExtent() { return extent; } From 006064802a28c393b91c3f7f99f1f02c9b37d381 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Fri, 15 May 2026 16:51:56 +0100 Subject: [PATCH 2/2] alternative impl --- .../extent/clipboard/ReadOnlyClipboard.java | 19 ++++++- .../extent/clipboard/SimpleClipboard.java | 53 ++++++++++++++----- .../extent/clipboard/WorldCopyClipboard.java | 7 +-- 3 files changed, 58 insertions(+), 21 deletions(-) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/ReadOnlyClipboard.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/ReadOnlyClipboard.java index 0f777196e1..dd9b1ed98d 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/ReadOnlyClipboard.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/ReadOnlyClipboard.java @@ -23,8 +23,25 @@ public abstract class ReadOnlyClipboard extends SimpleClipboard { public final Region region; + /** + * New {@link ReadOnlyClipboard} instance for the given region with max volume of {@link Integer#MAX_VALUE}. Initial offset + * is the clipboard minimum point. + * + * @param region dimensions of this clipboard instance. + */ public ReadOnlyClipboard(Region region) { - super(region); + this(region, Integer.MAX_VALUE); + } + + /** + * New {@link ReadOnlyClipboard} instance for the given region with the given maximum volume. + * + * @param region dimensions of this clipboard instance. + * @param maxSize maximum allowable size of the clipboard. A value of -1 implies infinite volume. + * @since TODO + */ + public ReadOnlyClipboard(Region region, long maxSize) { + super(region, maxSize); this.region = region.clone(); } 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 a6a51bb72e..5b412f881e 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 @@ -13,11 +13,49 @@ public abstract class SimpleClipboard implements Clipboard { private final int volume; private BlockVector3 origin; + /** + * New {@link SimpleClipboard} instance for the given region with max volume of {@link Integer#MAX_VALUE}. Initial offset + * is the clipboard minimum point. + * + * @param region dimensions of this clipboard instance. + */ + SimpleClipboard(Region region) { + this(region.getDimensions(), region.getMinimumPoint()); + } + + /** + * New {@link SimpleClipboard} instance with max volume of {@link Integer#MAX_VALUE}. + * + * @param dimensions dimensions of this clipboard instance. + * @param offset initial offset of this clipboard. + */ SimpleClipboard(BlockVector3 dimensions, BlockVector3 offset) { + this(dimensions, offset, Integer.MAX_VALUE); + } + + /** + * New {@link SimpleClipboard} instance for the given region with the given maximum volume. + * + * @param region dimensions of this clipboard instance. + * @param maxSize maximum allowable size of the clipboard implementation. A value of -1 implies infinite volume. + * @since TODO + */ + SimpleClipboard(Region region, long maxSize) { + this(region.getDimensions(), region.getMinimumPoint(), maxSize); + } + + /** + * New {@link SimpleClipboard} instance with given maximum volume. + * + * @param dimensions dimensions of this clipboard instance. + * @param offset initial offset of this clipboard. + * @param maxSize maximum allowable size of the clipboard implementation. A value of -1 implies infinite volume. + * @since TODO + */ + SimpleClipboard(BlockVector3 dimensions, BlockVector3 offset, long maxSize) { this.size = dimensions; this.offset = offset; long longVolume = (long) getWidth() * (long) getHeight() * (long) getLength(); - long maxSize = getMaxSize(); if (maxSize != -1 && longVolume >= maxSize) { throw new IllegalArgumentException("Dimensions are too large for this clipboard format."); } @@ -26,19 +64,6 @@ public abstract class SimpleClipboard implements Clipboard { this.origin = BlockVector3.ZERO; } - /** - * Get the maximum size allowed by this clipboard implementation - * - * @return maximum size in blocks of this clipboard implementation. - */ - public long getMaxSize() { - return Integer.MAX_VALUE; - } - - SimpleClipboard(Region region) { - this(region.getDimensions(), region.getMinimumPoint()); - } - protected void setOffset(final BlockVector3 offset) { this.offset = offset; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/WorldCopyClipboard.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/WorldCopyClipboard.java index 14e598d120..079da31000 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/WorldCopyClipboard.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/WorldCopyClipboard.java @@ -46,7 +46,7 @@ public WorldCopyClipboard(Supplier supplier, Region region, boolean hasE } private WorldCopyClipboard(Extent extent, Region region, boolean hasEntities, boolean hasBiomes) { - super(region); + super(region, -1); this.hasBiomes = hasBiomes; this.hasEntities = hasEntities; this.extent = extent; @@ -69,11 +69,6 @@ public static WorldCopyClipboard of(Extent extent, Region region, boolean hasEnt return new WorldCopyClipboard(extent, region, hasEntities, hasBiomes); } - @Override - public long getMaxSize() { - return -1; - } - public Extent getExtent() { return extent; }