Skip to content

Commit 237edb7

Browse files
committed
fix: correct lazycopy dimensions and world usage
1 parent 6371c5e commit 237edb7

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/SimpleClipboard.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,24 @@ public abstract class SimpleClipboard implements Clipboard {
1717
this.size = dimensions;
1818
this.offset = offset;
1919
long longVolume = (long) getWidth() * (long) getHeight() * (long) getLength();
20-
if (longVolume >= Integer.MAX_VALUE) {
20+
long maxSize = getMaxSize();
21+
if (maxSize != -1 && longVolume >= maxSize) {
2122
throw new IllegalArgumentException("Dimensions are too large for this clipboard format.");
2223
}
2324
this.area = getWidth() * getLength();
2425
this.volume = (int) longVolume;
2526
this.origin = BlockVector3.ZERO;
2627
}
2728

29+
/**
30+
* Get the maximum size allowed by this clipboard implementation
31+
*
32+
* @return maximum size in blocks of this clipboard implementation.
33+
*/
34+
public long getMaxSize() {
35+
return Integer.MAX_VALUE;
36+
}
37+
2838
SimpleClipboard(Region region) {
2939
this(region.getDimensions(), region.getMinimumPoint());
3040
}

worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/WorldCopyClipboard.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.fastasyncworldedit.core.extent.clipboard;
22

3+
import com.fastasyncworldedit.core.Fawe;
4+
import com.fastasyncworldedit.core.queue.implementation.SingleThreadQueueExtent;
5+
import com.fastasyncworldedit.core.util.ExtentTraverser;
36
import com.sk89q.worldedit.EditSession;
47
import com.sk89q.worldedit.EditSessionBuilder;
58
import com.sk89q.worldedit.WorldEdit;
@@ -39,17 +42,19 @@ public WorldCopyClipboard(Supplier<Extent> supplier, Region region) {
3942
*/
4043
@Deprecated(forRemoval = true, since = "2.13.0")
4144
public WorldCopyClipboard(Supplier<Extent> supplier, Region region, boolean hasEntities, boolean hasBiomes) {
42-
super(region);
43-
this.hasBiomes = hasBiomes;
44-
this.hasEntities = hasEntities;
45-
this.extent = supplier.get();
45+
this(supplier.get(), region, hasEntities, hasBiomes);
4646
}
4747

4848
private WorldCopyClipboard(Extent extent, Region region, boolean hasEntities, boolean hasBiomes) {
4949
super(region);
5050
this.hasBiomes = hasBiomes;
5151
this.hasEntities = hasEntities;
5252
this.extent = extent;
53+
if (new ExtentTraverser<>(extent).find(SingleThreadQueueExtent.class) != null) {
54+
// If we have a SingleThreadQueueExtent present, uncache so it cannot be used again for pasting (and therefore
55+
// potentially resetting the world)
56+
Fawe.instance().getQueueHandler().unCache();
57+
}
5358
}
5459

5560
public static WorldCopyClipboard of(Extent extent, Region region) {
@@ -64,6 +69,11 @@ public static WorldCopyClipboard of(Extent extent, Region region, boolean hasEnt
6469
return new WorldCopyClipboard(extent, region, hasEntities, hasBiomes);
6570
}
6671

72+
@Override
73+
public long getMaxSize() {
74+
return -1;
75+
}
76+
6777
public Extent getExtent() {
6878
return extent;
6979
}

0 commit comments

Comments
 (0)