From 237edb701f26cf54ca4de3c0c860a5d61fa2ce50 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Sun, 10 May 2026 16:57:48 +0100 Subject: [PATCH] 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; }